Académique Documents
Professionnel Documents
Culture Documents
Name
: Nadya Amalia
Student ID
: 20213042
Subject
Lecturer
FINITE-DIFFERENCE METHOD
Use the finite-difference method to solve the problem
= + ( 4),
0 4
)( =
= +
= 1
Complementary solution
= +
= +
(2 ) ( + + = ) 4
+ (2 = ) 4
The corresponding terms on both side should have the same coefficients, therefore, equating
the coefficients of like terms.
:
= 1
1 :
2 = 0
= 4
= 1
=4
= 2
Therefore, = + 4 2 and = + = + + 4 2.
1
For = 4
(0) = (4) = 0
+ (0) + (4)(0) 2 = 0
+ = 2
+ (4) + (4)(4) 2 = 0
+ = 2
Substitute = 2
(2 ) + = 2
+ = 2 2
( ) = 2 2
2 2
=
( )
4 0
=
=1
1
( 2 + )
1
' = ( )
'' =
with
in the differential equation we obtain
=1
( 2 + ) =
2 + =
For = 1, = 1, = 0
3 + =
3 + = ( 4)
0 3 + = 1(1 4)
3 + = 3
2
For = 2, = 2
3 + = ( 4)
3 + = 2(2 4)
For = 3, = 3, = 0
3 + = 4
3 + = ( 4)
3 + 0 = 3(3 4)
3 = 3
1
1
0
0
0
Or in a compact form as = .
0
0
0
3
1
0
1 3
1
0
1 3
0
0
0
0
0
0
1
1
0
0
1 3
2 = 4
3 3
4 0
ym = linspace(0,4,n+1);
ym(1:n+1) = y;
% The analytical solution's presentment
% y(x) = 0.03597(e^x) + 1.96403(e^(-x)) - x^2 + 4x - 2
e = 2.7182818;
delta = linspace(0,4,100);
u = (0.03597.*(e.^delta)) + (1.96403.*(e.^(-delta))) - (delta.^2) +
(4.*delta) - 2;
subplot(1,2,1);
p = plot(delta, u, '*');
title('Plotting of analytical solution of y"(x) - y(x) = x(x - 4)');
xlabel('x'); ylabel('y(x)');
grid on
set(p, 'Color', 'red')
% Presentment of the approximation
intervall = linspace(0,4,n+1);
subplot(1,2,2);
plot(intervall, ym, '-*') ;
title('Plotting of numerical solution of y"(x) - y(x) = x(x - 4) using
Finite-Difference Method');
xlabel('interval [0,4]'); ylabel('yi');
grid on;
1,85714
= 2,57143
1,85714
0
Thus,
= (1) = 1,85714,
2.5
2.5
1.5
1.5
yi
0.5
0.5
0.5
1.5
2
x
2.5
3.5
0.5
1.5
2
2.5
interval [0,4]
3.5