Using maxima for high school mathematics



Hi Daniel,

Le 03/04/2011 07:51, Daniel Dalton a ?crit :
> 4) Finally, I'm having trouble solving some more complicated equations
> with maxima. According to my text book there is real solutions. How can
> I find the real solution for the below equation? Input/output is
> below. (Note, I'm not familiar with complex numbers.)
>
> (%i2) float(solve(x^3-17*x^2-56*x+1153=0));
>    
solve looks for exact solutions of the equation. In case of polynomial 
of degree three, the solutions may be expressed by radicals, but in some 
cases we cannot avoid complex radical even to express real roots. 
Unfortunately, float keeps these "ghost" complex numbers as in your example.

When dealing with polynomials, you can use the functions allroots or 
realroots. The first one gives you a floating point approximation of the 
roots, the second one a rational approximation (you can then use float).

(%i41) p:x^3-17*x^2-56*x+1153;
(%o41) x^3-17*x^2-56*x+1153
(%i42) allroots(p);
(%o42) [x = 9.008409308902849,x = -8.002450376978056,x = 15.99404106807521]
(%i43) float(realroots(p));
(%o43) [x = -8.002450376749039,x = 9.008409291505814,x = 15.9940410554409]

Since the values do not agree with good precision, you can use find_root 
to compute the value of a root in an interval  if the function takes 
values of opposite signs at the endpoints :

(%i46) find_root(p,8,10);
(%o46) 9.008409308902849

This function find_root is not restricted to polynomial equations. In 
the same way, the function newton computes the root from a starting 
approximation ; it is fast and precise if you start from a sufficiently 
good approximation, but not guaranteed to converge in general. You can 
use bigfloats to get better approximation. Load the package newton first :

(%i47) load(newton)$
(%i48) fpprec:50;
(%o48) 50
(%i49) newton(p,9);
(%o49) 9.0084093089028481369232506708486782757538026517567b0


Last comment : in the case of polynomials of degree 3, you can usually 
replace complex radicals by trig functions, using the functions rectform 
and trigsimp. Then float looks ok :

(%i53) float(trigsimp(rectform(solve(p))));
(%o53) [x = 9.00840930890285,x = -8.002450376978054,x = 15.9940410680752]

Eric