Substitution in Matlab (Iteration Process)

2 views (last 30 days)
Hi, I am facing some problem in iterating my equations. Basically, here how it should work.
A(i)= x1*B(i) + x2*B(i-1)
B(i)= x3*A(i) + x4*A(i-2)
A(i)= x5*B(i-1) + x6*A(i-2)
B(i)= x7*B(i-1) + x8*A(i-2)
where x1,x2,x3,x4,x5,x6,x7,and x8 are all known constansts. Assume i is 7 and A(7),A(0),B(7),B(0) are known, and A(3) and B(3) need to be determined.
Starting from
A(7) = B(6) + A(5)
=B(5)+A(4) + B(4)+A(3) (using equation 3 and 4)
=B(4)+A(3) + B(3)+A(2) + B(3)+A(2) + B(2)+A(1) (using equation 3 and 4)
=B(3)+A(2) + B(2)+A(1) + B(2)+A(1) + B(1)+A(0) + B(2)+A(1) + B(1)+A(0)
+ B(1)+A(0) + B(1)+B(0) (using equation 1,3,4. When it comes to A(1),
we have to switch to equation 1 to prevent A(-1))
=B(2)+A(1) + B(1)+A(0) + B(1)+A(0) + B(1)+B(0) + B(1)+A(0) + B(1)+B(0)
+ B(1) + A(0) + B(1)+A(0) + B(1)+B(0) + B(1) + A(0) + B(1) + A(0) +B(1)
+ B(0)
= 12B(1)+7A(0)+5B(0)
Using the same way,
A(6)=8B(1)+4A(0)+3B(0)
A(5)=3B(1)+3A(0)+2B(0)
A(4)=3B(1)+2A(0)+B(0)
A(3)=2B(1)+A(0)+B(0)
A(2)=B(1)+A(0)
(The known constants coefficients are ignored at here for simplicity but it does exist.)
Originally my idea was trying to iterate in the way that when i of A(i) or B(i) is bigger than 1, then it will substitute in equation 3 and 4. While i is equal to 1, then it will substitute in equation 1 and 2. This process will keep iterating until the equation is left with one unknown. But I could not implement this in Matlab as I have no idea how to use loop for the substitution n this case.

Accepted Answer

Roger Stafford
Roger Stafford on 15 Jul 2014
Since your four equations are to be iterative, we can also write a shifted version of the second equation which we can consider as a fifth equation:
B(i-1) = x3*A(i-1) + x4*A(i-3)
The second and fifth equations can then be used to substitute for B(i) and B(i-1) in the first, third, and fourth equations to obtain iterative expressions entirely in terms of A:
A(i) = x1*(x3*A(i)+x4*A(i-2))+x2*(x3*A(i-1)+x4*A(i-3))
A(i) = x5*(x3*A(i-1)+x4*A(i-3))+x6*A(i-2)
(x3*A(i)+x4*A(i-2)) = x7*(x3*A(i-1)+x4*A(i-3))+x8*A(i-2)
These can be rewritten as:
(1-x1*x3)*A(i) -x2*x3*A(i-1) -x1*x4*A(i-2) = x2*x4*A(i-3)
1*A(i) -x5*x3*A(i-1) -x6*A(i-2) = x5*x4*A(i-3)
x3*A(i) -x7*x3*A(i-1) +(x4-x8)*A(i-2) = x7*x4*A(i-3)
The determinant of the above matrix of coefficients on the left-hand side is
det([1-x1*x3,-x2*x3,-x1*x4;1,-x5*x3,-x6;x3,-x7*x3,x4-x8]) =
x3*(x3*x1*x6*x7+x2*x4+x1*x4*x7+x3*x6*x2-x4*x5-x3*x8*x1*x5+x8*x5-x6*x7-x8*x2)
If this value is non-zero, the solution for A(i), A(i-1), and A(i-2) in terms of A(i-3) is uniquely determined and turns out to be:
A(i) = 0
A(i-1) = -x4/x3*A(i-3)
A(i-2) = 0
Since we are dealing in an iterative relationship we can repeat all the above arguments with i shifted down one and deduce that we also have:
A(i-1) = 0
A(i-2) = -x4/x3*A(i-4)
A(i-3) = 0
In other words, A(i), A(i-1), A(i-2), A(i-3), A(i-4), and on down must all be zero. Thus, with the assumption of the above determinant being non-zero we see that in fact all A and B terms must be identically zero. On the other hand, if the determinant is assumed to be zero, that is our first constraint on the eight parameters.
I don't have the patience to further explore the case with zero determinant, but I have reason to believe that it in turn will lead to at least a further necessary equality imposed on the eight parameters in seeking non-zero values for the A's and B's.
The point of all this long-winded argument is that you cannot arbitrarily assign eight random values to x1, x2, ..., x8 and expect to find a set of non-zero A and B sequences that satisfy your original four equations in an iterative way, that is, so that they hold for all i over a certain range. These parameters must be selected subject to certain conditions.
Another way to look at all this is that you have four equations to satisfy for each value of i but only two unknowns, A(i) and B(i), on the average to satisfy them. There are thus many more equations than unknowns and you have to expect that something special must be done with the eight x parameters to allow a non-trivial solution to exist.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!