Solve returns term with z. How do I get a "real Result"?
26 views (last 30 days)
Show older comments
I am trying to solve this equation system:
1/(1/r1+1/(r2+r3+r4)) = 2.1835
1/(1/r2+1/(r1+r3+r4)) = 2.1486
1/(1/r3+1/(r2+r1+r4)) = 2.1728
1/(1/r4+1/(r2+r3+r1)) = 2.2111
By using this code:
rg1=2.1835; rg2=2.1486; rg3=2.1728; rg4=2.2111;
syms r1 r2 r3 r4
eqns = [1/(1/r1+1/(r2+r3+r4)) == rg1, 1/(1/r2+1/(r1+r3+r4)) == rg2, 1/(1/r3+1/(r2+r1+r4)) == rg3, 1/(1/r4+1/(r2+r3+r1)) == rg4,];
S = solve(eqns, [r1 r2 r3 r4])
S.r1
S.r2
S.r3
S.r4
as result I g
et long terms with z^4...z What does this z mean and how can I get a "normal" result.
1 Comment
Alex Sha
on 23 Jun 2021
Is this the result you want?
r1: 2.91423055143557
r2: 2.84504784935676
r3: 2.8928454682783
r4: 2.97013510208625
Answers (4)
John D'Errico
on 15 May 2017
Edited: John D'Errico
on 15 May 2017
What does z mean?
S.r1
ans =
(62010831954402342000*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 1)^2)/308426107223360551 - (20616870056580000000*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 1)^3)/308426107223360551 - (10014473705252990336*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 1))/1542130536116802755 + 625923396639739/75445592095850000
(62010831954402342000*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 2)^2)/308426107223360551 - (20616870056580000000*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 2)^3)/308426107223360551 - (10014473705252990336*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 2))/1542130536116802755 + 625923396639739/75445592095850000
(62010831954402342000*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 3)^2)/308426107223360551 - (20616870056580000000*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 3)^3)/308426107223360551 - (10014473705252990336*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 3))/1542130536116802755 + 625923396639739/75445592095850000
(62010831954402342000*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 4)^2)/308426107223360551 - (20616870056580000000*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 4)^3)/308426107223360551 - (10014473705252990336*root(z^4 - (390850577*z^3)/128814000 + (51365067669*z^2)/268362500000 - (200586512576659*z)/64407000000000000 + 2905698570276161/644070000000000000000, z, 4))/1542130536116802755 + 625923396639739/75445592095850000
The solution to the problem has 4 solutions, roots of a 4th order polynomial equation, here in the variable z. MATLAB can solve for those roots numerically. You can force that using vpa.
vpa(S.r1)
ans =
- 0.0015935250661017208803081452445934 - 3.0552265138951126699710247931366e-38i
- 0.026074229751533563071359537716262 - 2.0296573594996764410679746085014e-38i
0.036326236876354958070888222876152 - 9.8336984726618252280864395970791e-40i
2.9142305514355702009478446858071 - 3.4116252883482229527622188810207e-38i
0 Comments
DHARUN M
on 15 May 2020
x+y-z=10,23x+4y+z=3,4x-56y+2=100
1 Comment
John D'Errico
on 16 May 2020
Edited: John D'Errico
on 16 May 2020
Please don't post your homework assignment as an answer to a totally different question. Don't post your homework assignment anyway, as we are not here to do your homework for you.
Walter Roberson
on 16 May 2020
S = solve(eqns, [r1 r2 r3 r4], 'MaxDegree', 4);
These solutions should not have z in them. However they will be quite long, and it is very unlikely that you will be able to make sense of them.
1 Comment
Walter Roberson
on 23 Jun 2021
Exact solutions are long complex formulae.
Decimal approximation includes negligable imaginary parts because the exact formulas inherently involve balancing complex-valued portions, and a minor round-off error can result in a complex coefficient being left-over.
Q = @(v) sym(v);
rg1 = Q(21835)/10000; rg2 = Q(21486)/10000; rg3 = Q(21728)/10000; rg4 = Q(22111)/10000;
syms r1 r2 r3 r4
eqns = [1/(1/r1+1/(r2+r3+r4)) == rg1, 1/(1/r2+1/(r1+r3+r4)) == rg2, 1/(1/r3+1/(r2+r1+r4)) == rg3, 1/(1/r4+1/(r2+r3+r1)) == rg4,];
S = solve(eqns, [r1 r2 r3 r4], 'MaxDegree', 4)
S.r1, real(vpa(S.r1)), vpa(S.r1)
S.r2, real(vpa(S.r2))
S.r3, real(vpa(S.r3))
S.r4, real(vpa(S.r4))
Delfin Estebes
on 17 Jun 2021
Try S = Vpasolve(eqns, [r1 r2 r3 r4]), maybe you could find a numerically solution.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







