On Nov. 17, Stavros Macrakis wrote:
-----------------
>Really? It seems pretty straightforward to me, something like
>
>hasmultival(ex,var) := if mapatom(ex) then false
>
>else if member(inop(ex), '[log, asin, acos, asinh, etc. etc.] ) and
>member(var,listofvars(ex)) then true
>
>else if inop(ex) = "^" and ...
>
>else ...recursive case...
----------------------------------
Thanks for the suggested framework.
So far, the code seems to be meeting my
goal, but bugs will probably show up
when I make it part of nint.
----------------------------------------------
(%i1) load(hasmultv);
(%o1) "c:/work2/hasmultv.mac"
(%i2) multival(a,x);
(%o2) false
(%i3) multival(sqrt(x),x);
(%o3) true
(%i4) multival(x*sqrt(x),x);
(%o4) true
(%i5) multival(x*sqrt(x^2),x);
(%o5) false
(%i6) multival(a^x,x);
(%o6) false
(%i7) multival(a^(%i*x),x);
(%o7) false
(%i8) multival(a^(2/3),x);
(%o8) false
(%i9) multival(x^(2/3),x);
(%o9) true
(%i10) multival(x^x,x);
(%o10) false
(%i11) multival(x^(%i*x),x);
(%o11) true
(%i12) multival(x^(%i*sin(x)),x);
(%o12) true
(%i13) multival(log(x),x);
(%o13) true
(%i14) multival(sqrt(x)*log(x),x);
(%o14) true
(%i15) multival(acos(x),x);
(%o15) true
(%i16) multival(x^acos(x),x);
(%o16) true
-------------------------------------
with the code:
any_of(list) := member(true,list)$
/* multival(e,x) returns true if a potentially multiple valued
function of x is detected in expression e */
multival(ex,var) := block([inflag:true,listconstvars:true],
if mapatom(ex) then false
else if member(op(ex), '[log, acos,acosh,acot,acoth,acsc,acsch,
asec,asech,asin,asinh,atan,atan2,atanh] ) and
member(var,listofvars(ex)) then true
else if op(ex) = "^" and mvp(ex,var) then true
else any_of(maplist(lambda ([u],multival(u,var)),ex)))$
/* complexvar(ee,vv) returns true if
ee contains both variable vv and %i */
complexvar(ee,vv) := block([listconstvars:true],
if mapatom(ee) then false
else if member (vv,listofvars(ee)) and member(%i,listofvars(ee))
then true
else any_of(maplist(lambda ([u],complexvar(u,vv)),ee)))$
/* mvp(e,v) returns true if e = f^g has either the
form f(x)^g(x,%i) or f(x)^(p/q) */
mvp (e,v) := block([inflag:true],
/* disp("mvp"),
display (e,v),
*/
if mapatom(e) then false
else if length(e) = 1 then false
else if atom(part(e,2)) then false
else if member(v,listofvars(part(e,1))) and
op(part(e,2)) = "/" then true
else if member(v,listofvars(part(e,1))) and complexvar(part(e,2),v)
then true
else any_of(maplist(lambda ([u],mvp(u,v)),e)))$
-----------------------------------
Ted