Showing posts with label CAS. Show all posts
Showing posts with label CAS. Show all posts

Sunday, March 9, 2008

CAS: Roots of a polynomial

Maxima
---------------------------
(%i1) eq1: x^5-x+x*(1-x)^4*(5*a)+x^2*(1-x)^3*(10*b)+
x^3*(1-x)^2*10*(1-b)+x^4*(1-x)*5*(1-a)=0;
(%o1)

(%i2) solve(eq1,x);
(%o2)

(%i3) f1:rhs(%[1] );
(%o3)

(%i4) radcan(f1);
(%o4)

(%i5) ratexpand(%);
(%o5)

(%i6) d1:part(%,1);
(%o6)

(%i7) d2:part(%o5,[2,3,4]);
(%o7)

(%i8) ratsimp(%);
(%o8)

Roots in simplified format is given by

x = 0.5 +/- sqrt((b+1.5a-0.7)/(4b-2a-1.2))


Matlab
-----------------
syms a b x
f = x^5-x+x*(1-x)^4*(5*a)+x^2*(1-x)^3*(10*b)+
x^3*(1-x)^2*10*(1-b)+x^4*(1-x)*5*(1-a);
soln = solve(f,x);
f4 = soln(4,1);
f5 = soln(5,1);

f4 =
1/2/(5*a-10*b+3)*(5*a-10*b+3+(-75*a^2+
100*a*b-10*a+100*b^2-100*b+21)^(1/2))

f5 =
1/2/(5*a-10*b+3)*(5*a-10*b+3-(-75*a^2+
100*a*b-10*a+100*b^2-100*b+21)^(1/2))

It does not simplify roots any further. I tried all sorts of other commands like 'simplify', 'factor' etc. Is it possible to get the simplified form of roots as shown above?


Now scilab comes with its own symbolic toolbox and interface with 'maxima'. Check following link for details.
http://www.cert.fr/dcsd/idco/perso/Magni/s_sym/functions.html
 
pre { margin: 5px 20px; border: 1px dashed #666; padding: 5px; background: #f8f8f8; white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ }