Most of the time, odetest() returns just zero if solution satisfies ode, and non-zero expression if solution does not satisfy ode.
So I was just checking for zero as return value to check if my solution was verified or not. This works for most cases.
But there are cases when odetest returns odetest/PIECEWISE` where some cases are zero and some are not. Example is below.
For this, I still want to consider my solution as valid if one of the cases in piecwise is zero. But I am not sure what is a robust way to do this in code. Currently, I do the following
ode:=x*diff(y(x),x) = y(x)+2*(x*y(x))^(1/2);
my_sol:=y(x)=x*(ln(x/_C1)^2 - 1) - 2*(-1 + sqrt(ln(x/_C1)^2))*x;
if res<>0 then
if type(res,'function') then #this meant to handle PIECWISE
print("did not verify");
else #if we come here, res=0, so I am sure it is valid.
In the above, the check type(res,'function') is meant to catch PIECEWISE return, since when I did type(res) Maple told me the type is function.
But I am not sure if this is a robust way to check for this, as it might be possible maple will return non zero, and also a function, but it will not be what I think it is (i.e. PIECEWISE) and then I would flag my solution as valid when it is not.
worksheet attached also.