I am trying to solve a cubic equation with unknown coefficients (
t), here is the code:
Rgas = 8.314; (* gas constant *) acoef[tc_, pc_] := (27*Rgas^2*tc^2)/(64*pc); bcoef[tc_, pc_] := (Rgas*tc)/(8*pc); latentK = 76.9*10^3*39*1.67*10^-27*6.022*10^23; tcK = 2223; (* Kelvin *) pcK = 16*10^6; (*Pa *) roots = v /. NSolve[(p - Rgas*t)*v^3 - bcoef[tcK, pcK]*p*v^2 + acoef[tcK, pcK]*v - acoef[tcK, pcK]*bcoef[tcK, pcK] == 0, v] // Chop; test = roots[] (p - Rgas*t)*test^3 - bcoef[tcK, pcK]*p*test^2 + acoef[tcK, pcK]*test - acoef[tcK, pcK]*bcoef[tcK, pcK] // Chop
1) I had to use
NSolve because otherwise it said it did not have exact expressions. I tried to play around with
Rationalize, in vain. Is there any chance of finding an exact solution (i.e. using
Solve) even if the coefficients (p and t) are not known?
2) In the last lines, I am plugging one of the roots (they are all the same) back into the equation, to see if it yields $0$. And it doesn't. Why? What am I doing wrong?