# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Compute an approximate Frobenius or power series solution to an ODE

Contributed by:
Rauan Kaldybayev

ResourceFunction["FrobeniusDSolve"][ solves a differential equation for the function | |

ResourceFunction["FrobeniusDSolve"][ uses the algebraic |

A Frobenius series has the form .

The output is of the form {*soln*_{1},*soln*_{2},…,*soln*_{Z}}, where *Z* is the order of the ODE and *soln*_{1},*soln*_{2},…,*soln*_{Z} are linearly independent solutions to the ODE. They are of the form , normalized by *a*_{0}=1.

ResourceFunction["FrobeniusDSolve"] can solve linear homogeneous ODEs with polynomial coefficients.

Any linear ODE with polynomial coefficients can be written in the form for some (any) *x*_{0}. Frobenius's method assumes solution of the form ; substituting this into the equation yields , where . To satisfy the equation, the coefficients before all power of *x*-*x*_{0} must be zero: for -*Z*≤*k*. From here, we can determine the possible values of the constant *r* for which *a*_{0}≠0, and then for each *r*, compute the coefficients. Read more at the related Wolfram Community post.

ResourceFunction["FrobeniusDSolve"] allows the option "ComputeError":

"ComputeError" | True | compute the error of the approximate solution |

If "ComputeError" is True, the output is of the form {{*soln*_{1},*err*_{1}},{*soln*_{2},*err*_{2}},…{*soln*_{Z},*err*_{Z}}}, where *Z* is the order of the ODE, {*soln*_{k}} are the linearly independent (approximate) solutions to the ODE, and {*err*_{k}} are the errors of the appoximate solutions {*soln*_{k}}. The error of an approximate solution to an ODE of the form *Ly*=0 is defined as . In other words, it is the absolute value of the remainder. The formulas for {*err*_{k}} returned by ResourceFunction["FrobeniusDSolve"] are exact.

Approximate numbers make the function much faster while not affecting accuracy in a significant way. To solve a differential equation exactly using Frobenius's method, in general we would have to compute an infinite number of terms, which is of course impossible. Solutions obtained using Frobenius's method will thus always be approximate, even if exact numbers are used. Because the decrease in accuracy that comes from using approximate numbers is very small, using approximate numbers doesn't really affect the accuracy. And since doing computations with approximate numbers is much faster, they are used in ResourceFunction["FrobeniusDSolve"].

Obtain an order six approximate solution to the ordinary differential equation 2*x*^{2}*y*''+9*x*(*x*+1)*y*'-3*y*=0 using a Frobenius series around the singular point *x*_{0}=0:

In[1]:= |

Out[1]= |

Plot the solutions:

In[2]:= |

Out[2]= |

Compute a more accurate solution with *n*=40 and compare to the previous result:

In[3]:= |

In[4]:= |

Out[4]= |

Plot the residuals Abs[*x*^{2}*y*''+9*x*(*x*+1)*y*'-3*y*]:

In[5]:= |

Out[5]= |

As you can see, the solutions are very accurate. (see Author Notes for more information)

FrobeniusDSolve can also be used to solve equations that don't have singular points. Solve the pendulum equation *θ*''[*t*]=-*θ*[*t*] near the point *t*=-3, with *n*=16:

In[6]:= |

Out[6]= |

Plot the result:

In[7]:= |

Out[7]= |

The function can operate with complex numbers:

In[8]:= |

Out[8]= |

Find a degree 10 approximate solution for the fourth-order ODE (*x*-1)^{4}*f*''''[*x*]=*x*(2+*x*)*f*[*x*]+*x*^{2}(*x*-1)^{2}*f*''[*x*]-19(*x*-1)^{3}*f*'''[*x*] near the singular point *x*=1:

In[9]:= |

Out[9]= |

Plot the results:

In[10]:= |

Out[10]= |

The inputs of the function can be symbolics:

In[11]:= |

Out[11]= |

In[12]:= |

Out[12]= |

Set "ComputeError" to True to get a formula for the error, defined as the absolute value of the remainder, of a FrobeniusDSolve solution set (see Details and Options):

In[13]:= |

Out[13]= |

Use AsymptoticDSolveValue to solve the ODE *ty*''[*t*]+*y*[*t*]=0 near the singular point *t*=0:

In[14]:= |

Out[14]= |

Compare to the result from FrobeniusDSolve:

In[15]:= |

Out[15]= |

Compare timings in milliseconds that FrobeniusDSolve and AsymptoticDSolveValue take to compute the 100th order power series approximation to *y*''+(1+*x*^{2})*y*=0:

In[16]:= |

Out[16]= |

FrobeniusDSolve takes roughly 6 milliseconds to compute, while AsymptoticDSolveValue takes about 34. We can reduce computation time even further with the help of the resource function FrobeniusDSolveFormula:

In[17]:= |

Out[17]= |

When the option "ComputeError" is set to True and FrobeniusDSolveFormula is used, the option "ComputeError" should be switched to True in FrobeniusDSolveFormula, too:

In[18]:= |

Out[18]= |

Solutions obtained using Frobenius's method generally only have a finite convergence radius. Try to compute an approximate solution to the ODE (1+*x*^{3})*y*'=*y* with *n*=60:

In[19]:= |

Out[19]= |

The plot looks good for *x*<1, however, for *x*>1 the solution starts diverging. To see that, notice that the ODE (1+*x*^{3})*y*'=*y* demands *y*' to be positive for *x*>0, *y*>0; the plot, however, suddenly goes down at *x*=1. Besides, the sharpness of the "cliff" looks very suspicious.

Frobenius's method only works near ordinary points or regular singular points. If solution near an irregular singular point is attempted, Frobenius's method would only yield some of the possible solutions or won't be able to find any solutions at all. Consider the ODE *x*^{3}*y*''+*x**y*'+(*x*^{2}-1)*y*=0 near the singular point *x*=0:

In[20]:= |

Out[20]= |

FrobeniusDSolve could only give one of the two linearly independent solutions. The other solution could not be found because it cannot be written in the form , as can be seen with the help of AsymptoticDSolveValue:

In[21]:= |

Out[21]= |

The parameter *n* must be at least *Z*+*M*, where *Z* is the order of the ODE and *M* is the highest power of *x* (the independent variable). If the ODE is *y*''''[*t*]=-(1+*t*^{2})*y*[*t*], then the order *Z*=4 and the highest power of *t* is *M*=2, so *n* must be at least 6:

In[22]:= |

Out[22]= |

Sometimes, the Frobenius series solution to an ODE consists of a finite number of terms. For example, below are a few examples when the exact solution only has one term in it:

In[23]:= |

Out[23]= |

In[24]:= |

Out[24]= |

Sometimes, the solution terminates after a couple terms. While the second of the two solutions below goes on forever, the first one only has four nonzero terms:

In[25]:= |

Out[25]= |

In[26]:= |

Out[26]= |

- 2.0.1 – 05 April 2021

This work is licensed under a Creative Commons Attribution 4.0 International License