Only real roots (basic)
- Subject: Only real roots (basic)
- From: Aleksas Domarkas
- Date: Mon, 9 Dec 2013 19:28:30 +0200
Barton Willis on Sun Dec 8 21:44:24 wrote:
>Maybe you can improve your code to handle:
> (%i3) eq : x^4-39*x^2+x+21$
> (%i4) solver(solve(eq,x));
>(%o4) []
>I think all four zeros are real:
>(%i5) bfallroots(eq);
>(%o5)
[x=7.523062361878836b-1,x=-7.25925930810255b1,x=6.187887129111267b0,x=-6.214267434488896b0]
>Another test is x^3-39*x^2+x+21.
>--Barton
Example. Solve x^4-39*x^2+x+21=0
(%i1) sol:solve(x^4-39*x^2+x+21=0),expand$
(%i2)
tr:((sqrt(25701811)*%i)/2-2209/2)^(1/3)+197/((sqrt(25701811)*%i)/2-2209/2)^(1/3)+26=r;
(%o2)
((sqrt(25701811)*%i)/2-2209/2)^(1/3)+197/((sqrt(25701811)*%i)/2-2209/2)^(1/3)+26=r
Solution:
(%i3) solution:ratsubst(rhs(tr),lhs(tr),sol),expand;
(%o3)
[x=-sqrt(r)/2-sqrt(-r+2/sqrt(r)+78)/2,x=sqrt(-r+2/sqrt(r)+78)/2-sqrt(r)/2,x=sqrt(r)/2-sqrt(-r-2/sqrt(r)+78)/2,x=sqrt(r)/2+sqrt(-r-2/sqrt(r)+78)/2]
where
(%i4) itr:r=rectform(map(polarform,lhs(tr)));
(%o4) r=2*sqrt(197)*cos((%pi-atan(sqrt(25701811)/2209))/3)+26
test:
(%i5) subst(itr,solution)$
(%i6) float(%), numer;
(%o6)
[x=-6.214267434488896,x=-0.72592593081025,x=0.75230623618788,x=6.187887129111267]
(%i7) allroots(x^4-39*x^2+x+21)$ sort(%);
(%o8)
[x=-6.214267434488895,x=-0.72592593081025,x=0.75230623618788,x=6.187887129111267]
Example 2. Solve x^3-39*x^2+x+21=0.
(%i9) load(odes)$
(%i10) solution:solvet(x^3-39*x^2+x+21,x);
(%o10)
[x=(2*sqrt(506)*cos(atan(sqrt(309854)/(1090*3^(3/2)))/3)+13*sqrt(3))/sqrt(3),
x=(2*sqrt(506)*cos((atan(sqrt(309854)/(1090*3^(3/2)))-2*%pi)/3)+13*sqrt(3))/sqrt(3),
x=(2*sqrt(506)*cos((atan(sqrt(309854)/(1090*3^(3/2)))+2*%pi)/3)+13*sqrt(3))/sqrt(3)]
test:
(%i11) float(solution), numer;
(%o11) [x=38.96049825979939,x=0.75418778176442,x=-0.7146860415638]
(%i12) allroots(x^3-39*x^2+x+21);
(%o12) [x=0.75418778176441,x=-0.7146860415638,x=38.96049825979939]
best
Aleksas D