Академический Документы
Профессиональный Документы
Культура Документы
FINAL EXAMINATION
LECTURER: Prof. SUN Heming
SUBMITTED BY:
IWAN MUHAMMAD SYARIEFUDIN (马伊万)
Student Category : Masters in College of Hydrology and Water Resources
Student No: M2015101
Email : m2015101@hhu.edu.cn
Use a fixed-point iteration method to determine a solution accurate to within 10-2 for
Solving ;
a. X = g (x) = - -
b. X = arc sin ( ) + 2
n (a) (b)
0 1 1
1 1,634887662 1,833333333
2 1,619134377 1,630869246
3 1,625036752 1,696498005
4 1,622854573 1,677657062
5 1,623665437 1,683240993
For X = g (x) = - - ;
Use appropriate Lagrange interpolating polynomials of degrees one, two and three to
approximate each of the following :
Solve :
x f (x )
X0 -0,75 -0,07181250
X1 -0,5 -0,02475000
X2 -0,25 0,33493750
X3 0 1,10100000
( ) ( ) (( ) –( )) (( ) –( ))
P1 (x) = * f(x1) + * f(x2) = * (-0,024750) + * (0,33493750)
( ) ( ) (( ) ( )) (( ) ( ))
= 0,21504167
( )( ) ( )( ) ( )( )
P2 (x) = ( )( )
* f(x0) + ( )( )
* f(x1) + ( )( )
* f(x2)
(( ) –( ))(( ) –( )) (( ) –( ))(( ) –( ))
= * (-0,0718125) + * (-0,024750)
(( ) ( ))(( ) –( )) (( ) ( ))(( ) –( ))
(( )–( ))(( ) –( ))
+ (( ) ( ))(( ) –( ))
* (0,33493750)
= 0,16988889
( )( )( ) ( )( )( ) ( )( )( )
P3 (x) = ( )( )( )
* f(x0) + ( )( )( )
* f(x1) + ( )( )( )
* f(x2)
( )( )( )
+ ( )( )( )
* f(x3)
(( ) –( ))(( ) –( ))(( )– )
+ * (-0,024750)
(( ) ( ))(( )–( ))(( ) )
= 0,17451852
∫ , n =4
To solve the problem, I’m using MATLAB program. And this is the source code:
clear;
clc;
f= @(x) x.*(log(x));
a=1;
b=2;
n=4;
if ( rem(n,2) ~= 0 )
disp
return
end
h = (b-a)/n;
x = linspace ( a, b, n+1 );
for i = 1:n+1
fx(i) = feval ( f, x(i) );
end
w = [ 1 zeros(1,n-1) 1 ];
w(2:2:n) = 4*ones(1,n/2);
w(3:2:n-1) = 2*ones(1,n/2-1);
if ( nargout == 1 )
y = (h/3) * sum ( w .* fx );
else
disp ( (h/3) * sum ( w .* fx ) );
end
Use the Runge-Kutta for System Algorithm to approximate the solutions of the following higher-
order differential equations, and compare the result to the actual solutions.
Solving :
k1,3 = h f 3(t0 , w1,0 , w2,0 , w3,0) = h [ et0 + 2*w1,0 + w2,0 - 2*w3,0 ] = 1.0000
wi , j = w i , j + ( k1 , i + 2 k 2 , i + 2k 3 , i + k 4 , i )
This isthe result
Solving :
F(x1, x2, x3) = ( f1(x1, x2, x3) , f2(x1, x2, x3) , f3(x1, x2, x3))t
3 2
f1(x1, x2, x3) = x1 + x1 x2 - x1x3 + 6
f2(x1, x2, x3) = + - x3
f3(x1, x2, x3) = x22 - 2x1x3 - 4
6 1 1
0,367879441 0,135335283 -1
J ( x(0 ) =
-2 -4 2
-1,6821556
y (0) = -0,682156 and x(1) = x(0) + y(0) =
-1,5142772
0,4857228
0,3347072
-0,665293
Thus , at the k step, here the solution :
x1 -1
x(0) x2 -2
x3 1
f1 (x1 , x2 , x3) 4
(0)
F(x ) f2 (x1 , x2 , x3) -0,49678528
f3 (x1 , x2 , x3) 2
6 1 1,00000000
-2 -4 2
x1 -1,68215563
x(1) x2 -1,51427723
x3 0,33470721
f1 (x1 , x2 , x3) -2,48174886
F(x(1)) f2 (x1 , x2 , x3) 0,07123256
f3 (x1 , x2 , x3) -0,58090523
x1 -1,45584109
x(3) x2 -1,66405796
x3 0,42205387
f1 (x1 , x2 , x3) 0,00190068
F(x(3)) f2 (x1 , x2 , x3) 0,00051924
f3 (x1 , x2 , x3) -0,00202439
The results using this iterative procedure are shown in Table below :
k x1 x2 x3
0 -1 -2 1
To solve the problem, I’m using MATLAB program. And this is the source code:
clear;
clc;
a=1.0;
b=2.0;
alpha=-1/2;
beta=log(2);
h=0.05;
N=((b-a)/h)-1;
for i=1:N
x=a+i*h;
A(i,i)=2+h^2*fungQ(x);
end
for i=1:N-1
x=a+i*h;
A(i,i+1)=-1+((h/2)*fungP(x));
end
for i=2:N
x=a+i*h;
A(i,i-1)=-1-((h/2)*fungP(x));
end
A
x=a+h;
b(1,1)=-h^2*fungR(x)+(1+((h/2)*fungP(x)))*alpha;
for i=2:8
x=a+i*h;
b(i,1)=-h^2*fungR(x);
end
xN=a+N*h;
b(N,1)=-h^2*fungR(xN)+(1-((h/2)*fungP(xN)))*beta;
b
for i=1:N
A(i,N+1)=b(i,1);
end
A
for j=1:N-1
if A(j,j)==0
for p=1:N+1
u=A(j,p);
v=A(j+1,p);
A(j+1,p)=u;
A(j,p)=v;
end
end
jj=j+1;
for i=jj:N
m=A(i,j)/A(j,j);
for k=1:(N+1)
A(i,k)=A(i,k)-(m*A(j,k));
end
end
end
x(N,1)=A(N,N+1)/A(N,N);
for i=N-1:-1:1
S=0;
for j=N:-1:i+1
S=S+A(i,j)*x(j,1);
end
x(i,1)=(A(i,N+1)-S)/A(i,i)
end
w=x
and this is the source code for the function of fungP(x), fungQ(x) and fungR(x) :
fungP(x) :
function y = fungP(x)
y = -4/x;
fungQ(x) :
function y = fungQ(x)
y = 2/x.^2;
fungQ(x) :
function y = fungR(x)
y = (-2/x.^2)*log(x);
And this is the result :
x(i) w(i)
1.00 -0.5000
1.05 -0.3165
1.10 -0.1664
1.15 -0.0424
1.20 0.0612
1.25 0.1485
1.30 0.2226
1.35 0.2860
1.40 0.3406
1.45 0.3880
1.50 0.4301
1.55 0.4678
1.60 0.5019
1.65 0.5329
1.70 0.5613
1.75 0.5874
1.80 0.6116
1.85 0.6342
1.90 0.6553
1.95 0.6752
2.00 ln(2) = 0.693147
7. P 715 no. 1(b)
Approximate the solution to the following partial differential equation using the Backward
Difference Algorithm.
= 0, 0 x 1 , 0 t ;
u(0 , t) = u(1 , t) = 0, 0 t ,
u(x , 0) = 2 sin 2 x , 0 x 1
-( )
and compare your result to the actual solution u(x , t) = 2 sin 2 x
To solve the problem, I’m using MATLAB program. And this is the source code:
clear;
clc;
n=2;
m=3;
l=1;
N=2;
t=0.1;
alpha=1/4;
k=t/N;
h=l/m;
lambda=(alpha^2)*k/(h^2);
for i=1:n
eq(i)=2*sin(2*pi*i*h);
end
for i=1:n
w0(i,1)=eq(i);
end
A=AA;
for i=1:n
A(i,n+1)=w0(i,1);
end
for j=1:(n-1)
if (A(j,j)==0)
for p=1:n+1
u=A(j,p);
v=A(j+1,p);
A(j+1,p)=u;
A(j,p)=v;
end
end
jj=j+1;
for i=jj:n
m=A(i,j)/A(j,j);
for k=1:(n+1)
A(i,k)=A(i,k)-(m*A(j,k));
end
end
end
w(n,1)=A(n,n+1)/A(n,n);
for i=n-1:-1:1
S=0;
for j=n:-1:i+1
S=S+A(i,j) *w(j,1);
end
w(i,1)=(A(i,n+1)-S)/A(i,i);
end
w0=w;
end
w
The results listed in Table below which illustrates the stability of this method