Am Donnerstag, den 20.10.2011, 13:52 -0700 schrieb Edwin Woollett:
> On Oct. 20, Stavros Makrakis wrote:
>
> > Something like this?:
> >
> > declare(union,nary)$
> > listofops(expr) := block([inflag:true], if mapatom(expr) then {} else
> > adjoin(op(expr),xreduce(union,maplist(listofops,expr))))$
> >
> > inflag:true uses the internal form for efficiency; be aware that
> > listofops(-a/b) => {"*","^"} (from (-1)*a*b^(-1)) instead of {"-","/"}
> >
>
> Actually, I asked for the wrong thing. I should have asked for
> something to detect the presence, in an expression, of one
> of Maxima's special functions (true/false).
>
> I found funp, funp1, funp2 in ...share/fourie.mac, which does
> the job to define spfunp (expr) ; see below:
>
> -----------------------------------------
> (%i1) load(temp);
> (%o1) c:/work2/temp.mac
>
> (%i2) spfunp (bessel_y(2,x));
> (%o2) true
>
> (%i3) spfunp (x);
> (%o3) false
> (%i4) spfunp (x*bessel_y(2,x) + bessel_j(0,x));
> (%o4) true
>
> --------------------------------------------------
> /* temp.mac
> oct. 20, 2011
> code spfunp to detect special functions:
> return true is any are found
> return false otherwise
> */
>
>
> /* funp1: code from ....share/calculus/fourie.mac */
>
> funp1(fun,exp):=block([inflag],inflag:true,
> if mapatom(exp) then false
> else (if inpart(exp,0) = fun then true
> else member(true,maplist(lambda([q],funp1(fun,q)),exp))))$
>
>
> spfunp (expr) :=
> block ([spfun, spf:false],
>
> for spfun in
> [bessel_j,bessel_y,bessel_i,bessel_k,
> hankel_1,hankel_2,struve_h,struve_l,
> assoc_legendre_p,assoc_legendre_q,
> %f,gamma,gammagreek,gammaincomplete,
> hypergeometric,slommel,%m,%w,erfc,
> expintegral_e,expintegral_e1,
> expintegral_ei,expintegral_li,
> expintegral_si,expintegral_ci,
> expintegral_shi,expintegral_chi,
> kelliptic,parabolic_cylinder_d] do
>
> if funp1 (spfun,expr) then (
> spf:true,
> return()),
> spf)$
Maxima has the Lisp function isinop. I have extended this function some
times ago to return not only true and false, but a whole expression.
With this function the following is possible:
(%i1) expr:abs(x)+bessel_y(1,y)+struve_h(0,z)+'integrate(f(x),x);
(%o1) 'integrate(f(x),x)+abs(x)+bessel_y(1,y)+struve_h(0,z)
(%i2) ?isinop(expr,abs);
(%o2) abs(x)
(%i3) ?isinop(expr,struve_h);
(%o3) struve_h(0,z)
(%i4) ?isinop(expr,struve_l);
(%o4) false
(%i5) ?isinop(expr,bessel_y);
(%o5) bessel_y(1,y)
(%i6) ?isinop(expr,bessel_i);
(%o6) false
(%i7) ?isinop(expr,nounify(integrate));
(%o7) 'integrate(f(x),x)
If the operator is present, the whole expression is returned. This
functions checks only for the first appearance of the operator. I think
it is a nice function which we might add for the Maxima user.
Dieter Kaiser