Azzera filtri
Azzera filtri

Solving simple integro-differential equation using dsolve in Matlab

7 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Torsten
Torsten il 18 Mar 2024
Modificato: Torsten il 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 Commento
Paul
Paul il 19 Mar 2024
Modificato: Paul il 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
eqn(t) = 
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)
ans = 
The equation should be entered as
syms tau
eqn = Dx + 2*x + 2*int(x(tau),tau,0,t) == 0
eqn(t) = 
The output from dsolve still not neccessarily helpful
sol(t) = dsolve(eqn,cond)
sol(t) = 
But now laplace() works and we can solve the problem that way
Leqn = laplace(eqn)
Leqn = 
syms s
L(s) = rhs(isolate(Leqn,laplace(x,t,s)))
L(s) = 
x(t) = ilaplace(subs(L(s),x(0),1))
x(t) = 

Accedi per commentare.

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by