Iterating substitution question (Matlab)

38 Views Asked by At

I have four relations between A and B as below.

A(i)= B(i) + B(i-1)

B(i)= A(i) + A(i-2)

A(i)= B(i-1) + A(i-2)

B(i)= B(i-1) + A(i-2)

Assume i is 7 and A(7),A(0),B(7),B(0) are known. (Just for easier calculation here, so that my iteration will be from 7 to 0) And I will need to determine A(4),B(4). I will need to solve this in Matlab as I will need to change i to a much bigger number.

Now what I got is as below.

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)

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.

Thank you so much.

1

There are 1 best solutions below

2
On

A(i)= B(i) + B(i-1)

B(i)= A(i) + A(i-2)

A(i)= B(i-1) + A(i-2)

B(i)= B(i-1) + A(i-2)

From your first and third equations, $B(i)=A(i-2)$. Then from your second equation, $A(i)=0$.