How to input piecewise continuous differential function into chebfun?
13 views (last 30 days)
Show older comments
I want to approximate the solution of a piecewise continuous differential equation with chebfun. But I did not figure out a way to pass the function into chebop.
Assume I have the following differential equation:
u''=x, 0<=x<=0.5
10*u''=x, 0.5<x<=1
With boundary condition u(0)=0, u(1)=1/80
How can I use chebop to solve u?
I tried to express the input with binary conditions but the approximate solution does not look right. Is that because I did not use chebop in the correct way, or is the problem with chebfun itself?
Below are the details:
====================================================================
To verify, the analytic solution of the differential equation above is
u = 1/6*x^3-1/24*x, 0<=x<=0.5
u = 1/60*x^3-1/240*x, 0.5<x<=1
====================================================================
I checked out the chebgui Demo, and found it has examples with discontinuity using either sign(x) or binary conditions, i.e. -(x>=5)*(x<=10).
Thus, I tried to input the differential equation with
L = chebop(0,1);
L.op = @(x,u)((x>=0.5)*10+(x<0.5)*1).*diff(u,2)-x;
L.lbc = @(u) u;
L.rbc = @(u) u-1/80;
But the result does not approximate the solution very well (the 'chebop' line in the figure).
On the other hand, if I plot the function with chebfun with the code
L=chebfun({@(x)1/6*x^3-1/24*x, @(x)1/60*x^3-1/240*x}, [0 0.5 1]);
The plot approximates the true solution very well even with 'splitting' off (the 'chebfun' line in the figure, the line is identical with the true solution line 'ts').
0 Comments
Answers (1)
Torsten
on 11 Mar 2015
Without your boundary conditions, the solution of your differential equation is given by
u1(x)=1/6*x^3+a*x+b if 0<=x<=0.5
u2(x)=1/60*x^3+c*x+d if 0.5<=x<=1
So you have four degrees of freedom, but only two boundary conditions.
Thus the solution of your differential equation is not unique.
You may want to specify some transmission conditions at x=0.5, e.g. u1=u2 and du1/dx=du2/dx to make u1 and u2 unique.
Best wishes
Torsten.
2 Comments
Torsten
on 11 Mar 2015
The above transmission conditions result in the solution from chebop:
u1(x)=1/6*x^3-19/240*x
u2(x)=1/60*x^3+1/30*x-3/80
Best wishes
Torsten.
Eszter Feher
on 20 Jan 2023
Edited: Eszter Feher
on 20 Jan 2023
Could you explain the method of specifying the transmission conditions? If I try to add an extra boundary condition at x=0.5, e.g.:
L.bc = @(u) diff(u(0.5),2);
I get: "Number of inputs to BCs do not match operator.".
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!