wrong solutions in system of nonlinear equations with "vpasolve"

6 views (last 30 days)
Hello, I am a beginner of Matlab.
I tried to solve a system of nonlinear equations (8 equation and 6 variables) with vpasolve as shown below.
The solutions do not satisfy 4 out of 8 equations. (Wrong solutions and equations that are not satisfied with the solutions are with bold letters.)
How can I fix the problem?
*Code I used
//
>> syms A B C D E x
eq1=B+C+7.5-100
eq2=A+C+E+7.5-135
eq3=D+E+7.5-15
eq4=0.7*C + x*E - A*(B+D)
eq5=0.7*(C+7.5)-B*(A+E)
eq6=0.7*C-x*7.5-(A*B-C*D)
eq7=x*(E+7.5)-D*(A+C)
eq8=x*E-0.7*7.5-(A*D-B*E)
eqs=[eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8]
[A, B, C, D, E, x]=vpasolve(eqs, [A,B,C, D, E, x])
//
*Response I got
//
eq1 = B + C - 185/2
eq2 = A + C + E - 255/2
eq3 = D + E - 15/2
eq4 = (7*C)/10 + E*x - A*(B + D)
eq5 = (7*C)/10 - B*(A + E) + 21/4
eq6 = (7*C)/10 - (15*x)/2 - A*B + C*D
eq7 = x*(E + 15/2) - D*(A + C)
eq8 = E*x - A*D + B*E - 21/4
eqs = [ B + C - 185/2, A + C + E - 255/2, D + E - 15/2, (7*C)/10 + E*x - A*(B + D), (7*C)/10 - B*(A + E) + 21/4, (7*C)/10 - (15*x)/2 - A*B + C*D, x*(E + 15/2) - D*(A + C), E*x - A*D + B*E - 21/4]
A =
34.046247300863523845963342329846
29.073162677776520552338619357279
-2.4237473008635238459633423298465
-6.8461164144313248228012528092361
B =
1.8635105955281338875279376538881
1.8635105955281338875279376538881
-37.563510595528133887527937653888
-37.563510595528133887527937653888
C =
90.636489404471866112472062346112
90.636489404471866112472062346112
130.06351059552813388752793765389
130.06351059552813388752793765389
D =
4.6827367053353899584354046759584
-0.29034791775161333518931829660926
7.6397632946646100415645953240416
3.217394181096809064726684844652
E =
2.8172632946646100415645953240416
7.7903479177516133351893182966093
-0.13976329466461004156459532404161
4.282605818903190935273315155348
x =
56.590242103608342266508720016265
-2.2731626777765205523386193572788
132.48725789639165773349127998373
33.646116414431324822801252809236
//

Answers (1)

Nagasai Bharat
Nagasai Bharat on 20 Oct 2020
Hi,
There is an syntax error in how the "vpasolve" function is being solved. Do look in the below snippet for correct syntax.
Refer vpasolve mathwork documentaton for more detail.
syms A B C D E x
eq1=B+C+7.5-100;
eq2=A+C+E+7.5-135;
eq3=D+E+7.5-15;
eq4=0.7*C + x*E - A*(B+D);
eq5=0.7*(C+7.5)-B*(A+E);
eq6=0.7*C-x*7.5-(A*B-C*D);
eq7=x*(E+7.5)-D*(A+C);
eq8=x*E-0.7*7.5-(A*D-B*E);
[A, B, C, D, E, x]= vpasolve(eq1 == 0, eq2 == 0, eq3 == 0, eq4== 0, eq5== 0, eq6== 0, eq7== 0, eq8== 0, [A,B,C, D, E, x])
  1 Comment
Naohiro Kato
Naohiro Kato on 22 Oct 2020
Deaar Nagasai,
Thak you very much for youre answer.
There seem to be several different syntax to run vpaaslove. I found the syntax you described would give exact same solutions as the syntax I used.
On the other hand, I now noticed that all answers of the equations are 0 or nearly 0 (<+1.2 E-12) when I plug the solutions back into the equations. I simply upset when I saw the solutions are non zero, assuming vpasolve would always give the perect solution of 0.
Thak you again for your help anyway. I keep learnng Matlab.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!