vpasolve and independent equations

7 views (last 30 days)
How does the vpasolve command work and what is the difference between vpasolve and solve ?
I read on a discussion the vpasolve can solve many independent equations without using a loop over single equations. Then I tried and got the following.
>> syms x y z u;
1>> sol = vpasolve([2*x+3, exp(y)-20,log(z+5)+60],[x,y,z]);[sol.x sol.y sol.z] % correct answer
ans =
[ -1.5, 2.9957322735539909934352235761425, -4.9999999999999999999999999912435]
2>> sol = vpasolve([2*x+3, exp(y)-20,log(z+5)+60,1/u+10],[x,y,z,u]);[sol.x sol.y sol.z sol.u] % ??
ans =
[ -1.5, 72.364158219472484524557308589775, - 2.3427240402068111246084751973687e55 - 3.8942786692210248849674644994505e53i, 2.1973620198615687196267013300432e220164446]
3>> sol = vpasolve([2*x+3, exp(y)-20,1/u+10],[x,y,u]);[sol.x sol.y sol.u] % ??
ans =
[ -1.5, 72.395408219472484524557308589775, 7.6288584990871366247428709032065e187034710]
4>> sol = vpasolve([2*x+3,1/u+10],[x,u]);[sol.x sol.u] % correct answer
ans =
[ -1.5, -0.1]
Commands 1 and 4 gave the correct answer that I expected. But I don't understand the results of 2 and 3. 2 is the 1 to which I added one simple equation 1/u+10 ==0. Not only the result of that equation is not correct (in the sens -1/10 that I expect) but also the results of the former equations are affected. I cannot uderstand complex number as result for log(z+5)+60==0. Same thing in 3. then in 4 I supress some equations and I get expected results again. Does anyone understand what is actually done ?
And in the case, how can I solve for many independent equations (like the same equations but with different parameters: e.g. a1*x+b1==0, a2*x+b2==0, ..., an*x+bn ==0) without using a loop over the single equations ?

Sign in to comment.

Accepted Answer

Roshni Garnayak
Roshni Garnayak on 21 Aug 2019
vpasolve’ solves algebraic equations using numerical methods whereas ‘solve’ solves the equations symbolically. If possible, solve equations symbolically using solve, and then approximate the obtained symbolic results numerically using vpa’.
You can solve multiple independent equations by using the following piece of code:
syms x y z u;
eqns = [2*x+3==0, exp(y)-20==0,log(z+5)+60==0,1/u+10==0];
vars = [x,y,z,u];
For further details on ‘solve and ‘vpa’ functions refer the following links:
Walter Roberson
Walter Roberson on 21 Aug 2019
Quasi Newton approaches can effectively end up estimating the response between variables as being locally linear scales of each other. When that is not true, such as when one variable has exponential response and the others are linear, then QN can end up projecting positions far enough out that one of the variables completely dominates to within working precision, and where subtraction of goal point can give 0 to within working precision even though the location is just massively wrong. QN then finds a false solution due to loss of precision.
When you have exponential growth in your formulas then it is advisable to use bounds constraints.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!