(Then similarly for the y and z variables)
Main Topics
Browse All TopicsIs there a general way to get a single equation for a recursive formula?
For instance, the equation X = 2x - 1 can be written as X = (2^N)x - (2^N-1)-1 to get a single equation. Is a general way to solve possible? I solved the above based on expansion, but would like a general way to solve.
Also, for the following loop system is a general solution possible?
x = y + z
z = y + x
y = 2 * x
The items can be written as follows to get them dependant on previous iteration only:
x = y + z
y = 2y + z
z = 2y + 2z
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
>InteractiveMind, just for completness can you post the solution for x, y, and z?
y is found using the same method as x:
x_(n+3) - 3x_(n+1) - 2x_n = 0
y_(n+3) - 3y_(n+1) - 2y_n = 0
Finding z by rearrangement seems quite tedious though, but there's a slight trick: recall that z_(n+1)=x_n+y_n. So if we add the above two equations, we get:
[x_(n+3)+y_(n+3)] - 3[x_(n+1)+y_(n+1)] - 2[x_n+y_n] = 0
which is
z_(n+4) - 3z_(n+2) - 2z_(n+1) = 0
or
z_(n+3) - 3z_(n+1) - 2z_n = 0.
In other words, all three variables have the same solution. Which, as aburr correctly points out, has the solution x_n=y_n=z_n=2^n.
BTW, your code is not quite right.
Something is not right.
First off, my answer of X = (2^N)x - (2^N-1)-1 is correct.
My code is correct and that is what I am trying to find.
Maybe there is a misunderstanding.
The initial system is a loop and so should be "executed" top to bottom then again.
It can be rewritten as follows to get it dependent on previous: (Is this wrong?)
x_n = y_(n-1) + z_(n-1)
z_n = y_(n-1) + x_(n-1)
y_n = 2x_(n-1)
If all three are the same then running the loop would yield the same answers which it doesn't.
My goal is to remove the loop and use a single equation for x, a single for y, and so on for z.
if x = y = z = 1 then I get
1:
x: 2
y: 4
z: 3
2:
x: 7
y: 14
z: 11
3:
x: 25
y: 50
z: 39
4:
x: 89
y: 178
z: 139
5:
x: 317
y: 634
z: 495
6:
x: 1129
y: 2258
z: 1763
7:
x: 4021
y: 8042
z: 6279
8:
x: 14321
y: 28642
z: 22363
9:
x: 51005
y: 102010
z: 79647
10:
x: 181657
y: 363314
z: 283667
This is the exact code to calculate the loop.
Sorry, I had misunderstood you (or rather, made incorrect assumptions). Your code is not the same as,
x_n = y_(n-1) + z_(n-1)
z_n = y_(n-1) + x_(n-1)
y_n = 2x_(n-1),
instead, it is equivalent to:
x_n = y_(n-1) + z_(n-1)
z_n = y_(n-1) + x_n
y_n = 2x_n,
which can be solved in a similar way (below). Let me know if you have any other questions.
===Derivation===
First, rearrange to get a recursive equation for x:
x_(n+2) - 3x_(n+1) - 2x_n = 0
as described in the wiki article, we solve this by trying the ansatz x_n=k^n:
k^(n+2) - 3k^(n+1) - 2k^n = 0
which gives the quadratic
k^2 - 3k - 2 = 0
hence, k=[3 +/- sqrt(17)]/2. So the solution for x_n is:
x_n = A*([3+sqrt(17)]/2)^n + B*([3-sqrt(17)]/2)^n,
where A and B are constants which account for our initial conditions. Before we find A and B though, you must note that for our system we require that y_n=2x_n, and so x_0=y_0=1 is not possible (unless we take n=1 to be the first element in our series, but this makes it a lot trickier to solve A and B below), so let's take x_0=2, y_0=4, z_0=3 (which is your 3-tuple for n=1). Then:
x_0 = 2 = A + B, and
x_1 = y_0 + z_0 = 7 = A*([3+sqrt(17)]/2) + B*([3-sqrt(17)]/2).
Solving simultaneously for A and B we find:
A = 1 + 8/(2*sqrt(17)),
B = 1 - 8/(2*sqrt(17)).
Now that we know x_n, we find y_n and z_n as functions of x_n.
===Final Solution===
So putting it all together:
x_n = {1 + 8/(2*sqrt(17))}*([3+sqrt(1
y_n = 2*x_n, and z_n = 2*x_(n-1) + x_n,
z_n = 2x_(n-1) + x_n.
Important: Remember that the {1+/-8/(2*sqrt(17)} terms need to be changed if you change the initial variables!
===Test===
This solution may look complicated, but it's a fairly typical solution for this type of problem, moreover, it works!
Recall that because I chose x_0 to be your x_1 (and similarly for y_0 as y_1 et cetera), we'd expect x_n from the above equation to give x_(n+1) in the numbers you computed above.
So let's take n=6 (you get x_7=4021):
x_6 = {1 + 8/(2*sqrt(17))}*([3+sqrt(1
as expected. Then y_n and z_n are easily found as per above.
I've attached a Java implementation if it helps (I don't have C# installed on this computer).
Business Accounts
Answer for Membership
by: InteractiveMindPosted on 2009-08-11 at 12:25:19ID: 25072404
First of all, I get a slightly different answer to you for your first example: X=(2^N)x - 2^(N-1).
ki/Recurre nce_relati on#Solving
With regards to a general solution: there are general approaches to recursive equations depending on their properties. Here's a list of solutions: http://en.wikipedia.org/wi
In the case of a system, let's first use the notation:
x_(n+1) = y_n + z_n
z_(n+1) = y_n + x_n
y_(n+1) = 2x_n
Then x_(n+1) = 2x_(n-1) + y_(n-1) + x_(n-1) = 4x_(n-1) + 2x_(n-2), which is equivalent to x_(n+3) = 3x_(n+1)+2x_n, which is a linear homogeneous recurrence relation (c.f. wiki)