Question: substitution of sub expressions. Is this an OK method?

What is the correct idiom in Maple to do subexpression replacement?

Suppose I want to replace each occurance of ln(anything) by ln(abs(anything)) in an expression.

Currently I call indets and then loop over each entry and use patmatch to do the replacement.

Is there a better method than what I doing now? Here is an example

restart;
expr := 7*ln(arcsin(x))-(1/2)*ln(x-1)*sin(x)-(1/2)*ln(x+1)+f;
lis:=indets(expr):
for z in lis do
    a:='a';b:='b';c:='c';
    if patmatch(z,a::anything*ln(b::anything)*c::anything,'la') then
       map(z0->assign(z0),la);
       expr:=subs(z = a*ln(abs(b))*c, expr);
    fi;
od:
expr;

I do not know if this will fails on some other cases yet.

Please Wait...