Convert an ODE to algebraic equations

10 次查看(过去 30 天)
Hello, how can I convert a nonlinear ODE of third degree to a set of algebraic equations, which I can at last solve with fsolve? Some mentioned the Haar wavelet, however I cannot find an example of this on MATLAB.


John D'Errico
John D'Errico 2018-2-22
编辑:John D'Errico 2018-2-22
It has been a while since I used these methods, so I will not go that deeply into the answer. But there are multiple ways to solve a differential equation, not just the ones you find in ODE45 or dsolve. Well, to try to solve one at least. And if the ODE is nonlinear, I would not expect any real hope that you will get an analytical solution.
Here is your ODE:
y' ' '+(1-x^2)y = 0
Well, not too messy at least. there are some common ways you might decide to solve this that do not fall into the standard methods described above, that will convert the problem into a set of (nonlinear) algebraic equations.
Simplest is to discretize the problem, using finite differences. Thus over some domain, we will approximate y at a set of points. Suppose you intend to solve the ODE on the domain [0,a]. Choose some number of points (n) to break the domain into, such that y is now some vector of values at the locations
x = linspace(0,a,n-1);
At each location, we will formulate one nonlinear equation, using a finite difference operator on that third derivative. (Be careful near the ends of the domain, since you may need to tweak that finite difference to be valid.) Create several additional equations to represent the initial/boundary conditions on the ODE. In the end, you want n nonlinear equations in the unknown vector y.
The solution is simple if the ODE is linear, because the result will be a linear system of algebraic equations. But it is only an approximation, as good as the discretization you have chosen. It will NOT yield an analytical solution.
There are other approaches. For example, you might decide to represent y as a spline. Given the third derivative in your problem, I might decide to work with a quintic spline. You should be able to see where this is going, since a spline model will be nicely differentiable. Substitute into the ODE, and the result will again be a system of nonlinear equations in the coefficients of the spline. Again, this cannot possibly result in an analytical solution to your problem.
If I had to guess however, you are thinking about a Galerkin method. Here we will approximate y(x) using some intelligently chosen expansion. Some common choices might be to represent y(x) as a Fourier series, or a sum of Bessel functions, or perhaps a sum of orthogonal polynomials, thus Chebychev, etc. (Were you to go the last route, you might find the chebfun toolbox of great value. Read here, for example. ) So we will write y(x) as a sum of terms a_n*y_n(x), for a set of undetermined coefficients a_n. Form a dot product with each member of the orthogonal family, which results in one nonlinear equation per dot product. Again, solve for the undetermined coefficients in the series expansion. Will this yield an analytical solution? Of course not, unless you can find something nice happens. However good things never seem to happen on these things, at least not to me.
So, all of the above approaches can be made to result in a system of nonlinear algebraic equations to solve. NONE of them will generally yield an analytical solution on a nonlinear problem.
For example, were I to try to solve your ODE
y' ' ' + (1-x^2)*y = 0
on the domain [0,1], using chebfun. I'll be pretty arbitrary, with y(0)=1, and y'(0)=0, y''(0)=0.
L = chebop(0, 1);
L.op = @(x,u) diff(u,3) + (1-x^2)*u;
L.lbc = [1 0 0]; % short way of writing all three BC at x==0
u = L\0
u =
chebfun column (1 smooth piece)
interval length endpoint values
[ 0, 1] 13 1 0.85
vertical scale = 1
But again, is this an analytical solution? Of course not. It was easy to solve though. Trivial to write using chebfun. I'd give chebfun a try here. (I used the current version found on the FEX, chebfun-chebfun-f5d7a97, for my solution.) While it will not give you the analytical solution you desire, it might give you some intuition about the solution.
On the other hand, essentially NOTHING you do using fsolve will yield an analytical solution anyway.

更多回答(3 个)

Steven Lord
Steven Lord 2018-2-21
If you have an ODE, why solve it (or a modified version of it) using fsolve? Why not simply use one of the ODE solvers included in MATLAB? The "Choose an ODE Solver" section linked on that page includes an example of how to solve a higher-order ODE.
  3 个评论


Sergio Manzetti
Sergio Manzetti 2018-2-22
编辑:Sergio Manzetti 2018-2-22
Thanks John, it appears I must have misunderstood the claim of an analytical solution. It was suggested by one of the authors of this paper, using this method.
I will try to use Chebtool! Thanks
  3 个评论
John D'Errico
John D'Errico 2018-2-22
I read through the paper just now. It only offers approximate solutions, then compares them to exact solutions obtained using other methods. The analytical solutions they had were easy to gain, because the problems they were solving were basic Laplacian PDEs.
There was no claim that I saw for a method that would offer an analytical solution. Anyway, that methodology was only applied to linear problems in their examples.
So, sorry, but I think it will be of little real value to you here. And it will require you to do the computations yourself, writing a bit of code to implement.


Sergio Manzetti
Sergio Manzetti 2018-2-22
Thanks John! Sounds like something I may do in the future.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by