Recurrence Relation 9-1 split - recursion

Given the recurrence relation: $T(n)=T(9n/10)+T(n/10)+cn$, the recursion tree is given by recurrence tree, how did they work out the longest path being $log_{10/9}n$?
Edit: unrelated, why does enclosing in dollar signs $, not format maths properly? Does that only work in the math part of stackoverflow?

Related

In Big-O terms if O(n-1) is the same thing as O(n) then why in the master theorem is T(n-1) not equal T(n)?

Ok So I'm pretty new to CS and was recently learning about Big-O, Theta, and Omega as well as the master theorem and in lecture I saw that this was not the case for some reason and was wondering why is that?
Although both O(n) and T(n) use capital letters on the outside and lower-case n in the middle, they represent fundamentally different concepts.
If you’re analyzing an algorithm using a recurrence relation, it’s common to let T(n) denote the amount of time it takes for the algorithm to complete on an input of size n. As a result, we wouldn’t expect T(n) to be the same as T(n-1), since, in most cases, algorithms take longer to run when you give them larger inputs.
More generally, for any function f, if you wanted to claim that f(n) = f(n-1), you’d need to explain why you could assume this because this generally isn’t the case.
The tricky bit here is that when we write O(n), it looks like we’re writing a function named O and passing in the argument n, but the notation means something totally different. The notation O(n) is a placeholder for “some function that, when the inputs gets really big, is bounded from above by a multiple of n.” Similarly, O(n-1) means “some function that, when the inputs get really big, is bounded from above by a multiple of n-1.” And it happens to be the case that any function that’s bounded above by a multiple of n is also bounded from above by a multiple of n-1, which is why O(n) and O(n-1) denote the same thing.
Hope this helps!

In Z3 solver , is there a way to represent numbers in fixed point notation with arithmetic operations support

In Z3 solver, I want to represent numbers using fixed point notation and perform arithmetic operations with rounding.
Example: Let's say, X, Y and Z represent fixed point numbers type,
X[4,3] Total 4 digits number with 3 digits after the decimal.
Y[4,2]
Z[4,1]
Assign fixed point numbers to X, Y
X = 1.234 ( here there are total 4 digits & decimal digits are 3 )
Y = 45.67
Perform the Fixed point numbers Arithmetic operation
Z = X * Y (The result 56.35678 needs to be rounded and assign to Z i.e., 56.36)
I understand that, the Z3 supports floating point theory for numbers but not for fixed point theory for numbers with arithmetic operations !
Is there any plan to support fixed point theory for numbers? if not, is there any way to achieve this using any existing theory in Z3 solver with an example ?
Thank you for your help in advance!
I got information about Fixed Point theory for numbers from Z3 forum.
Please find below link for information
An SMT Theory of Fixed-Point Arithmetic
which provides an API via PySMT for dealing with fixed point numbers:
SOAR Lab - PySMT - Fixed Points
You can always "request" such a feature at https://github.com/Z3Prover/z3/issues
But SMT solvers in general follow the SMTLib initiative; so unless SMTLib comes up with a "logic" for fixed-point numbers, it's unlikely to be implemented. See here: http://smtlib.cs.uiowa.edu/
There's a discussion forum for SMTLib where you can post your request and ask for guidance: https://groups.google.com/forum/#!forum/smt-lib
Within the current capabilities, however, these kinds of numbers are not supported out of the box. Given that, I'd go with trying to model this "outside" the SMT solver and use the regular integer libraries, but the details of that depend on how much you want to invest and what sorts of problems you want to deal with. (For instance, you can represent fixed-point numbers with two integers, one for the "whole" part and one for the "fraction" part, and do all the arithmetic and rounding-etc. yourself. This can be a lot of work, but probably is your best bet given there's no direct support for these numbers currently.)

Possible Heuristic Function for Word Ladder

Hey I'm thinking of using A* to find and optimal solution for the Word Ladder problem but I'm having a bit of difficulty thinking of an appropriate g(x) and h(x). For this particular problem, could g(x) be the number of hops from the start vertex and h(x) be the number of different characters from the goal word? I'm advice would be a big help.
I never really was a fan of the A* notation of f(x) = g(x) + h(x) notation because it oversimplifies the algorithm. A* is based on two heuristics; often labelled g(x) + h(x).
You already have most of it figured out; for Djikstra's/g(x), you want to return the amount of hops taken. For Greedy/h(x), you want to check how many characters are wrong; you are at the goal when h(x) = 0.
By combining these two values, you have the A* heuristic, which essentially says to expand the best nodes along the shortest path. In other projects, you may wish to add heuristics to A* to get behaviours like avoiding enemies (this is why I prefer not to think A* = g+h).
EDIT: Don't forget to check each candidate using a dictionary file; word ladder requires that intermediate words be real words.

Is the `IntegralDomain` in `numeric-prelude` really an Integral domain?

