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

NMO Solver Final 228

The document outlines various numerical methods and optimization techniques, including the Bisection Method, Newton-Raphson Method, and methods for solving simultaneous equations such as Gauss Elimination and Thomas algorithm. It also covers numerical integration techniques like the Trapezoidal rule and Simpson's rules, as well as curve fitting and interpolation methods. Additionally, it includes programs for solving ordinary differential equations using Euler and Runge-Kutta methods.

Uploaded by

nehaskumbhar11
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)
4 views

NMO Solver Final 228

The document outlines various numerical methods and optimization techniques, including the Bisection Method, Newton-Raphson Method, and methods for solving simultaneous equations such as Gauss Elimination and Thomas algorithm. It also covers numerical integration techniques like the Trapezoidal rule and Simpson's rules, as well as curve fitting and interpolation methods. Additionally, it includes programs for solving ordinary differential equations using Euler and Runge-Kutta methods.

Uploaded by

nehaskumbhar11
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/ 14

Name = Vanamala Tanaji Pawar

PRN = 123B2G231

Subject = Numerical Method and Optimization (Solver)

Batch = C4
Date = 16/05/2025

2. Programme on roots of equation

a) Bisection Method b) Newton Raphson Method

f = inline('x^3+x^2-100')

f=

Inline function:

f(x) = x^3+x^2-100

>> root = fzero(f, 0)

root =

2.706

3. Program on Simultaneous Equations

a) Gauss Elimination Method

>> A = [1 1 1; 1 2 3; 1 4 9]

A=

1 1 1
1 2 3
1 4 9
>> B = [3; 4; 6]

B=

>> X=A\B

X=

b) Thomas algorithm for tridiagonal matrix

>> A = [1 2 0; 2 3 1; 0 2 -1]

A=

1 2 0

2 3 1
0 2 -1

>> B = [3; 4; 1]

B=
3

>> X = A\B

X=

-1

-3

c) Gauss-Seidel method
A = [2 -3 20; 3 -20 -1; 20 1 -2]

A=

2 -3 20
3 -20 -1
20 1 -2

>> B = [25; -18; 17]

B=

25

-18
17

>> X=A\B
X=

0.9316
0.9746

1.3030

4. Program on Numerical Integration


a) Trapezoidal rule b) Simpson’s Rules 1/3rd c) Simpson’s Rules 3/8th

>> f = inline('exp(-x.^2)')

f=

Inline function:
f(x) = exp(-x.^2)

>> area = quad(f, 0, 1)

area =

0.8468

5. Program on Curve Fitting using Least square technique

a) Straight line

X = [0 1 2 3 4]

X=

0 1 2 3 4
>> Y = [1 1.8 3.3 4.5 6.3]

Y=

1.0000 1.8000 3.3000 4.5000 6.3000

>> p = polyfit(X, Y, 1)

p=

1.3300 0.7200

>> plot(X,Y)

b) Power equation

>> x=[1 2 3 4 5 6 ]

x=

123456

>> y=[2.98 4.26 5.12 6.1 6.8 7.5 ]

y=
2.9800 4.2600 5.1200 6.1000 6.8000 7.5000

>> plot(x,y)

c) Exponential equation

>> x=[0 2 4 ]

x=

0 2 4

>> y=[5.102 10 31.62]

y=

5.1020 10.0000 31.6200


>> plot(x,y)

d) Quadratic equation

>> x = [10 20 30 40 60 50]

x=

10 20 30 40 60 50

>> y = [157 179 210 252 302 361]

y=

157 179 210 252 302 361


>> plot(x,y)

6. Program on Interpolation
a) Lagrange’s Interpolation

>> x = [5 7 11 13 17]

x=

5 7 11 13 17

>> y = [150 392 1452 2366 5202]

y=

150 392 1452 2366 5202


>> yg = interp1(x,y,9,'spline')

yg =

810

b) Newton’s Forward interpolation

>> x = [0 2 4 6 8]

x=

0 2 4 6 8

>> y = [5 29 125 341 725]

y=

5 29 125 341 725

>> yg = interp1(x,y,1.2,'spline')

yg =

13.4480

7. Program on ODE

a) Euler Method
>> f = inline('x*log(y)-y*log(x)')

f=
Inline function:

f(x,y) = x*log(y)-y*log(x)

>> y = ode45(f,[1 1.6], 1)

y=

1.0000

1.0150

1.0300

1.0450
1.0600

1.0750

1.0900

1.1050

1.1200

1.1350

1.1500
1.1650

1.1800

1.1950

1.2100

1.2250

1.2400

1.2550
1.2700

1.2850

1.3000
1.3150

1.3300

1.3450

1.3600
1.3750

1.3900

1.4050

1.4200

1.4350

1.4500

1.4650

1.4800
1.4950

1.5100

1.5250

1.5400

1.5550

1.5700

1.5850
1.6000

a.1) Modified Euler Method

>> f = inline('x*log(y)-y*log(x)')

f=

Inline function:
f(x,y) = x*log(y)-y*log(x)

>> [x,y] = ode23(f,[1 1.6], 1)


x=

1.0000
1.0600

1.1200

1.1800

1.2400

1.3000

1.3600

1.4200

1.4800
1.5400

1.6000

y=

1.0000

0.9982

0.9928
0.9837

0.9709

0.9542

0.9335

0.9084

0.8787

0.8439
0.8034

b) Runge-Kutta Methods- Second order & fourth-order

>> f = inline('x+y')
f=

Inline function:
f(x,y) = x+y

>> [x,y] = ode23(f,[0 0.1], 1)

x=

0.0100
0.0200

0.0300

0.0400

0.0500

0.0600

0.0700

0.0800
0.0900

0.1000

y=

1.0000

1.0101
1.0204

1.0309

1.0416
1.0525

1.0637

1.0750

1.0866
1.0983

1.1103

You might also like