A possible bug in solver?
1 view (last 30 days)
Show older comments
Either this is a bug in 'solver' or I'm missing something.
This script should generate two identical figures, however the second part ignores an entire set of solutions.
clear all;
%%System parameters
D = 0.072;
phi = 20;
B = 8;
Beta = 0.3;
static = [];
syms x2 u
for x1=0.1:0.01:0.82
res = solve(0== -x1 + D*(1 - x1)*exp(x2/(1+x2/phi)), 0== -x2 + B*D*(1 - x1)*exp(x2/(1+x2/phi)) + Beta*(u - x2));
static = [static; vpa(res.u)];
end
plot(static,0.1:0.01:0.82)
hold all;
clear all;
%%System parameters
D = 0.072;
phi = 20;
B = 8;
Beta = 0.3;
static = [];
syms x2 x1
for u=-1:0.01:1
res = solve(0== -x1 + D*(1 - x1)*exp(x2/(1+x2/phi)), 0== -x2 + B*D*(1 - x1)*exp(x2/(1+x2/phi)) + Beta*(u - x2));
static = [static; vpa(res.x1)];
end
plot(-1:0.01:1,static)
xlabel('u')
ylabel('x1')
4 Comments
Accepted Answer
Aubrey
on 6 Dec 2012
Would you understand it if the equation was:
x1 + x2^2 = 0
Now x1 and x2 have different effects on the equation, is that better?
If you fix x1 to 1, the solution set is S1 = {x1,x2} = {1,i}.
Now if you fix x2 to i, the solution set is S2 = {x1,x2} = {1,i}.
Actually, if you fix x1 to 1, the solutions are {1,i} and {1,-i}, while if you fix x2 to i, the only solution is {1,i}.
This is exactly the same issue that you are encountering in your plots. Looking at the plot, there are three different solutions for x1 when u=0. Solve finds one of them.
If we had a perfect solver that was guaranteed to find all solutions, then you are correct and we would find the same set of solutions either way. However, numerical solvers cannot guarantee finding all solutions.
3 Comments
Azzi Abdelmalek
on 6 Dec 2012
static = [static; vpa(res.u)]; correspond to first plot
static = [static; vpa(res.x1)] correspond to the second plot
Why the plot of u and x1 are expected to be the same?
More Answers (1)
Azzi Abdelmalek
on 6 Dec 2012
In your above comment, x1 and x2 have the same effect in the equation. In your equations u appears once while x1 appears three times, then they have'nt the same effect, why are you expecting to find the same result?
3 Comments
Azzi Abdelmalek
on 6 Dec 2012
Why do you fix x1 to i? and not 4 or ....
It's not what you did in your program, what you did is
for x1=0.1:0.01:0.82
and
for u=-1:0.01:1
See Also
Categories
Find more on Calculus 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!