How to solve a system of integro differential equation using numerical method?

10 views (last 30 days)
integro differential equation

Accepted Answer

Torsten
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
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 ?

Sign in to comment.

More Answers (3)

Hewa selman
Hewa selman on 28 Dec 2021
function mysysfun
clc;
clear;
t = 0:0.1:10;
%%%t = [0 5];
initial_Y1 = 1;
initial_Y2 = 1;
initial_U1 = 0;
initial_U2 = 0;
%%%Y0 = [initial_Y1 initial_Y2];
Y0 = [initial_Y1 initial_Y2 initial_U1 initial_U2];
[t, Y] = ode45 (@ mysys, t, Y0);
%%
%figure;
plot(t,Y(:,1),'r');
xlabel('t1'); ylabel('Y1');
title('solving the 1st order differential equations Y(1,1)')
figure;
plot(t,Y(:,2),'g');
xlabel('t2'); ylabel('Y2');
title('solving the 1st order differential equations Y(2,1)')
figure;
plot(t,Y(:,1),'r')
grid on; hold on;
plot(t,Y(:,2),'g')
xlabel('Time of t1')
ylabel('Equation Y1')
title('solving the system of 1st order differential equations')
legend('Y(1,1)','Y(2,1)','Interpreter','latex');
%%
function dYdt = mysys(t,Y)
dYdt1_11=t+exp(t)*Y(2)+exp(t)*U(1);
dYdt2_21=exp(t)+cos(Y(1))+exp(t)*U(2);
dUdt3_31=exp(-t)*Y(2);
dUdt4_41=exp(t)*sin(Y(1));
%%%dYdt = [dYdt1_11; dYdt2_21];
dYdt = [dYdt1_11; dYdt2_21; dUdt3_31; dUdt4_41];
end
end
Hello Mr. Torsten. Could you help me for solve this code. I think ode45 is not suitable for solve this code. The system is integro differential eqyation.
with regards.

Torsten
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
Hewa selman
Hewa selman on 29 Dec 2021
well. thank you Mr. Torsten.
Could i use the comlex functions instead of real functions in this code? Or I have to get the real and imaginary pars and next use your code.
Like this code
%% file imaginaryODE
function fv = imaginaryODE(t,yv)
y = yv(1) + 1i*yv(2);
yp = complexfun(t,y);
fv = [real(yp) ;imag(yp)];
end
y0 = 1 + 1i;
yv0 = [real(y0); imag(y0)];
tspan = [0 2];
y = yv(:,1) + 1i*yv(:,2);
[t,yv] = ode45(@imaginaryODE, tspan, yv0);
% and the file complexfun
function f = complexfun(t,y)
f = y.*t+2*1i;
I have to solve the complex integro differential equations and get the results.
Could you help me in this problem
with regards.
Torsten
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

Sign in to comment.


Hewa selman
Hewa selman on 3 Jan 2022
Edited: Hewa selman on 3 Jan 2022
HELLO MR. TORSTEN.
THANK YOU FOR SUPPORT.
I AM NOT UNDERSTANDING THE PLOT CLEARLY, SINCE THE INITIAL VALUE PLACES THE POINT(1,1) BUT IN FIGURE IT PLACES THE POINT (0,1). I THINK THE PLOT (PLOT 3D) IS MORE CLEAR AND I TRIED TO PLOT THE 3D ONE, BUT I AM NOT SURE TOO AS FOLLOSW
a = -2:0.1:2;
b = -2:0.1:2;
f = meshgrid(a,b);
surfc(a,b,abs(f))
WHERE, (a+bi) is complex number.
PLEADE HELP ME
WITH REGARDS.
  9 Comments

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!