Two-level Recurrence in Matlab
Show older comments
Hi All,
I want to solve a (system of) recurrence equation in Matlab's symbolic toolbox. Formally, I would like to have a formula for the value of a(n) if a(n) is defines, as follows:
a(n+1) = 0.5*b(n)+0.5*a(n)
b(n+1) = 0.2 + 0.8*b(n)
For one-level recurrence the task is easy and the solution by Matlab is
eq1 := rec(b(n+1) = 0.2 + 0.8*b(n),b(n),b(0)=b0)
rec(b(n + 1) - 0.8*b(n) - 0.2, b(n), {b(0) = b0})
solve(eq1)
{0.8^n*(1.0*b0 - 1.0) + 1.0}
That is, Matlab determined the close for solution for b(n). Do you have an idea how I can achieve the same for a(n)?
eq2 := rec(a(n+1) = 0.5*b(n) + 0.5*a(n),a(n),a(0)=a0)
rec(a(n + 1) - 0.5*a(n) - 0.5*b(n), a(n), {a(0) = a0})
But solving the system of equations
solve({eq1,eq2})
gives an error of Error: Recursive definition: the maximal depth for nested procedure calls is reached. Evaluating: numeric::rationalize@rec_rat
despite a closed form solution exists.
Any help is appreciated very much.
Thanks! Gerzson
Answers (1)
Torsten
on 7 Jun 2018
Edited: Walter Roberson
on 7 Jun 2018
0 votes
You could try to insert the solution expression for b(n) in the calculation for a(n).
Another way:
Or this approach:
Best wishes
Torsten.
Categories
Find more on Utilities for the Solver 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!