Am Mittwoch, den 16.11.2011, 14:54 -0800 schrieb Edwin Woollett:
> I need a way to detect the op sqrt in an expression.
>
> So far, neither ?isinop or listofops seems to work:
> ---------------------------------------------
> Maxima 5.25.1 http://maxima.sourceforge.net
> using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
>
> (%i1) display2d:false$
>
> (%i2) ?isinop(a*bessel_j(0,x),bessel_j);
>
> (%o2) bessel_j(0,x)
>
> (%i3) ?isinop(a*sqrt(x),sqrt);
>
> (%o3) false
>
> (%i4) ?isinop(sqrt(x^2),sqrt);
>
> (%o4) false
>
> (%i5) load(nint);
>
> (%o5) "c:/work2/nint.mac"
>
> (%i6) listofops(a*sqrt(x^2+y^2)/b);
>
> (%o6) {"*","+","^"}
>
> (%i7) listofops(a*bessel_j(0,x)/c);
>
> (%o7) {"*","^",bessel_j}
> -------------------------------------
Maxima does not know an internal SQRT operator. SQRT is only displayed
and can be part of an input, but internally in Maxima the SQRT function
is represented as the power function x^(1/2) and the internal form is
((mexpt) x ((rat) 1 2). There is some documentation about the internal
and external representation of Maxima expressions in the manual.
The Lisp function isinop gives the result the following way:
(%i1) ?isinop(a*x^(1/2), ?getopr("^"));
(%o1) sqrt(x)
But any other power function will be a result too:
(%i2) ?isinop(a*x^(1/3), ?getopr("^"));
(%o2) x^(1/3)
In addition it is necessary to transform the name "^" of the operator to
the internal symbol MEXPT. This has been done with the Lisp function
getopr:
(%i3) ?getopr("^");
(%o3) ?mexpt
An alternativ is the Maxima function dispform, see the Maxima manual.
This functions transforms an expression into the external representation
which contains the SQRT function:
(%i4) ?isinop(dispform(a*sqrt(x)), sqrt);
(%o4) sqrt(x)
(%i5) ?isinop(dispform(a*x^(1/2)), sqrt);
(%o5) sqrt(x)
With the function dispform a power function with an exponent different
from 1/2 gives the result false:
(%i6) ?isinop(dispform(a*x^(1/3)), sqrt);
(%o6) false
I see you are using the Lisp function isinop. Perhaps it is desirable to
have an equivalent Maxima function which can do even some more work like
the transformation of the names of operators into the internal format.
Dieter Kaiser