How to solve a system of integro differential equation using numerical method?
30 views (last 30 days)
Show older comments
integro differential equation
0 Comments
Accepted Answer
Torsten
on 24 Dec 2021
Edited: Torsten
on 24 Dec 2021
Simple.
Solve instead
dx/dt = t*x(t) + exp(t)*u(t), x(0) = 1
dy/dt = t^3*x(t) + exp(-t)*v(t), y(0) = 1
du/dt = exp(-t)*y(t), u(0) = 0
dv/dt = exp(t)*sin(x(t)), v(0) = 0
using one of the ODE solver from the MATLAB ODE suite, e.g. ODE15S,ODE45.
3 Comments
Torsten
on 24 Dec 2021
Edited: Torsten
on 24 Dec 2021
This works for your IDE from above, not for IDEs in general.
Do you really expect someone out there will write a code for you for the solution of general systems of IDEs ?
I think this would take some weeks or even months of work.
Hint for the du/dt and dv/dt terms:
What do you get if you differentiate
integral_{0}^{t} exp(-s)*y(s) ds
and
integral_{0}^{t} exp(s)*sin(x(s)) ds
with respect to t ?
More Answers (3)
Torsten
on 28 Dec 2021
Edited: Torsten
on 28 Dec 2021
function main
tspan = [0 10];
y0 = [1; 1; 0; 0];
[T,Y] = ode45(@fun,tspan,y0);
plot(T,[Y(:,1),Y(:,2)])
end
function dy = fun(t,y)
dy = zeros(4,1);
dy(1) = t*y(1) + exp(t)*y(3);
dy(2) = t^3*y(1) + exp(-t)*y(4);
dy(3) = exp(-t)*y(2);
dy(4) = exp(t)*sin(y(1));
end
This is the code for your original system of IDEs.
I don't know about the new system you wanted to solve with the code from above.
2 Comments
Torsten
on 29 Dec 2021
Edited: Torsten
on 29 Dec 2021
Seems to work as expected:
function main
y0 = 1 + 1i;
z0 = [1 1];
tspan = [0 2];
[t,y] = ode45(@complexfun, tspan, [y0,z0]);
figure
plot(t,[real(y(:,1)),imag(y(:,1))])
figure
plot(t,[y(:,2),y(:,3)])
end
function f = complexfun(t,y)
f = zeros(3,1);
f(1) = y(1)*t+2*1i;
f(2) = y(2)*t;
f(3) = y(3)*t+2;
end
See Also
Categories
Find more on Ordinary Differential Equations 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!