Professional Documents
Culture Documents
Numerical Method Final Hand Outs PDF
Numerical Method Final Hand Outs PDF
Chapter 1
NUMERICAL METHOD
Numerical method is an approach for solving complex mathematical problems using basic
arithmetic operation i.e. addition, subtraction, multiplication, division. Thus the numerical
method is the computational techniques which involves only a set of basic arithmetic operation
for solving any complex mathematical problem
Its major concern is to provide efficient and computer oriented solution of any physical problem
Errors
i) Inherent errors:
Errors which are already present in the statement of a problem before its solution are
called inherent errors.
Arises either due to the given data being approximate or due to limitation of
mathematical tables, calculations
Can be minimized by taking better data or by using precision computing aids
ii) Round off errors:
Round off errors occurs when a fixed number of digits are used to represent exact numbers.
Such as we represent the value of pi by 3.1416. There are two ways of rounding off a
number
a) Chopping
In chopping extra digits are dropped. Suppose we want to store a number 23.45678 in
computer with a fixed word length of four digits, then the number 23.45678 will be
stored as 23.45 and the digits 678 will be dropped
b) Symmetric rounding
in symmetric round off, the last retained significant digit is round up by 1 if the first
discarded digit is larger than or equal to 5,otherwise the last retained digit is unchanged
for example the number 23.45678 would become 23.46
x0+h y1 ∆ y0
2
∆ y-1
4
∆y1 ∆3y0
x0+2h y2 ∆2y1
∆y2
x0+3h y3
yp=y0+p + ∆2y-1 + + ∆4y-2 +
+….
bessel’s formula is given by
xi yi ∆yi ∆2yi ∆3yi ∆4yi ∆5yi ∆6yi ∆7yi
x0-3h y-3
∆y-3
x0-2h y-2 ∆2y-3
∆y-2 ∆3y-3
x0-h y-1 ∆ y-2
2
∆4y-3
∆y-1 ∆3y-2 ∆5y-3
x0 y0 ∆ y-1
2
∆ y-2
4
∆6y-3
∆y0 ∆3y-1 ∆5y-2 ∆7y-3
x0+h y1 ∆ y02
∆ y-1
4
∆ y-2
6
∆y1 ∆ y0
3
∆ y-1
5
+ ( )+ ∆5y-2
+ ( )+ ∆7y-3 …..……..
448
32 3992
We have
yp=y0+p∆y0 + + ∆3y-1
yp=3162+0.25*382+ + (-8)
=3250.875
Numerical differentiation formula
a)two point formula
f’(x)= or y’i=(yi+1-yi) /h (forward difference formula)
f’(x)= or y’i=(yi-yi-1)/h (backward difference formula)
f’(x)= or y’i=(yi+1-yi-1) /2h (central difference formula)
b)three point formula
f’(x)= ( forward difference formula)
If B2 is also not equal to B, then process may be continued until we obtain the correct estimate of
y(b) however the procedure can be accelerated by using and improved guess for z(a) M3 as given
by following formula
Or M3=M2+ (B-B2)
Here M1,M2,B1,B2,B all are known so we can easily calculate M3 with this z(a)=M3 we can
obtain the solution of y
Summary: step1 let z(a)=M1 and find y(b) (let y(b)=B1)
Step2 let z(a)=M2 and find y(b) (let y(b)=B2)
Step3 calulate z(a)=M3=M2+ (B-B2) and find y(b) with z(a)=M3
Prepared by Ajay Lama
6
Q) Using shooting method, solve the equation y’’=6x with y(1)=2 and y(2)=9 by taking step
size 0.5 and with the help of modified eulers method
Sol n, Let y’=z then y’’=z’ =6x
Now y’=f(x,y,z)=z and z’=g(x,y,z)=6x
Step1: x0=1,y0=2,z0=M1=2(guess)
Solution for y (m=y’=f(x,y,x)=z) Solution for z (l=z’=g(x,y,z)=6x)
m1=f(x0,y0,z0)=2 l1=g(x0,y0,z0)=6
m2=f(x0+h,y0+m1*h,z0+l1*h)=5 l2=g(x0+h,y0+m1*h,z0+l1*h)=9
m=(m1+m2)/2=3.5 l=(l1+l2)/2=7.5
y1=y(1.5)=y0+m*h=3.75 z1=z(1.5)=z0+l*h=5.75
m1=f(x1,y1,z1)=5.75 l1=g(x1,y1,z1)=9
m2=f(x1+h,y1+m1*h,z1+l1*h)=10.25 l2=g(x1+h,y1+m1*h,z1+l1*h)=12
m=(m1+m2)/2=8 l=(l1+l2)/2=10.5
y2=y(2)=y1+m*h=7.75 z2=z(2)=z1+l*h
Therefore B1=7.75(<9)
Step2: x0=1,y0=2,z0=M2=4(guess)
Solution for y (m=y’=f(x,y,x)=z) Solution for z (l=z’=g(x,y,z)=6x)
m1=f(x0,y0,z0)=4 l1=g(x0,y0,z0)=6
m2=f(x0+h,y0+m1*h,z0+l1*h)=7 l2=g(x0+h,y0+m1*h,z0+l1*h)=9
m=(m1+m2)/2=5.5 l=(l1+l2)/2=7.5
y1=y(1.5)=y0+m*h=4.75 z1=z(1.5)=z0+l*h=7.75
m1=f(x1,y1,z1)=7.75 l1=g(x1,y1,z1)=9
m2=f(x1+h,y1+m1*h,z1+l1*h)=12.25 l2=g(x1+h,y1+m1*h,z1+l1*h)=12
m=(m1+m2)/2=10 l=(l1+l2)/2=10.5
y2=y(2)=y1+m*h=9.75 z2=z(2)=z1+l*h
Therefore B2=9.75(>9)
lagrange interpolation
step1:Input order of polynomial (n) // n+1 data create n order polynomial
step2:Input all data (xi,yi) ,i=0 to n
step3:Input value of x at which functional value is unknown (xun)
step4:calculate f(xun)=
where Li(xun)=
step5:print f(xun)
Least square method
Step1:Input number of data (n)
Step 2:Input all data (xi,yi),x2
Step 3:Calculate ,
Step 4:calculate a=
b=
step 5: print y=a+bx
Pseudo code
1.Bisetion Method
Input f(x),e
Repeat
Input x1 and x2
till f(x1)*f(x2)>0
Repeat
x0=(x1+x2)/2
if f(x1)*f(x0)<0 assign x2=x0
else assign x1=x0
till |x2-x1|>e (Or till |f(x0)|>e )// write any one in your pseudo code
print root=x0
2.Regula Falsi method:
Input f(x),e
L1: Input x1 and x2
If(f(x1)*f(x2)>0)goto L1
Repeat
x0={f(x2)*x1-f(x1)*x2}/{f(x2)-f(x1)}
if f(x1)*f(x0)<0 assign x2=x0
else assign x1=x0
till |x2-x1|>e (Or till |f(x0)|>e) //write any one in your pseudo code
print root=x0
3.Secant Method
Input: f(x), e1,x1 and x2 //e1 is error
L1: Set x3= {f(x2)*x1-f(x1)*x2}/{f(x2)-f(x1)}
Assign x1=x2 and x2=x3
If( | f(x3)| >e1) goto L1 (or |x2−x1| >e1) //write any one in your pseudo code
Display roor= x3
4.Newton Raphson
Define f(x) and f’(x)
Input e and x0
Repeat
x1=x0-f(x0)/f’(x0)
error=|x1-x0|
assign x0=x1
till error>e (Or till |f(x0)|>e) //write any one in your pseudo code
5.Newton Raphson(two equation method)
Define f(x,y) ,g(x,y) ,f1(x,y),f2(x,y),g1(x,y),g2(x,y) and error(e)
Input initial guesses (x0,y0)
Repeat D=f1(x0,y0)*g2(x0,y0)-g1(x0,y0)*f2(x0,y0)//D= , Dx= Dy=
Dx=f(x0,y0)*g2(x0,y0)-g(x0,y0)*f2(x0,y0)
Dy=f1(x0,y0)*g(x0,y0)-g1(x0,y0)*f(x0,y0)
x1=x0-Dx/D
y1=y0-Dy/D
error_x=|x1-x0|
error_y=|y1-y0|
Prepared by Ajay Lama
11
8. Jacobi method
Define error e
Input number of equation (n) and augmented matrix aij
for i=1,2,3..n
set xi=ai,n+1/aii
Prepared by Ajay Lama
12
for i=2,3..n
if (|eigenvalue|<|yi|) set eigenvalue=yi
emax=0
for i=1,2,3…n
if(|xi-yi/|eigenvalue||>emax
emax= |xi-yi/|eigenvalue||
xi=yi/|eigenvalue|
end for i
if emax>e go to L1
print eigenvalue and eigen vector xi
11.Lagrange Interpolation
Input E
Input n and all data (xi,yi)
Input point at which value is unknown (xx)
Sum=0
For i=0 to n updating i by 1 repeat
Mul=1
For j=0 to n updating j by 1 repeat
If i≠j , mul=mul*(xx-xi)/(xi-xj)
End for j
Sum=sum+yi*mul
End for i
Print result=sum
12 .least square method
input number of data (n)
input all data (xi,yi)
for i=1to n updating i by 1 repeat
sumx=sumx+xi
sumy=sumy+yi
sumxy=sumxy+xi*yi
sumx2=sumx2+xi*xi
end for i
a=
b=
print result y=a+bx
sum=sum+f(a)+f(b)
I=sum*h/3
print integration =I