numerical solution.docx
DESCRIPTION
numericalTRANSCRIPT
QUESTION ONEUse newtons interpolation divided difference formulae algorithm 3.2 to construct interpolation polynomial of degree one, two and three for the following data. Approximate the specific value using each of the polynomials of degree one, two and three for the following data. Approximate the specified value using each of polynomials.
Let
1st divided difference
2nd Divided difference
2rd Divided difference
QUESTION TWOThe composite Simpsons rule to approximate the integral use
SOLUTION
00.237425780.548311360-2.1932484-5.9356445-9.8696044
QUESTION THREEUse the Runge-Kutta for Systems Algorithm to approximate the solutions of the following higher-order differential equations, and compare the results to the actual solutions.
If
Question4Use S0R method with =1.2 to solve the linear system with a tolerance TOL= in the l 4x1-x2-x4`=0-x14x2-x3-x5=0-x24x3-x6=0-x14x4-x5=-6-x2-x44x5-x6=-2-x3-x5+4x6=6 AnswerUsing w= 1.2
Xi=(1-w)+For x
(1)
(2)
.(3)
(4)
(5)
(6)
kX1X2X3X4X5X6
0111111
10.42.020.7062.020.7122.0254
21.1321.8611.024721.94921.008282.00482
30.916662.0126981.00031141.9876420.9998921.9990970
41.016772.00255241.00043252.00747021.00275752.0011376
50.99965282.00034241.00035751.99922910.99966121.9997781
60.99994091.99991940.99983782.000034810.99998751.9999920
Checking for Error
Ans==4.0284 x
Hence TOL =is satisfied
5. Find the first two iterations of the SOR method with for the following linear systems:
Answer+ cos(x1x2)=0=G ()=X(K-1) J(x(k-1))-1 F(x(k-1))
Jacobi matrix is:
Using The iterative method produces the table belowk
022
11.9686825641.4789055410.521094459
21.7227713371.6422622570.245911227
31.7999277181.7519248330.109662576
41.7723831111.7711625500.027544607
51.7724556931.7724520381.89488 x
61.7724572051.7724504921.5460 x
71.7724538511.772453851
81.7724538511.7724538510
-And satisfies the error bound
Question6function [alpha,beta,gamma,delta]=finite_function(x,h)alpha=-1-(h/2)*p(x);beta=2+(h^2)*q(x);gamma=-1+(h/2)*p(x);delta=-(h^2)*r(x); function p=p(x)%p=-2/x; %Example 1/P663%p=-3; %11.3.3.a/P665%p=-4/x; %11.3.3.b/P665%p=-(x+1); %11.3.3.c/P665%p=1/x; %11.3.3.d/P665p=-(x+1); function q=q(x)%q=2/(x^2); %Example 1/P663 q=2; %11.3.3.a/P665 %q=2/(x^2); %11.3.3.b/P665 %q=2; %11.3.3.c/P665 %q=3/(x^2); %11.3.3.d/P665 function r=r(x)%r=sin(log(x))/(x^2); %Example 1/P663 r=2*x+3; %11.3.3.a/P665 %r=(-2/(x^2))*log(x); %11.3.3.b/P665 r=(1-x^2)*exp(-x); %11.3.3.c/P665 %r=(log(x)/x)-1; %11.3.3.d/P665 disp('Finite difference method for linear problems') clearformat long a=input('Input a=');b=input('Input b=');ya=input('Input y(a)=');yb=input('Input y(b)=');h=input('Input h='); NumberInterval_First=(b-a)/h;NumberInterval=fix(NumberInterval_First);if NumberInterval_First-NumberInterval==0 NumberUnknow=NumberInterval-1; Result_matrix=zeros(NumberInterval+1,2); Result_matrix(1,1)=a; Result_matrix(1,2)=ya; Result_matrix(NumberInterval+1,1)=b; Result_matrix(NumberInterval+1,2)=yb; %Result_matrix(1,3)=g(a); %Result_matrix(1,4)=abs( Result_matrix(1,3)-Result_matrix(1,2) ); %have not a,b in array x(i) x=zeros(1,NumberUnknow); for i=1:NumberUnknow x(i)=a+i*h; Result_matrix(i+1,1)=x(i); end A=zeros(NumberUnknow); b=zeros(NumberUnknow,1); for i=2:NumberUnknow-1 [A(i,i-1),A(i,i),A(i,i+1),b(i)]=finite_function(x(i),h); end [temp1,temp2,temp3,temp4]=finite_function(x(1),h); A(1,1)=temp2; A(1,2)=temp3; b(1)=b(1)+temp4+(-1)*temp1*ya; [temp1,temp2,temp3,temp4]=finite_function(x(NumberUnknow),h); A(NumberUnknow,NumberUnknow-1)=temp1; A(NumberUnknow,NumberUnknow)=temp2; b(NumberUnknow)=b(NumberUnknow)+temp4+(-1)*temp3*yb; solution_w=A\b; for i=1:NumberUnknow Result_matrix(i+1,2)=solution_w(i);% Result_matrix(i+1,3)=exact_func(x(i));% Result_matrix(i+1,4)=abs( Result_matrix(i+1,3)-Result_matrix(i+1,2) ); end else disp('h is not appropriate because [(b-a)/h] is not integer') end disp(' x(i) Finite_difference_w(i) ') Result_matrix % filename = 'Numerical_ass.xlsx';% xlswrite('Numerical_ass.xlsx',A)
>>finitediffFinite difference method for linear problemsInput a=0Input b=1Input y(a)=-1Input y(b)=0Input h=0.1 x(i) Finite_difference_w(i)
0 -1.000000000000000 0.100000000000000 -0.814229721703067 0.200000000000000 -0.654773599432834 0.300000000000000 -0.518308412475371 0.400000000000000 -0.401904443119574 0.500000000000000 -0.302980806647425 0.600000000000000 -0.219265711250556 0.700000000000000 -0.148761111240269 0.800000000000000 -0.089711275448616 0.900000000000000 -0.040574844868567 1.000000000000000 0QUESTION SEVENApproximate the solution to the following partial differential equations using the backward difference algorithm.
SOLUTION
becomes
becomes
Therefore from 1 substituting all these valueEquation1
Equation2
Equation3
Equation4
Equation5
Equation5
Equation6
Hence equation
So the backward substitution ijxiwwijU(xi,w)
110.50.050.632950.65204
211.00.050.895130.88394
311.50. 050.632950.62504
120.50.10.566570.55249
221.00.10.801260.78134
321.50.10.566570.55249