finding out if expr has the form F(y/x^a)



?Finally, you might enjoy testing your code on

(%i16) subst(z = y*x^2, (y/x) * (abs(z)-z));
(%o16) (y*(x^2*abs(y)-x^2*y))/x

and determine why check1 fails. Fixing this (and related problems isn't easy, I think).


--Barton?
if pw is loaded then this version of Aleksas? check function works for this case and a lot of other piecewise defined functions too.
load(pw);
load(pdiff);
check3(g,x,y):=block
(
    [eq,sol,_a],
    local(sol,eq),
    eq:_a*y*diff(u(x,y),y)+x*diff(u(x,y),x)=(_a-1)*u(x,y),
    eq:signum2abs(simpsignum(abs2signum(convert_to_diff(eq)))),
    subst(u(x,y)=g,eq), 
    ev(%%,nouns),
    sol:signum2abs(simpsignum(abs2signum(radcan(solve(%%,_a))))),
    if sol=all then sol:[a=%r],
    if not freeof (x,y, sol) then 
        return(false),
    ['a=signum2abs(simpsignum(abs2signum(rhs(sol[1])))),'f(x)=signum2abs(simpsignum(abs2signum(radcan(subst([y=x^(_a+1),sol[1]],g*x/y))))), 
    'u(x,y)=y/x*at(signum2abs(simpsignum(abs2signum(radcan(subst([y=x^(_a+1),sol[1]],g*x/y))))),x=y/x^signum2abs(simpsignum(abs2signum(rhs(sol[1])))))]
)$


(%i13) display2d:false;
(out13) false
(%i14) subst(z = y*x^3, (y/x) * (abs(z)-z));
(out14) y*(x^2*abs(x)*abs(y)-x^3*y)/x
(%i15) check3(%,x,y);
(out15) [a = -3,'f(x) = abs(x)-x,'u(x,y) = y*(x^2*abs(x)*abs(y)-x^3*y)/x]
(%i16) subst(z = y*x^n, (y/x) * (abs(z)-z));
(out16) y*(abs(x^n)*abs(y)-x^n*y)/x
(%i17) check3(%,x,y);
(out17) [a = -n,'f(x) = abs(x)-x,'u(x,y) = y*(abs(x^n)*abs(y)-x^n*y)/x]
(%i18) pw([-1,-x,0,x,1],x,connect,abs);
(out18) (-abs(x+1)+2*abs(x)-abs(x-1))/2
(%i19) subst(z = y*x^n, (y/x) * at(%,x=z));
(out19) y*(-abs(x^n*y+1)-abs(x^n*y-1)+2*abs(x^n)*abs(y))/(2*x)
(%i20) check3(%,x,y);
(out20) [a = -n,'f(x) = (-abs(x+1)+2*abs(x)-abs(x-1))/2,'u(x,y) = y*(-abs(x^n*y+1)-abs(x^n*y-1)+2*abs(x^n)*abs(y))/(2*x)]
(%i21)

Rich