Only real roots (basic)



Ricardo JF on Dec 8 07:26:43 wrote:

>hi friends,

>why this doesn't give only real roots:

>f(x):=x^3-x^2+x+1;
>declare(x,real);
>solve(f(x));

>i just want [x=(sqrt(11)/...)]

>thanks.

(%i1) load(odes);
(%o1) "C:/Users/Aleksas/maxima/odes.mac"

Example 1
(%i2) eq:x^3-x^2+x+1;
(%o2) x^3-x^2+x+1
(%i3) solvet(eq,x)$
(%i4) sublist(%,lambda([e],freeof(%i,e)));
(%o4)
[x=(sqrt(11)/3^(3/2)-17/27)^(1/3)-2/(9*(sqrt(11)/3^(3/2)-17/27)^(1/3))+1/3]

Example 2
(%i5) eq:x^3-4*x^2+x+1;
(%o5) x^3-4*x^2+x+1
(%i6) solvet(eq,x)$
(%i7) sublist(%,lambda([e],freeof(%i,e)));
(%o7)
[x=(2*sqrt(13)*cos(atan(3^(3/2)/5)/3)+4)/3,x=(2*sqrt(13)*cos((atan(3^(3/2)/5)-2*%pi)/3)+4)/3,x=(2*sqrt(13)*cos((atan(3^(3/2)/5)+2*%pi)/3)+4)/3]
(%i8) float(%), numer;
(%o8) [x=3.651093408937175,x=0.72610944503578,x=-0.37720285397296]
(%i9) allroots(eq);
(%o9) [x=-0.37720285397296,x=0.72610944503578,x=3.651093408937175]

function "solvet" see in next Maxima relase

best
Aleksas