Professional Documents
Culture Documents
Uio PDF
Uio PDF
On
NUMRICAL METHODS
By
T K RAJAN
SELN GRADE LECTURER IN MATHEMATICS
GOVT VICTORIA COLLEGE PALAKKAD
ALGORITHM
Step 1: Read the number of numbers as n
Step 2: If n<1 , then
Write Incorrect input
Goto step 1
Endif
Step 3: For i=1 to n
Read a(i)
Step 4: For i=1 to n
Step 5:
Step 6:
For j=i+1 to n
If (a(i) > a(j) )then
t=a(i)
a (i)=a(j)
a(j)=t
Endif
BISECTION METHOD
Find a root of the equation x^2-5x+6 using bisection method.
ALGORITHM
EULERS METHOD
Solve the differential equation dy/dx = (y-x)/y+x) at x = 0 .1 using Eulers method in five
steps. Given y(0) = 1
ALGORITHM
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
:
:
:
:
:
:
:
FIBONACCI NUMBERS
Write a program to
first
eight
ALGORITHM
Step 1: f1=1
f2=2
Step 2: Read the number of terms to be displayed
Step 3: If n=1
then
write f1
Else
write f1,f2
Step 4: For i=3 to n
f3=f1+f2
write f3
f1=f2
f2=f3
Step 5: Stop
fibonacci
numbers.
Step 5 :
Step 6 :
step 7 :
step 8 :
step 9
step 10 :
step 11 :
step 12 :
step 13 :
step 14 :
step 15 :
step 16 :
step 17 :
step 18 :
Step 19:
Step 1
Step 2
Step 3
Step 4
:
:
:
:
Step 5 :
Step 6 :
Step 7 :
Step 8 :
Step 9 :
Step 10 :
Step 11 :
Step 12 :
Step 13 :
Step 14 :
Step 15 :
Step 16 :
ALGORITHM
Step 1:
Read a,b two numbers for which gcd and lcm is to be found.
Step 2:
m=a, n=b
Step 3:
If a>b , then
j=a
a=b
b=j
endif
Step 4:
i=mod(b,a)
Step 5:
If (i = 0) , then
Write a
else
b=a
a=i
go to step 4
endif
Step 6:
l=m*n/a
Step 7:
write l
Step 8:
Stop
Find the value of the function at x=5 using Lagrange interpolation method, the value
of x and the corresponding function values are given below.
-3
30
132
ALGORITHM
Step 1:
Step 2:
For i=1 to n
read x(i),y(i)
Step 3:
Step 4:
s=0
Step 5:
For i=1 to n
p=1
Step 6:
For j=1 to n
Step 7:
If (i ! = j ) then
p=p*(a-x(j))/(x(i)-x(j))
Endif
Step 8:
s=s+p*y(i)
Step 9:
Write a,s
Step 10:
Stop
METHOD OF TRIANGULARISATION
Solve the system of equations by method of triangularisation.
x+3y+8z=4
x+4y+3z=2
x+3y+4z=1
ALGORITHM
Step1:
Step2:
Step3:
Step4:
Step5:
Step6:
Step7:
Step8:
Step9:
Step10:
Step11:
Step12:
Step13:
Step14:
Step15:
Step16:
Step17:
Step18:
Step19:
y
2
1
4
ALGORITHM
Step 1: Read n, the number of known function values
Step 2: For i=1 to n
Read x(i),y(i,1)
Step 3:
Step 4:
k=0
Step 5:
For j=2 to n
k=k+1
Step 6:
Step 7:
For i=1 to n
write x(i)
Step 8:
Step 9:
s=y(1,1)
Step10:
For j=2 to n
p=1
Step11:
Step 12:
Write s
Step13:
Stop
NUMERICAL DIFFERENTIATION
Find the value of the derivative of a function at the point x=0.22 using numerical
differentiation. The
value of x and the corresponding
x
y
function values are
given below.
0.15
0.1761
0.21
0.3222
0.23
0.3617
0.27
0.4314
0.32
0.5051
0.35
0.5441
ALGORITHM
Step1:
Step2:
For i=1 to n
Read x(i) , y(i,1)
Step3:
Step4:
For j=2 to n
Step5:
Step6:
v=y(1,2)
Step7:
For i=3 to n
s=0
Step8:
Step9:
Step10: Print v
Step11: Stop
2
4
9
5
8
4
7
3
6
2
ALGORITHM
Step 1:
Step 2:
If (n != p)Then
WriteMatrices are not conformable for multiplication
Go to Step 12
Step 3:
Step 4:
For i=1 to m
For j=1 to n
Read a(i,j)
Step 5:
Step 6:
For i=1 to p
For j=1 to q
Read b(i,j)
Step 7:
Step 8:
For i=1 to m
For j=1 to q
c(i,j)=0
Step 9:
For k=1 to n
c(i,j)=c(i,j)+a(i,k)*b(k,j)
Step10:
Step 11:
For i=1 to m
For j=1 to q
write c(i,j)
Step 12:
Stop
2
4
9
5
8
4
7
3
6
2
ALGORITHM
Step 1:
Step 2:
If (n != p)Then
WriteMatrices are not conformable for multiplication
Go to Step 12
Step 3:
Step 4:
For i=1 to m
For j=1 to n
Read a(i,j)
Step 5:
Step 6:
For i=1 to p
For j=1 to q
Read b(i,j)
Step 7:
Step 8:
For i=1 to m
For j=1 to q
c(i,j)=0
Step 9:
For k=1 to n
c(i,j)=c(i,j)+a(i,k)*b(k,j)
Step10:
Step 11:
For i=1 to m
For j=1 to q
write c(i,j)
Step 12:
Stop
ALGORITHM
Step 1:
Step 2:
Step 3:
Step 4:
count=0
Step 5:
h=(a-x1)/n
Step 6:
write x1,y1
Step 7:
s1=f(x1,y1)
Step 8:
s2=f(x1+h/2,y1+s1*h/2)
Step 9:
s3=f(x1+h/2,y1+s2*h/2)
Step 10:
s4=f(x1+h,y1+s3*h)
Step 11:
y2=y1+(s1+2*s2+2*s3+s4)*h/6
Step 12:
x2=x1+h
Step 13:
write x2,y2
Step 14:
count=count+1
Step 15:
If count<n . then
x1=x2
y1=y2
go to step step 7
endif
Step 16:
write x2,y2
Step 17:
Stop
Step 2:
Step 3:
Step 4:
count=0
Step 5:
h=(a-x1)/n
Step 6:
write x1,y1
Step 7:
k1=h*f(x1,y1)
Step 8:
k2=h*f(x1+h,y1+k1)
Step 9:
y2=y1+(k1+k2)/2
SIMPSONS
RULE OF INTEGRATION
ALGORITHM
Step 1 :
Step 2 :
Step 3 :
h=(b-a)/n
Step 4 :
x=a
Step 5 :
y=f(x)
Step 6 :
sum=y
Step 7 :
For i=2 to n
x=x+h
y=f(x)
Step 8:
If mod(i,2)=0 then
sum=sum+4*y
Step 9:
Else
sum=sum+2*y
Endif
Step 10:
x=x+h
Step 11:
y=f(x)
Step 12:
sum=sum+y
Step 13:
sum=h*sum/3
Step 14:
write sum
Step 15:
Stop
TRAPEZOIDAL RULE
To find the value of the integral of the function 1/1+x^2 in 4 steps using
Trapezoidal rule.
ALGORITHM
Step 1 : Read a , b the limits of integration
Step 2 :
If b<a then
c=a
a=b
b=c
Step 3:
Step 4:
h=b-a/n
Step 5:
x=a
y=f(x)
sum=y
Step 6:
If
else
x=x+h
y=f(x)
sum=sum+y
endif
Step 7:
sum=h*sum/2
Step 8:
write sum
Step 9:
Stop