I am trying to model linear feedback shift registers in haskell. These can be modeled by polynomials over finite fields, so I am using numeric-prelude to get type classes that resemble mathematical algebraic structures more closely than those in the normal prelude.
I am by no means an expert in abstract algebra, so I have become a little confused about the IntegralDomain type class. The problem is that my book on abstract algebra (A book of abstract algebra by Charles C. Pinter) and the type classes seem to be conflicting with each other.
According to the book, the ring of polynomials over an integral domain, is itself an integral domain. Also, a ring of polynomials over a field is only an integral domain, but with the special(the fact that it is special is mentioned) property that the division algorithm holds.
That is, if F[x] is a polynomial over a field, then for a in F[x] and b!=0 in F[x], there exists q,r in F[x] such that b*q+r=a, and the degree of r is less than that of b.
The fact that this property is special to polynomials over a field, to me implies that it does not hold over any integral domain.
On the other hand, according to the type classes of numeric prelude, a polynomial over a field (that is zeroTestable) is also an IntegraldDomain. But according to the documentation, there are several laws of integralDomains, one of the being:
(a `div` b) * b + (a `mod` b) === a
http://hackage.haskell.org/packages/archive/numeric-prelude/0.4.0.1/doc/html/Algebra-IntegralDomain.html#t:C
This to me looks like the division algorithm, but then the division algorithm is true in any integral domain, including a polynomial over an integral domain contradiction my book. It is also worth noting that a polynomail over an integral domain does not have an instance for IntegralDomain in numeric-prelude(not that I can see at least, the fact that every type class is simply called C, make the documentation a little hard to read). So maybe the IntegralDomain in numeric prelude is an integral domain with the extra property that the division algorithm holds?
So is the IntegralDomain in numeric-prelude really an integral domain?
rubber duck debugging post script: While writing this question I got an idea for part of a possible explanation. Is it the requirement that "the degree of r is less than that of b." which makes the whole difference? That requirement is not in the numeric-prelude IntegralDomain. Then again, some of the other laws might imply this fact...
According to the book, a polynomial over an integral domain, is itself an integral domain.
That's not correctly phrased. The ring of polynomials over an integral domain is again an integral domain.
The ring of polynomials in one indeterminate over a field is even a principal ideal domain, as witnessed by the division algorithm, since every polynomial of degree 0 is a unit then.
In a general integral domain R, you have nonzero non-units, and if a is one, then you cannot write
X = q*a + r
with the degree of r smaller than that of a (which is 0).
Is it the requirement that "the degree of r is less than that of b." which makes the whole difference?
Precisely. That requirement guarantees that the division algorithm terminates. In a general integral domain, you can have a "canonical" choice of remainders modulo any fixed ring element, but the canonical remainder need not be "smaller" in any meaningful way, so an attempt to use the division algorithm need not terminate.
Then again, some of the other laws might imply this fact
None of the laws in Algebra.IntegralDomain imply that.
The law
(a+k*b) `mod` b === a `mod` b
is, I believe, hard to implement for a completely general integral domain, which could somewhat restrict the actual instances, but for something like Z[X] or R[X,Y] which are not PIDs, an instance is possible.

Reflection? How do I do it?

This is over my head, can someone explain it to me better? http://mathworld.wolfram.com/Reflection.html
I'm making a 2d breakout fighting game, so I need the ball to be able to reflect when it hits a wall, paddle, or enemy (or a enemy hits it).
all their formula's are like: x_1^'-x_0=v-2(v·n^^)n^^.
And I can't fallow that. (What does ' mean or x_0? or ^^?)
The formula for reflection is easier to understand if you think to the geometric meaning of the operation of "dot product".
The dot product between two 3d vectors is mathematically defined as
<a, b> = ax*bx + ay*by + az*bz
but it has a nice geometric interpretation
The dot product between a and b is the length
of the projection of a over b taken with
a negative sign if the two vectors are pointing in
opposite directions, multiplied by the length of b.
Something that is immediately obvious using this definition and that it's not evident if you only look at the formula is for example that the dot product of two vectors doesn't change if the coordinate system is rotated, that the dot product of two perpendicular vectors is 0 (the length of the projection is clearly zero in this case) or that the dot product of a vector by itself is the square of its length.
Something that is instead less obvious using the geometric interpretation is that the dot product is commutative, i.e. that <a, b> = <b, a> (fact that is clear considering the formula).
An important point to consider is also that if the length of b is 1 then the dot product <a, b> is simply the length of the projection of a over b (taken with the proper sign).
Given this interpretation the formula for computing the reflection over a plane is quite easy to understand:
To compute the reflected vector r, given a vector a and a plane with normal n you just need to use the formula:
r = a - 2<a, n> n
the height h in the figure is in this case just <a, n> (note that n is assumed to be of unit length) and so it should be clear that you need to move twice that height in the direction of the normal.
If you consider the proper dot product signs you should see that the formula applies also when the incident vector a and the plane normal n are facing in the same direction.
The prime (') indicates the second form of a number/point/structure. In this case, x₁' refers to the reflected form of x₁.
The subscript (0) shows various states of the same. In this case, x₀ is the point of reflection.
The caret notation (^) shows that something is a vector. In this case, n̂ is the normal vector.
Is this just about the equation formatting? Because I see nicely formatted equations, not the LaTeX-style markup appearing in your question. So step 1: try viewing the page in a different web browser and see if it looks clearer.
More substantively, I'd recommend a different kind of resource. Fundamentally, you're looking at collisions, which are normally better treated in a physics text than a math text. Any introductory physics textbook will have a chapter on collisions, which should be directly applicable to your game.

Resources