0% found this document useful (0 votes)
2 views4 pages

Lab 3 Original

The document presents a MATLAB implementation for solving an initial value problem (IVP) using the Pade approximation on a variable mesh. It includes code for calculating numerical solutions, plotting results, and comparing numerical and exact solutions. The results are displayed through various figures illustrating the numerical and exact values of the solution over time.

Uploaded by

akhilaanil220
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Lab 3 Original

The document presents a MATLAB implementation for solving an initial value problem (IVP) using the Pade approximation on a variable mesh. It includes code for calculating numerical solutions, plotting results, and comparing numerical and exact solutions. The results are displayed through various figures illustrating the numerical and exact values of the solution over time.

Uploaded by

akhilaanil220
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

%NAME:ANKIT KUMAR PADHI

% ROLL NO.-SAU/AM/MSC/2024/09
% APM-2025
% SOUTH ASIAN UNIVERSITY
% MATLAB FILE 03
% NUMERICALOF SOLUTION OF IVP USING PADE APPROAX ON VARIABLE MESH
% Ut=lamda*U
% U(t)=exp(Lamda*t)
clear all;
LAMDA =10.0;
N=10;
ETA=l.2;
disp('variable mesh numerical solution for IVP using PADE ')
disp(' ');
fprintf('N=%4.2f\n',N);
disp(' ');
for I=l:8
SUM=l.0;
for L=l:N-1
SUM=SUM+ETA"L;
end
H(2)=1.0/SUM;
for L=2:N
H(L+l)=ETA*H(L);
end
T(1)=0.0;
for L=2:N+l
T(L)=T(L-l)+H(L);
end
T(N+l)=l.0;
for L=l:N+l
EU(L)=exp(LAMDA*T(L));
end
U(l)=EU(l);
U(l)=l.0;
tic
for L=l:N
H0=H(L+l)
C=LAMDA*H0;
D1=1+0.5*C;
D2=1-0.S*C;
D=1+0.5*C+(C*C/12);
D=D1/D2;
U(L+l)=D*U(L);
end
ERU=abs(U(N+l)-EU(N+l)); fprintf('N=%4.2f,ERU=%10.4e\
n',N,ERU);
disp(' ');
N=2*N;
end
toe
figure(l);
plot( T,U,'--g');
xlabel('t-values');
ylabel('numerical values u');
title('numerical solution');
figure(2);
plot( T,U,'--g');
xlabel('t-values');
ylabel('exact values
u'); title('exact
solution'); figure(3);
plot( T,U,'-g',T,EU,'--r');
xlabel('t-values');
ylabel('numerical and exact values u');
title('exact vs numerical solution');
figure(4);
plot(T,U,'b+');hold on
plot(T,EU,'-r');hold off
xlabel('t-values');
ylabel('numerical and exact values u');
title('exact vs numerical solution');

variable mesh numerical solution for IVP using PADE

N=10.00

H0

0.0385

H0

0.0462

H0

0.0555

H0

0.0666

H0

0.0799

H0

0.0959

H0

0.1150
x10
4 num:erical :&oluti,on
ilO

9
I

8 '
7 -
'::]

aU : l ,
6
m
> I
m 5 ( -
0
·s:::: I

'
d)

E 4
::J
C
3

2
I
I -
,....,,.
1
.,-
"'- - - -
0
0 0.1 0..2 0.3 0.4 0.5 0.6 0.7 0.B 0.9
t-valu.es

4 exa:ct soluti,on
ilO x10

9
I

8 '
7
::J
Ul 6
a:,
::J
m I
> 5 ( -
t I
rn
X
a:, 4
'
3

2
I
I
,....,,.
..
1

0 "' - -
.,-

0 0.1 0..2 0.3 0.4 0.5 0.6 0.7 0.B 0.9


t-valu.es
x10
4 exact vs numerical solution
ilO

I
9

8
::::l
tJ'J
a:,
::J
rn
7 I
>
t5 6
m
ri'.i
TI 5
C
m
mu 4
·c
Q)

E 3
::J
C
2

0
0 0.1 0..2 0.3 0.4 0.5 0.6 0.7 O.B 0.9 1
t-values

4 exact vs numerical solution


x10
ilO

8
::::l
tJ'J
a:,
::J 7
m
>
t5 6
m
ri'.i
TI 5
C
m
mu 4
·c
Q)
E 3
::J
C
2

1 +

0..2 0.3 0.4 0.5 0.6 0.7 O.B 0.9


t-values

Published with MATLAB® R2024b

You might also like