[Maxima] realonly in algsys.lisp

Alexey Beshenov al at beshenov.ru
Sun Apr 26 09:58:42 CDT 2009

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

(%i3) map ('trigsimp, %);
(%o3) [(sqrt(3)*sin(5*%pi/18)-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.

Yours sincerely,
Alexey Beshenov <al at cadadr.org>

More information about the Maxima mailing list