HP Forums

Full Version: The solution to the quartic equation on the HP50g, revisited
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

The last time I posted about this topic, I had a program that had the HP50g itself go through the steps to solve the equation from first principles. This took about 3 minutes (for the most general case), and the final result couldn't be displayed in pretty print.

This solution is basically just plugging into an already simplified solution. It "solves" the general case in about 10 seconds, and the result can be displayed in pretty print.

%%HP: T(3)A(R)F(.);
\<< 0 0 0 0 \-> A B C D E ALPHA BETA GAMM DELTA
\<< C 2 ^ 3 B D * * - 12 A E * * + 'ALPHA' STO 2 C 3 ^ * 9 B C D * * * - 27 A D 2 ^ * * + 27 B 2 ^ E * * + 72 A C E * * * - 'BETA' STO BETA 'SQUAREROOT' \v/ 'SQUAREROOT' -4 ALPHA 3 ^ * BETA 2 ^ + = SUBST + 'GAMM' STO 'SQUAREROOT' \v/ 'SQUAREROOT' B 2 ^ 4 A 2 ^ * / 2 C * 3 A * / - ALPHA 3 A GAMM 2 / 3 INV ^ * * / 1 3 A * / GAMM 2 / 3 INV ^ * + + = SUBST 'DELTA' STO B NEG 4 A * / 2 INV DELTA * - 2 INV NEG 'SQUAREROOT' \v/ 'SQUAREROOT' B 2 ^ 2 A 2 ^ * / 4 C * 3 A * / - ALPHA 3 A * GAMM 2 / 3 INV ^ * / - 3 A * INV GAMM 2 / 3 INV ^ * - B 3 ^ A 3 ^ / 4 B C * * A 2 ^ / - 8 D * A / + 4 DELTA * / + = SUBST * +
\>>
\>>


The solution is:

%%HP: T(3)A(R)F(.);
'((-(B/(4*A)))-((1/2)*(\v/((((B^2)/(4*(A^2)))-((2*C)/(3*A)))+(((((C^2)-(3*(B*D)))+(12*(A*E)))/(3*(A*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2))))+((1/(3*A))*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2)))))))-((1/2)*(\v/((((((B^2)/(2*(A^2)))-((4*C)/(3*A)))-((((C^2)-(3*(B*D)))+(12*(A*E)))/((3*A)*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2))))-((1/(3*A))*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2)))+(((((B^3)/(A^3))-((4*(B*C))/(A^2)))+((8*D)/A))/(4*(\v/((((B^2)/(4*(A^2)))-((2*C)/(3*A)))+(((((C^2)-(3*(B*D)))+(12*(A*E)))/(3*(A*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2))))+((1/(3*A))*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2))))))))))'


I've tested it with numerical inputs, and confirmed it works.

Caveats from the previous thread still apply. If you want a numerical result, you should be in approx. mode before running the program, or the calculator might not be able to evaluate the result to a number.