komputasi sistem fisis 3

4

Click here to load reader

Upload: nadya-amalia

Post on 08-Jul-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Komputasi Sistem Fisis 3

8/19/2019 Komputasi Sistem Fisis 3

http://slidepdf.com/reader/full/komputasi-sistem-fisis-3 1/4

1

Homework 3

Name : Nadya Amalia

Student ID : 20213042

Subject : Computational Physical Systems (FI5005)

Lecturer : Dr.rer.nat. Linus Ampang Pasasa

FINITE-DIFFERENCEMETHOD

Use the finite-difference method to solve the problem

ݕ

ᇱᇱ =ݕ 

− 4),   0   ≤ݔ

≤ 4

with (4) = 0ݕ = (0)ݕ and = 4 subintervals.

SOLUTION

 Analytical Solution

The general solution of the second nonhomogeneous linear equation

ݕ

ᇱᇱ − ݕ (ݔ)ݎ =

can be expressed in the form

ݕ + ݕ =

The corresponding homogeneous equation ݕᇱᇱ − ݕ

= 0 has characteristic equation

ݎ

ଶ − 1 = 0

ݎ

ଶ = 1

ݎ

= ±1

Complementary solution

 = ଵݕభ௫ + ଶ

మ௫

= ݕ ଵ

௫ + ଶି௫

