0% found this document useful (0 votes)
49 views

Algorithm Newton Raphson Method: Ik KK

The document describes several numerical analysis algorithms: 1. Newton-Raphson method finds the root of a function iteratively by using the tangent line of the function. 2. Gaussian elimination solves systems of linear equations by transforming the matrix into row echelon form. 3. Gauss-Jordan method extends Gaussian elimination to compute the inverse and determinant of a matrix. 4. Interpolation methods like Lagrange, Newton divided differences, and Newton forward interpolation find polynomial functions that pass through given data points.

Uploaded by

Andrew Jackson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Algorithm Newton Raphson Method: Ik KK

The document describes several numerical analysis algorithms: 1. Newton-Raphson method finds the root of a function iteratively by using the tangent line of the function. 2. Gaussian elimination solves systems of linear equations by transforming the matrix into row echelon form. 3. Gauss-Jordan method extends Gaussian elimination to compute the inverse and determinant of a matrix. 4. Interpolation methods like Lagrange, Newton divided differences, and Newton forward interpolation find polynomial functions that pass through given data points.

Uploaded by

Andrew Jackson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Algorithm

Newton raphson method

• Input initial guess a , stopping criteria e and define function.


• Find f(a),f’(a)
• Check if f’(a)=0 then display root diverged
• b= a-f(a)/f’(a)
• if abs(b-a)<e then root =b
• else b=a go to step 4.
• Stop

Gauss elimination method

X+y+z=3(A03)

2x-4y+3z=1(A13)

3x+5y-2z=6 (A23)

• Input number of equations n.(n=3)


• Input the coefficients in augmented form for i=0,n-1 & j=0to n
• Repeat for k=0 to n-2(0-1)
Repeat for i=k+1 to n-1(1-2)
Compute ratio R=aik / akk (r=2/1)
Repeat for j=k to n(0-3)
aij = aij – R* akj (aij=2-2*1=0)
• Compute last element xn-1 = an-1,n / an-1,n-1 (back substitution method)(x2=a2,3/a2,2)
• Repeat for k= n-2 to 0(1-0)
Set s=0
Repeat for j=k+1 to n-1(2-2)
S=s+ akj * xj (s=0+a12*x2)
Xk = (akn –s)/akk
• Display xk for k= 0 to n-1
• stop

Gauss Jordan method

• Input number of equations n.


• Input the coefficients in augmented form for i=0,n-1 & j=0to n
• Repeat for k=0 to n-1(0-2)
Repeat for i =0 to n (0-3)
Compute ratio R=aik / akk
Repeat for j=0 to n(0-3)
If(i!=j)
aij = aij – R* akj
• Repeat for k= 0 to n
Xk = ak,n / ak,k (x0=A03/A00)
• Display xk for k= 0 to n-1
• Stop

Gauss seidel algorithm

• Start
• Declare the variables and read the order of the matrix n
• Read the stopping criteria er
• Read the coefficients aim as
repeat for i=1 to n
repeat for j=1 to n
Read a[i][j]
Repeat for j
Repeat for i
• Read the coefficients b[i] for i=1 to n
• Initialize x0[i] = 0 for i=1 to n
• Set key=0
o For i=1 to n
Set sum = b[i]
For j=1 to n
If (j not equal to i)
Set sum = sum – a[i][j] * x0[j]
Repeat j
x[i] = sum/a[i][i]
If absolute value of ((x[i] – x0[i]) / x[i]) > er, then
Set key = 1
Set x0[i] = x[i]
Repeat i
• If key = 1, then
Goto step 6
Otherwise print results
• stop
Lagrange’s Interpolation

1 2 4 5 6 8
1 10 46 73 106 190
Pn(x)= f(x0)L0(x) + f(x1)L1(x) + f(x2)L2(x) + f(x3)L3(x) +………+ f(xn)Ln(x)
n
Pn(x)= ∑ f(xi)Li(x)
i=0
Where
n
Li(x) = ∏ (x-xi)/(xi-xj)
j=0,i≠j
• Input number of points as n (n=6)
• Enter the elements as (xi,yi)Pair for i=0 to n-1(x0-x5,y0-y5)
• Enter the interpolating point xp (xp=3)
• Set s=0
• Repeat for i=0 to n-1(i=0-5)
Set l=1
Repeat for j=0 to n-1(j=0-5)
If (j not equal to i)
Compute l=l*(xp-xj)/ (xi-xj) {l=1*(3-2)/(1-2)}
Compute s=s+l*yi (s=0+l*1)
• Output s
• Stop

Newton divided difference interpolation

f(x)= F[x0] +(x-x0) F[x0,x1]+ (x-x0) (x-x1) F[x0,x1,x2]+ (x-x0) (x-x1) (x-x2) F[x0,x1,x2,x3]+………+
(x-x0) (x-x1) (x-x2)……. (x-xn-1) F[x0,x1,x2,x3,……,xn]

• Input number of points as n


• Enter the elements as (xi,yi)Pair for i=0 to n-1
• Enter the interpolating point xp
• Compute the first column matrix dij
Repeat for i=0 to n-1
di,0 =yi (d00=y0, d10=y1, d20=y2, d30=y3, d40=y4, d50=y5)
o Repeat for i=0 to n-1 (i=0-5)
Repeat for j=1 to n-i-1(j=1-5-i)
Compute dij = (di+1,j-1 - di,j-1)/(xi+j -xi) (d01 = (d1,0 – d0,0)/(x1 –x0))
o Repeat for i=0 to n-1
Compute ai =d0i
o Set s=0
o Repeat for i=0 to n-1
P=1
Repeat for j=0 to i-1
P= p* (xp - xj)
S=s + ai * p
o Display s
o Stop

Newton forward interpolation

Programs

Lab 1

1.bisection method 2. secant method 3. N-R method

Lab 2

Gauss elimination, gauss Jordan, gauss seidel

Lab 3

Lagrange interpolation , Newton Divided difference interpolation ,Newton forward interpolation

Lab 4

Numerical differentiation {central formula for f’(x) and f”(x)}

Numerical Integration (trapezoidal, Simpson’s 1/3 and simpson’s 3/8)

Lab 5

You might also like