EndIf
Else
augment(o,{l[i]})→o
EndIf
EndFor
If f=0 Then
o
Else
o|s
EndIf
EndFunc
cubic() is used to solve cubic (third-order) equations, and quartic() solves 4th-order equations. coef()
and evalrt() are used by cubic() and quartic() to find the solutions. evalrt() can also be used on the
results from cubic() and quartic(), as described below, to expand the solutions.
All of these routines must be in the same folder, called p. The mode must be set to Auto, and not to
Exact or Approx. Set Complex format to Rectangular or Polar. To help prevent "Memory" errors, these
routines should be the only variables in the folder, and there should be no other variables in the folder.
These routines can take a long time to return the result.
The input to both cubic() and quartic() is a polynomial in x or z. The output is a list of the solutions.
For example,
cubic(x
3
-12x
2
-15x+26,x) returns {-2 1 13}
quartic(z
4
-2z
3
-13z
2
+38z-24,z) returns {-4 1 2 3}
The advantage of using cubic() and quartic() is that they return exact answers, which czeros() or
csolve() don't always do. For example,
czeros(x
3
-x+1,x)
returns
{-1.32472 0.662359 - .56228i 0.662359+.56228i}
while
cubic(x
3
-x+1,x)
returns a list with these solution elements:
✍
−✍
2
+
✎$ 3
2
$ i
−✍
2
−
✎$ 3
2
$ i
6 - 12