Am Sonntag, den 26.04.2009, 18:58 +0400 schrieb Alexey Beshenov:
> At Sun, 26 Apr 2009 16:10:03 +0200,
> Dieter Kaiser wrote:
> > I think that it is always good to handle complex expressions more
> > carefully and complete. A test freeof(%i,x) is a very weak test. The
> > test function $csign can detect complex and imaginary expressions too.
> > If we use it for your example, we get:
> >
> > (%i16) sol : map ('rhs, solve (3*x^3 - 3*x + 1))$
> >
> > (%i17) map(lambda([x],csign(x)),sol);
> > (%o17) [complex,complex,complex]
>
> 3*x^3 - 3*x + 1 has three real roots, but it is irreducible.
>
> (%i1) sol : map ('rhs, solve (3*x^3 - 3*x + 1))$
>
> (%i2) map ('rectform, sol);
> (%o2) [%i*((sqrt(3)*sin((%pi-atan(3*3^-(3/2)))/3)/2
> +3*cos((%pi-atan(3*3^-(3/2)))/3)/2)
> /3
> -sin((%pi-atan(3*3^-(3/2)))/3)/(2*sqrt(3))
> -cos((%pi-atan(3*3^-(3/2)))/3)/2)
> +(3*sin((%pi-atan(3*3^-(3/2)))/3)/2
> -sqrt(3)*cos((%pi-atan(3*3^-(3/2)))/3)/2)
> /3+sin((%pi-atan(3*3^-(3/2)))/3)/2
> -cos((%pi-atan(3*3^-(3/2)))/3)/(2*sqrt(3)),
> %i*((sqrt(3)*sin((%pi-atan(3*3^-(3/2)))/3)/2
> -3*cos((%pi-atan(3*3^-(3/2)))/3)/2)
> /3
> -sin((%pi-atan(3*3^-(3/2)))/3)/(2*sqrt(3))
> +cos((%pi-atan(3*3^-(3/2)))/3)/2)
> -sin((%pi-atan(3*3^-(3/2)))/3)/2
> +(-3*sin((%pi-atan(3*3^-(3/2)))/3)/2
> -sqrt(3)*cos((%pi-atan(3*3^-(3/2)))/3)/2)
> /3-cos((%pi-atan(3*3^-(3/2)))/3)/(2*sqrt(3)),
> 2*3^-(1/2)*cos((%pi-atan(3*3^-(3/2)))/3)]
>
> (%i3) map ('trigsimp, %);
> (%o3) [(sqrt(3)*sin(5*%pi/18)-cos(5*%pi/18))/sqrt(3),
> -(sqrt(3)*sin(5*%pi/18)+cos(5*%pi/18))/sqrt(3),
> 2*cos(5*%pi/18)/sqrt(3)]
>
> imagpart and trigsimp do the trick. Of course it is better to
> implement a more efficient algorithm which tests if a given expression
> is real.
Of course, you are right. Because I have a look at the functions for the
complex components I have observed the following strange results:
(%i83) sol : map ('rhs, solve (3*x^3 - 3*x + 1))$
(%i84) trigsimp(rectform(sol));
(%o84) [(sqrt(3)*sin(5*%pi/18)-cos(5*%pi/18))/sqrt(3),
-(sqrt(3)*sin(5*%pi/18)+cos(5*%pi/18))/sqrt(3),
2*cos(5*%pi/18)/sqrt(3)]
The absolute value of the three real roots is:
(%i85) abs(%),numer;
(%o85) [.3949308436346985,1.137158042603258,.7422271989685593]
But if I do it with the function abs I get the following:
(%i86) abs(sol),numer;
(%o86) [.5773502691896257,.5773502691896257,1.154700538379251]
And again, now with an additional rectform:
(%i87) abs(rectform(sol)),numer;
(%o87) [.3949308436346983,1.137158042603258,.7422271989685594]
These are the symbolic results with and without rectform:
(%i88) abs(sol);
(%o88) [1/sqrt(3),1/sqrt(3),2/sqrt(3)]
(%i89) abs(rectform(sol));
(%o89) [sin(5*%pi/18)-cos(5*%pi/18)/sqrt(3),
sin(5*%pi/18)+cos(5*%pi/18)/sqrt(3),2*cos(5*%pi/18)/sqrt(3)]
There seems to be something wrong with the absolute value.
Dieter Kaiser