3.42 How to guess a solution to an ode?

Sometimes we need to guess a particular solution to an ode. For example when solving the Riccati ode \(y'=f_0 + f_1 y + f_2 y^2\).

Typical guesses for this ode are \(y=a x^b\) and \(y=a e^{b c}\). How can we find using Maple if such a guess works or not and what are the values of the constants \(a,b\)?.

To do this, we first use odetest on the guess. This gives some residual. Then we use solve command with the identity, to solve for the values \(a,b\) that would make the residual zero. If solve finds a solution, then we have found the guess solution.

solve with identity used below, basically says to find constants \(a,b\) which will make the residual zero for any \(x\). This is why we must use identity(the_residual=0,x) below.

Here is an example

restart; 
 
ode:=diff(y(x),x)=-(1+x+x^2)-(2*x+1)*y(x)-y(x)^2; #riccati ode 
guess_1:=y(x)=a*x^b; 
the_residual:= odetest(guess_1,ode); 
 
# the_residual := a^2*x^(2*b) + 2*a*x^(1 + b) + a*b*x^(b - 1) + a*x^b + x^2 + x + 1 
 
solve(identity(the_residual=0,x),[a,b]) 
 
        [[a = -1, b = 1]]
 

It worked. The above says that \(y=-x^{-1}\) is a particular solution. Now we know a particular solution, we can solve the Riccati ode and find the general solution.

Let use try the other guess and see what happens

guess_2:=y(x)=a*exp(b*x); 
ode:=diff(y(x),x)=-(1+x+x^2)-(2*x+1)*y(x)-y(x)^2; 
the_residual:=odetest(guess_2,ode) 
 
    #the_residual := a^2*exp(2*b*x) + a*b*exp(b*x) + 2*a*exp(b*x)*x + a*exp(b*x) + x^2 + x + 1 
 
solve(identity(the_residual=0,x),[a,b]) 
 
      []
 

No solution. This means this guess did not work. This way we can make a number of guesses and try them hoping one will work. As we know, there is no general method to solve every Riccati ode. but if we know one particular solution, then it can be solved. So this method of guessing a solution can lead to a way to solve a Riccati ode which otherwise can be hard to solve using other methods.

This is another example, given ode

\[ y'=\frac {4 x^{2}+5 x}{x -1}-\frac {4 \left (2 x +1\right )}{x -1} y +\frac {4}{x -1} y^2 \]

Try to guess a solution. Since coefficients are polynomials of most degree 2, we start by a guess of form \(y=a x + b\) and if this does not work, we try \(y=a x^2 + b x + c\). But it is better just to use same order polynomial as the largest one in the coefficients.

restart; 
ode:=diff(y(x),x)= (4*x^2+5*x)/(x-1)-4*(2*x+1)/(x-1)*y(x)+4/(x-1)*y(x)^2; 
guess_1:=y(x)=a*x^2+b*x+c; 
 
the_residual:=odetest(guess_1,ode) 
 
#the_residual := -4*a^2*x^4/(x - 1) - 8*a*b*x^3/(x - 1) - 8*a*c*x^2/(x - 1) 
                 + 8*a*x^3/(x - 1) - 4*x^2*b^2/(x - 1) + 6*a*x^2/(x - 1) 
                 - 8*b*c*x/(x - 1) + 8*x^2*b/(x - 1) - 2*a*x/(x - 1) + 5*b*x/(x - 1) 
                 - 4*c^2/(x - 1) + 8*c*x/(x - 1) - 4*x^2/(x - 1) - b/(x - 1) + 4*c/(x - 1) - 5*x/(x - 1) 
 
solve(identity(the_residual=0,x),[a,b,c]) 
 
 
#[[a = 0, b = 1, c = 1/2], [a = 0, b = 1, c = 1/2], [a = 0, b = 1, c = 1/2], [a = 0, b = 1, c = 1/2]]
 

There are 4 different particular solutions. Using any one of these, now we can solve the Riccati ode easily using the transformation \(y=y_p + u(x)\) or using \(y=y_p + \frac {1}{u}\). Where \(y_p\) is any of the above 4 particular solutions.