NSM 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

DI No.

:
Dr D Y PatilPratishthan’s
Dr. D. Y. Patil Institute of Engineering, Management and ACAD/DI/
Research, Akurdi, Pune
Academic Year: Unit 1. Roots of Equation Revision : 00
2022-2023 Dated :
Term –I Department of Mechanical Engineering Date of Preparation :

Name of Kush Tilgule


Student
Roll Call TME20248
Program Name Program of Bisection Method
Question Find the root of Equation x*x*x-2*x-5 using
Bisection Method. Take Accuracy upto 3 decimal
places.Take Initial Guess as 2 and 3.
Code #20248 Kush Tilgule def
f(x):
return x*x*x -2*x-5
a=eval(input('Enter value of a:'))
b=eval(input('Enter value of b:'))
acc=eval(input('Enter value of accuracy:'))
i=1 if (f(a)*f(b)>=0):
print("Initial Guess are not correct") else:
print("int","root")
while (abs(a-b)>=acc):
c=(a+b)/2 prod =
f(a)*f(c) if prod>
0: a=c
i=i+1 else:
b=c i=i+1
print(i-1,c) print("Value of
root is ",c)

Output Enter value of a:2


Enter value of b:3
Enter value of accuracy:0.001
int root 1 2.5
2 2.25
3 2.125
6 2.109375
7 2.1015625
8 2.09765625
9 2.095703125
10 2.0947265625
Value of root is 2.0947265625

Solver Output ans =

2.2790187861665933688471
Flowchart(Paste
Photo of
Flowchart)
DI No.:
Dr D Y PatilPratishthan’s
Dr. D. Y. Patil Institute of Engineering, Management and ACAD/DI/
Research, Akurdi, Pune
Academic Year: Unit 1. Roots of Equation Revision : 00
2022-2023 Dated :
Term –I Department of Mechanical Engineering Date of Preparation :

Name of Student Kush Tilgule

Roll Call TME20248

rogram Name Program of Newton Raphson Method

Question Find the root of Equation x*x*x-2*x-5 using Newton Raphson


Method. Take Accuracy upto 3 decimal places.Take Initial
Guess as 2.

Code #Kush Tilgule


#20248
def f(x):
return x*x*x -2*x-5
def df(x):
return 3*x*x-
2 def ddf(x):
return 6*x
x0=eval(input('Enter value of x0'))
acc=eval(input('Enter value of
accuracy')) i=1 if
((((f(x0)*ddf(x0))/((df(x0))^2)))>=1):
print("Initial Guess are not correct")
else:
print("int","root")
x1=x0-(f(x0)/df(x0))
while (abs(x1-x0)>=acc):
x0=x1
x1=x0-(f(x0)/df(x0))
i=i+1 print(i-1,x1)

Output Enter value of x02


Enter value of accuracy0.00000001
int root
1 2.094568121104185
2 2.094551481698199
3 2.0945514815423265

Solver Output ans =

2.2790187861665933688471
Flowchart(Paste
Photo of
Flowchart)
DI No.:
Dr D Y PatilPratishthan’s
Dr. D. Y. Patil Institute of Engineering, Management and ACAD/DI/
Research, Akurdi, Pune
Academic Year: Unit 1. Roots of Equation Revision : 00
2022-2023 Dated :
Term –I Department of Mechanical Engineering Date of Preparation :

Name of Student Kush Tilgule

Roll Call TME20248

Program Name Program of Succesive Approximation Method

Question Find the root of Equation exp(x)-5.x using Bisection Method.


Take Accuracy upto 3 decimal places. Take Initial Guess as 0

Code #Kush Tilgule


#20248
import math
def
f(x):
return math.exp(x)-5*x def
g(x):
return (math.exp(x)/5) def
dg(x):
return (math.exp(x)/5)
x0=eval(input('Enter value of x0'))
acc=eval(input('Enter value of
accuracy')) i=1 if((abs(dg(x0))>=1)):
print("Initial Guess are not correct") else:
print("int","root")
x1=g(x0) while (abs(x1-
x0)>=acc):
x0=x1
x1=g(x0) i=i+1
print(i-1,x1)

Output Enter value of x00


Enter value of accuracy0.0001
int root
1 0.24428055163203397
2 0.25534049224182814 3
0.2581802175712955
4 0.25891442044856716
5 0.25910458596251895
6 0.2591538634045623

Solver Output ans =

0.2591711018190737680911
Flowchart(Paste
Photo of
Flowchart)

You might also like