Solving simple integro-differential equation using dsolve in Matlab
5 views (last 30 days)
Show older comments
I have following integro-differential equation:
I tried to solve it using symbolic math toolbox in Matlab:
syms x(t)
Dx = diff(x,t)
cond = x(0)==1
eqn = Dx + 2*x + 2*int(x) == 0
x(t) = dsolve(eqn, cond)
dsolve gives:
x(t) =
exp(1 - (2*t + 2)^2/4)
Matlab solution is wrong.
Solving equation by hand using Laplace transform I get:
Why Matlab gives the wrong symbolic solution?
Thank you.
0 Comments
Answers (1)
Torsten
on 18 Mar 2024
Edited: Torsten
on 18 Mar 2024
If you insert the line
simplify(diff(x,t)+2*x+2*x*t)
you will see that this expression turns out to be equal to 0. So MATLAB interprets x(t) as constant over [0 t] in the integration.
I'd say that "dsolve" is not suited to solve integro-differential equations or - since you don't get an error message - it's a bug.
1 Comment
Paul
on 19 Mar 2024
Edited: Paul
on 20 Mar 2024
Not a solution to the problem, but worth pointing out that the code does not properly reflect the actual equation in the question.
syms x(t)
Dx = diff(x,t);
cond = x(0)==1;
eqn = Dx + 2*x + 2*int(x) == 0
Here, int(x) is an anti-derivative of x(t), which is not the same as the integral in the problem statement.
Consequently, further operations on eqn may not yield the expected result. For example, taking the Laplace transform does not apply the expected "integral rule" to the third term.
laplace(eqn)
The equation should be entered as
syms tau
eqn = Dx + 2*x + 2*int(x(tau),tau,0,t) == 0
The output from dsolve still not neccessarily helpful
sol(t) = dsolve(eqn,cond)
But now laplace() works and we can solve the problem that way
Leqn = laplace(eqn)
syms s
L(s) = rhs(isolate(Leqn,laplace(x,t,s)))
x(t) = ilaplace(subs(L(s),x(0),1))
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!