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



Nice, but it fails for some trivial cases (as does rich.hennessy's version): 


solution(0) => error  but h(x):=0, m=<anything> is a solution
solution(y/x) => error but h(x):=1, m=<anything> is a solution


             -s

This one works and does not crash with your inputs but it is only lightly tested.  I came up with it based on the observation that when g2=g3 the inputs make this crash. There is a zero/zero problem case then so I defined u/u = 1 even if u = 0.  %r is any nonzero real number.

solution(g):=block([g2,g3,g6,a],g2:g*x/y,g3:at(g2,y=1/x),if is(equal(g3,g2))=true then (g6:1,a:%r) else  (g6:at(diff(at(g,y=x),x)/diff(g3,x),x=1),a:-ratsimp((g6+1)/(g6-1))), f:at(g*x/y,y=x^(a+1)), if is(equal(radcan(g-y/x*at(f,[x=y/x^a])),0))=true then ['a=a,'f(x)=f])$

Rich