The nonhomogeneous equation has ݎ(ݔ) = ݔ(ݔ − ଶݔ = (4 − . It is a degree 2 polinomial. Weݔ4

will let   be a genetic quadratic polinomial:  =  ݔ

ଶ + ݔ  +  . It followsܥ   ݔ 2 = +   and

  = 2 . Substitute them into the equation

(2 

) − (ݔ 

ଶ +ݔ 

ଶݔ = ( − 4ݔ

−ݔ 

ଶ −ݔ  + (2 −

ܥ

ଶݔ = ( − ݔ4

The corresponding terms on both side should have the same coefficients, therefore, equating

the coefficients of like terms.

ݔ

ଶ :   −  = 1   = −1

ݔ :   − 

= −4   → 

= 4

1   :   2 −ܥ = 0   ܥ = −2

Therefore, = ଶݔ− + ݔ4 − 2 and ݕ + ݕ = = ଵ௫ + ଶ

ି௫ − ݔ

ଶ + ݔ4 − 2.

Page 2: Komputasi Sistem Fisis 3

8/19/2019 Komputasi Sistem Fisis 3

http://slidepdf.com/reader/full/komputasi-sistem-fisis-3 2/4

2

Boundary value conditions

ݕ

(4) = 0ݕ = (0)

For ݔ = 0   :   ଵ + ଶ

ି − (0)ଶ + (4)(0) − 2 = 0

ଵ + ଶ = 2

For ݔ = 4   :   ଵସ + ଶ

ିସ − (4)ଶ + (4)(4) − 2 = 0

ଵସ + ଶ

ିସ = 2

Substitute ଵ  = 2 − ଶ

(2 − ଶ) ସ + ଶିସ = 2

− ଶସ + ଶ

ିସ = 2 − 2 ସ

− ଶ( ସ − ିସ) = 2 − 2 ସ

ଶ =2 − 2 ସ

−( ସ − ିସ)

We obtain ଶ = 1,96403 and ଵ = 0,03597.

Thus, ݕ = 0,03597 ௫ + 1,96403 ି௫ −ݔ

ଶ + ݔ4 − 2.

Numerical Solution

We denote the numerical solution at any point ݔ by ݕ

ݕ

ᇱᇱ

−ݎ = ݕ

The two boundary value conditions are  = 0ݔ and . = 4ݔ

We also have = 4 and

ℎ =ݔ − ݔ

=4 − 0

4  = 1

Thus, we have five node points, they are , = 0ݔ ,ଵ = 1ݔ ,ଶ = 2ݔ ଷ = 3ݔ and ସ = 4ݔ .

We are given the data values  = 0ݕ = (ݔ)ݕ and ସ = 0ݕ = (ସݔ)ݕ

By using the approximations

 ݕ  =1

ℎଶ(ାଵݕ − + ݕ2 (ିଵݕ

=  ݕ1

(ାଵݕ − (ݕ

with

ℎ = 1

in the differential equation we obtain

(ାଵݕ − + ݕ2 (ିଵݕ −

ݎ = ݕ

ିଵݕ − 2ݕ − + ݕ = ାଵݕ

ݎ 

ିଵݕ − + ݕ3 ݎ = ାଵݕ

For = 1,,ଵ = 1ݔ

 = 0ݕ   :  ݕ − 3

+ ଵݕ= ଶݕ

)ଵݔ ଵݔ − 4)

0 − + ଵݕ3 ݕ

ଶ = 1(1 − 4)

+ ଵݕ3− = ଶݕ −3

Page 3: Komputasi Sistem Fisis 3

8/19/2019 Komputasi Sistem Fisis 3

http://slidepdf.com/reader/full/komputasi-sistem-fisis-3 3/4

3

For = 2, ଶ = 2ݔ   :   ଵݕ − 3+ ଶݕ

= ଷݕ)ଶݔ 

ଶݔ − 4)

ଵݕ − + ଶݕ3 ଷ = 2(2ݕ − 4)

ଵݕ − 3+ ଶݕ

= ଷݕ −4

For = 3, ,ଷ = 3ݔ ସ = 0ݕ   :   ଶݕ − + ଷݕ3 )ଷݔ = ସݕଷݔ − 4)

ଶݕ − + ଷݕ3 0 = 3(3 − 4)

ଶݕ − 3= ଷݕ −3

We obtain the following system of equations

1 0 0 0 0

1   − 3 1 0 00 1   − 3 1 00 0 1   − 3 1

0 0 0 0 1   ⎦ ⎣

ݕ

0

ݕ

1

ݕ

2

ݕ

3

ݕ

4⎦

=

0

−3−4−3

0 ⎦

Or in a compact form as 

.

MATLAB Source Code

clc, clear   all

% NADYA AMALIA (20213042)

% COMPUTATIONAL PHYSICAL SYSTEMS

% DR.rer.nat. LINUS AMPANG PASASA

% FINITE-DIFFERENCE METHOD

% y"(x) - y(x) = r(x) , r(x)= x(x - 4)

% y(0)= alfa , y(l)= beta

% The definate of the global values

global   alfa beta h l;

% Problem Data

alfa = 0;

beta = 0;

l = 4 ;

n = 4 ;

h = l/n;

% Making of the vector b

b = zeros(n,1);

b(1) = 0

b(n+1) = 0

for   i = 2:n

b(i) = (i-1)*((i-1)-4)

end

% Making of the matrix A

A = zeros(n,n) ;

A(1,1) = 1

A(n+1,n+1) = 1

for   i = 2:n

A(i,i-1) = 1

A(i,i) = -3

A(i,i+1) = 1

end

% The solution of the system

y = A \ b ;

Page 4: Komputasi Sistem Fisis 3

8/19/2019 Komputasi Sistem Fisis 3

http://slidepdf.com/reader/full/komputasi-sistem-fisis-3 4/4

4

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;

From the calculation for numerical solution we obtain

=

0

1,85714

2,57143

1,85714

0   ⎦

Thus,

,(1) = 1,85714ݕ = ଵݕ

= ଶݕݕ 

(2) = 2,57143, and

(3) = 1,85714ݕ = ଷݕ

0 0.5 1 1.5 2 2.5 3 3.5 40

0.5

1

1.5

2

2.5

3Plotting of analytical solution of y"(x) - y(x) = x(x - 4)

x

     y       (     x       )     =

       0 ,

       0       3       5       9       7      e     x

      +

       1 ,

       9       6       4       0       3      e

       (   -     x       )   -     x

       2

      +

       4     x

   -       2

0 0.5 1 1.5 2 2.5 3 3.5 40

0.5

1

1.5

2

2.5

3Plotting of numerical solution of y"(x) - y(x) = x(x - 4) using Finite-Difference Method

interval [0,4]

     y       i