How do i solve a cubic function giving the answer in a matrix
Ältere Kommentare anzeigen
Im trying to solve this cubic equation to give me the intersection points at Pr and give me the anser in a matrix format. Doing this only gives me one answer not three
Pr=input('Pr=');
solve(0==((8*0.9)/((8*Z)-1))-(27/(64*(Z^2)))-Pr,Z);
Z=subs(Z,Pr)
2 Kommentare
madhan ravi
am 24 Nov. 2018
what’s Pr?
callum roberts
am 24 Nov. 2018
Bearbeitet: callum roberts
am 24 Nov. 2018
Akzeptierte Antwort
Weitere Antworten (1)
John D'Errico
am 24 Nov. 2018
This is not a cubic polynomial. Fact. A cubic polynomial is of the form:
a + b*x + c*x^2 + d*x^3
What you have is a rational polynomial. Hint: a cubic polynomial does not have any points where the function goes to infinity for a real finite input. What happens in your function?
syms Z Pr
pretty(((8*0.9)/((8*Z)-1))-(27/(64*(Z^2)))-Pr)
36 27
----------- - Pr - -----
(8 Z - 1) 5 2
64 Z
So when Z==1/8 or Z==0, thig function is undefined, with a singularitiy at those locations. Again, is it a cubic pollynomial? No.
Now, as long as you are willing to assume that Z is NEVER going to be exactly 0 or 1/8, you can multiply by Z^2*(8*Z-1), converting the relation into one that is cubic polynomial in nature. It looks like solve does this for you.
Prvals = 1:5;
vpa(subs(solve(36/(5*(8*Z - 1)) - Pr - 27/(64*Z^2),Z),Pr,Prvals),5)
ans =
[ 0.21067, 0.19186, 0.18239, 0.17615, 0.17155]
[ 0.40717 - 0.29075i, 0.19157 - 0.31738i, 0.1213 - 0.28576i, 0.086927 - 0.2594i, 0.066727 - 0.23881i]
[ 0.40717 + 0.29075i, 0.19157 + 0.31738i, 0.1213 + 0.28576i, 0.086927 + 0.2594i, 0.066727 + 0.23881i]
And since you can the do a subs into the result for a set of values for Pr, that works. Be careful though, because for any value of Pr that would have yielded a solution of 1/8 for Z, that solution is actually spurious.
Kategorien
Mehr zu Number Theory finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!