SlideShare a Scribd company logo
1 of 35
Department of Computer Science
Gujarat University
Presentation
on
Finding Roots of Equations by Numerical Methods
& Calculate Avg. Time
Prepared By :
Rajan Thakkar (10017)
Parth Karkar (10013)
Dhyanesh Bhanderi (10005)
M.sc.(Artificial Intelligence & Machine Learning)
Under the Guidance of :
Dr. Savita Gandhi
Introduction to Numerical Methods
▪ The determination of the roots of an equation is one of the oldest problems in
mathematics & there have been many efforts in this regard.
▪ We learned numerical methods for finding roots of an equations. They represent
the values of x that make f(X) equal to zero.
▪ Thus, we can define the roots of an equation as the value of an equation as the
value of x that makes f(x) = 0.
▪ Roots are sometime called the zeros of equation. Root
F(x)=0
Introduction to Numerical Methods
1. Bracketing Methods (Need two initial
estimates that will bracket the root.
Always converge.)
a. Bisection Method
b. False-Position Method
1. Open Methods (Need one or two initial
estimates. May diverge.)
a. Newton-Raphson Method (Needs
the derivative of the function.)
b. Secant Method
Objectives
▪ Find solutions of Non-Liner equation and Liner Equation (User can Input)
▪ Derive the formula and follow the algorithms for the solutions of equations using
the following methods:
1. Bisection
2. False-Position
3. Secant
4. Newton-Raphson
▪ Average time Take by all the method in python as well as c++ So, we can predict
the performance.
▪ Graphical representation for better understand
Problem Statement
▪ Write a Python program to find the roots of an equation of any non-liner , liner
equation & use four different methods and find the root plus find the average
time taken by each method.(Menu driven Program )
 User will also input the first and second point.
 Also user can do new equation in the program.
 Output is view as Tabular format.
 Graphical representation of Four numerical method
 We also create c++ program for checking which language evaluation is faster.
 Note:- we also use the Kotlin Language which is use to create a mobile application so, we create a mobile application and run
all four method and also check the evaluation time
Bisection Method Algorithm
1. Start.
2. Define function f(X).
3. Choose initial guesses x0 and x1 such that f(x0)f(x1)<0.
4. Choose pre specified tolerable error e.(0.0001->4 significant digit)
5. Calculate new approximated root as x2 = (x0 + x1)/2
6. Calculate f(x0)f(x2)
a. if f(x0)f(x2) < 0 then x0 = x0 and x1 = x2
b. if f(x0)f(x2) > 0 then x0 = x2 and x1 = x1
c. if f(x0)f(x2) = 0 then go to (8)
7. if |f(x2)| > e then go to (5) otherwise go to (8)
8. Display x2 as root
9. Stop
False-Position Method Algorithm
1. Start
2. Define function f(x)
3. Choose initial guesses x0 and x1 such that f(x0)f(x1) < 0
4. Choose pre-specified tolerable error e.
5. Calculate new approximated root as:
x2 = x1 * f(x2) – x2*f(x1) / f(x2) – f(x1)
6. Calculate f(x0)f(x2)
a. if f(x0)f(x2) < 0 then x0 = x0 and x1 = x2
b. if f(x0)f(x2) > 0 then x0 = x2 and x1 = x1
c. if f(x0)f(x2) = 0 then go to (8)
7. if |f(x2)|>e then go to (5) otherwise go to (8)
8. Display x2 as root.
9. Stop
Secant Method Algorithm
1. Start
2. Define function as f(x)
3. Input initial guesses (x0 and x1), tolerable error (e) and maximum iteration (N)
4. Initialize iteration counter i = 1
5. If f(x0) = f(x1) then print "Mathematical Error" and go to (11) otherwise go to (6)
6. Calculate x2 = x1 - (x1-x0) * f(x1) / ( f(x1) - f(x0) )
7. Increment iteration counter i = i + 1
8. If i >= N then print "Not Convergent" and goto (11) otherwise goto (9)
9. If |f(x2)| > e then set x0 = x1, x1 = x2 and goto (5) otherwise goto (10)
10. Print root as x2
11. Stop
Newton Raphson Method Algorithm
1. Start
2. Define function as f(x)
3. Define first derivative of f(x) as g(x)
4. Input initial guess (x0), tolerable error (e) and maximum iteration (N
5. Initialize iteration counter i = 1
6. If g(x0) = 0 then print "Mathematical Error" and goto (12) otherwise goto (7)
7. Calculate x1 = x0 - f(x0) / g(x0)
8. Increment iteration counter i = i + 1
9. If i >= N then print "Not Convergent" and go to (12) otherwise go to (10)
10. If |f(x1)| > e then set x0 = x1 and go to (6) otherwise go to (11)
11. Print root as x1
12. Stop
Time Module
▪ Time Module to calculate the execution time of every method every iteration
and after calculate average of all iteration of every method.
▪ We use perf_counter() method to calculate the time.
▪ Basically it will work like counter when we start function than we called this function
and when function over then we store value of end time.
▪ Than we difference two of them and we find the total time take by that function
import time
start_time = time.perf_counter()
if f(x1) * f(x2) < 0.0:
...
else:
…
end_time = time.perf_counter()
diff=end_time - start_time
print(f"Execution Time is : {diff:0.6f} seconds")
Graph Plotting
import matplotlib.pyplot as plt
matplotlib library which have pyplot module so that we can use graph in python
def graph(ls):
plt.plot(*zip(*sorted(ls.items())))
# sorted() sorted by key, return a list of tuples
# Zip() unpack a list of pairs into two tuples
# items() Function show keys and values
#Spines are the lines connecting the axis tick marks and noting the boundaries of the data area.
ax.spines['right'].set_position('center')
Graph Plotting
ax.set_ylim([-20, 20])
#ylim() Function. The ylim() function in pyplot module of
#matplotlib library is used to get or set the y-limits of the current axes
plt.title('Numerical Methods ')
plt.show() #Show() use for display the graph
Above is the function which have one argument that is dictionary (ls) which have new point as key
and their point’s function evolution as value.
ls = dict()
ls.update({x3:f(fu,x3)}) so, this is the way to show the graph of each of the numerical method
Input Screen (which user can give an equation)
Menu For Different operation
OUTPUT FOR BISECTION METHOD
ENTER NEW COEFFICIENT
OUTPUT FOR FALSE POSITION METHOD
OUTPUT FOR SECANT METHOD
OUTPUT FOR NEWTON RAPHSON METHOD
RESULT(FOR AVERAGE TIMING)
Graph Bisection
X Axis – new Iteration value
Y Axis - F(x) where x = new iteration value
Graph False Position Method
X Axis – new Iteration value
Y Axis - F(x) where x = new iteration value
Graph Secant Method
X Axis – new Iteration value
Y Axis - F(x) where x = new iteration value
Graph Newton Raphson Method
X Axis – new Iteration value
Y Axis - F(x) where x = new iteration value
Kotlin Application Output (App)
Comparisons between C++ & Python & Kotlin (App)
(Time Wise)
x*x*x+x*x+x+1
x1=8
x2=-3 0.0001
Python C++ Kotlin(App)
Bisection 0.004 0.073 0.050016
False Position 0.327 0.521 0.133367
Secant 0.0035 0.023 0.009437
Newton
Raphson 0.098 0.047 0.026898
0.004
0.327
0.0035
0.098
0.073
0.521
0.023
0.047
0.050016
0.133367
0.009437
0.026898
0
0.1
0.2
0.3
0.4
0.5
0.6
Bisection False Position Secant Newton Raphson
Time Wise Compare
Python C++ Kotlin
Comparisons between C++ & Python
(Time Wise)
▪ 1
0.076627
0.499501
0.047569
0.352328
0.157
1.186
0.141
0.093
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Bisection False potion Secant Newton
Eqution X^3 + X^2 + X +7
Initial Guess a=-8 b=3
python cpp
Comparisons between C++ & Python
(Time Wise)
▪ 2
0.036425
0.028661
0.022824
0.158344
0.069
0.084
0.068 0.068
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0.16
0.18
Bisection False potion Secant Newton
Eqution X^2 + 2*x -4
Initial Guess a=1 b=2
python cpp
Comparisons between C++ & Python
(Time Wise)
▪ 3
0.048465
0.020706 0.017874
0.152216
0.131
0.1
0.078
0.062
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0.16
Bisection False potion Secant Newton
Eqution sin(x) - 3*x
Initial Guess a=-1 b=2
python cpp
Comparisons between C++ & Python
(Time Wise) avg. of above 3
▪ 4
0.053839
0.182956
0.029422
0.220962
0.119
0.456
0.956
0.074
0
0.2
0.4
0.6
0.8
1
1.2
Bisection False potion Secant Newton
3 Equation Compare x axis- Method
y axis- Time (sec)
Python C++
Comparisons of iteration for each method
▪ ITERATION
19
15
12
106
6 5
11
3 4
7
3 3
0
20
40
60
80
100
120
X^3 + x^2 +x +7 Sin(x) - 3*x X*x +2*x -4
bisection false-position secant newton
CONCLUSION
▪ FROM ABOVE OBSERVATIONS WE CONCLUDE THAT AVERAGE TIME TAKEN
BY THE SECANT METHOD IS LESS AMONG ALL THE METHOD (IN PYTHON).
▪ AND AVERAGE TIME TAKEN BY THE NEWTON RAPSHON MATHOD IS LESS
AMONG THE ALL METHOD (IN C++).
▪ AND AVERAGE TIME TAKEN BY PYTHON IS LESS THEN THE C++.
▪ PYTHON IS FASTER THEN C++ TO SOLVE THE NUMARICAL METHODS.
▪ ALSO WE CAN CONCLUDE THAT NEWTON RAPSHON METHOD HAVE LESS
ITERATION IN BOTH PYTHON AND C++.
Future Details
1. Using Django, we can also put this method online or create webpage.
2. Automatically Take an initial guess of method.
3. Use ML algorithm or method to solve an equation
References
▪ https://www.codesansar.com/numerical-methods/ (1)
▪ Introductory methods of numerical analysis , Sastry, S.S. , , PHI Learning
Private Limited ,2015 (2)
▪ https://www.epythonguru.com/2019/12/how-to-find-derivatives-in-
python.html (3)
THANK YOU

More Related Content

What's hot

Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocamlpramode_ce
 
Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)stasimus
 
N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...Philip Schwarz
 
Scala. Introduction to FP. Monads
Scala. Introduction to FP. MonadsScala. Introduction to FP. Monads
Scala. Introduction to FP. MonadsKirill Kozlov
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsPhilip Schwarz
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...Philip Schwarz
 
Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingSaurabh Singh
 
Monoids - Part 2 - with examples using Scalaz and Cats
Monoids - Part 2 - with examples using Scalaz and CatsMonoids - Part 2 - with examples using Scalaz and Cats
Monoids - Part 2 - with examples using Scalaz and CatsPhilip Schwarz
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]vikram mahendra
 

What's hot (20)

Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
 
Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)
 
Algorithms DM
Algorithms DMAlgorithms DM
Algorithms DM
 
statistics assignment help
statistics assignment helpstatistics assignment help
statistics assignment help
 
N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for fun and profit - Haskell and...
 
Scala. Introduction to FP. Monads
Scala. Introduction to FP. MonadsScala. Introduction to FP. Monads
Scala. Introduction to FP. Monads
 
Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
 
Array
ArrayArray
Array
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
 
White box-sol
White box-solWhite box-sol
White box-sol
 
Lec3
Lec3Lec3
Lec3
 
Ch5(loops)
Ch5(loops)Ch5(loops)
Ch5(loops)
 
Ch3
Ch3Ch3
Ch3
 
Ch4
Ch4Ch4
Ch4
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
 
Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional Programming
 
Monoids - Part 2 - with examples using Scalaz and Cats
Monoids - Part 2 - with examples using Scalaz and CatsMonoids - Part 2 - with examples using Scalaz and Cats
Monoids - Part 2 - with examples using Scalaz and Cats
 
Lec1
Lec1Lec1
Lec1
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
DATA TYPE IN PYTHON
DATA TYPE IN PYTHONDATA TYPE IN PYTHON
DATA TYPE IN PYTHON
 

Similar to Finding root of equation (numarical method)

Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxjovannyflex
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxjovannyflex
 
Numerical differentation with c
Numerical differentation with cNumerical differentation with c
Numerical differentation with cYagya Dev Bhardwaj
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
Machine Learning - Introduction to Tensorflow
Machine Learning - Introduction to TensorflowMachine Learning - Introduction to Tensorflow
Machine Learning - Introduction to TensorflowAndrew Ferlitsch
 
Excel macro for solving a polynomial equation
Excel macro for solving a polynomial equationExcel macro for solving a polynomial equation
Excel macro for solving a polynomial equationUpendra Lele
 
Столпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай МозговойСтолпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай МозговойSigma Software
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxSALU18
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2Mohamed Ahmed
 
Introduction to comp.physics ch 3.pdf
Introduction to comp.physics ch 3.pdfIntroduction to comp.physics ch 3.pdf
Introduction to comp.physics ch 3.pdfJifarRaya
 
Introduction to Functions
Introduction to FunctionsIntroduction to Functions
Introduction to FunctionsMelanie Loslo
 
Why Haskell Matters
Why Haskell MattersWhy Haskell Matters
Why Haskell Mattersromanandreg
 
Module II Partition and Generating Function (2).ppt
Module II Partition and Generating Function (2).pptModule II Partition and Generating Function (2).ppt
Module II Partition and Generating Function (2).pptssuser26e219
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningBig_Data_Ukraine
 
Advance data structure & algorithm
Advance data structure & algorithmAdvance data structure & algorithm
Advance data structure & algorithmK Hari Shankar
 

Similar to Finding root of equation (numarical method) (20)

Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Numerical differentation with c
Numerical differentation with cNumerical differentation with c
Numerical differentation with c
 
Monadologie
MonadologieMonadologie
Monadologie
 
PythonOOP
PythonOOPPythonOOP
PythonOOP
 
Machine Learning - Introduction to Tensorflow
Machine Learning - Introduction to TensorflowMachine Learning - Introduction to Tensorflow
Machine Learning - Introduction to Tensorflow
 
Excel macro for solving a polynomial equation
Excel macro for solving a polynomial equationExcel macro for solving a polynomial equation
Excel macro for solving a polynomial equation
 
Mutation @ Spotify
Mutation @ Spotify Mutation @ Spotify
Mutation @ Spotify
 
10. Recursion
10. Recursion10. Recursion
10. Recursion
 
Столпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай МозговойСтолпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай Мозговой
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2
 
Introduction to comp.physics ch 3.pdf
Introduction to comp.physics ch 3.pdfIntroduction to comp.physics ch 3.pdf
Introduction to comp.physics ch 3.pdf
 
Introduction to Functions
Introduction to FunctionsIntroduction to Functions
Introduction to Functions
 
Why Haskell Matters
Why Haskell MattersWhy Haskell Matters
Why Haskell Matters
 
Module II Partition and Generating Function (2).ppt
Module II Partition and Generating Function (2).pptModule II Partition and Generating Function (2).ppt
Module II Partition and Generating Function (2).ppt
 
Matlab1
Matlab1Matlab1
Matlab1
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Advance data structure & algorithm
Advance data structure & algorithmAdvance data structure & algorithm
Advance data structure & algorithm
 

Recently uploaded

Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxFurkanTasci3
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...limedy534
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...ThinkInnovation
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 

Recently uploaded (20)

Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptx
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 

Finding root of equation (numarical method)

  • 1. Department of Computer Science Gujarat University Presentation on Finding Roots of Equations by Numerical Methods & Calculate Avg. Time Prepared By : Rajan Thakkar (10017) Parth Karkar (10013) Dhyanesh Bhanderi (10005) M.sc.(Artificial Intelligence & Machine Learning) Under the Guidance of : Dr. Savita Gandhi
  • 2. Introduction to Numerical Methods ▪ The determination of the roots of an equation is one of the oldest problems in mathematics & there have been many efforts in this regard. ▪ We learned numerical methods for finding roots of an equations. They represent the values of x that make f(X) equal to zero. ▪ Thus, we can define the roots of an equation as the value of an equation as the value of x that makes f(x) = 0. ▪ Roots are sometime called the zeros of equation. Root F(x)=0
  • 3. Introduction to Numerical Methods 1. Bracketing Methods (Need two initial estimates that will bracket the root. Always converge.) a. Bisection Method b. False-Position Method 1. Open Methods (Need one or two initial estimates. May diverge.) a. Newton-Raphson Method (Needs the derivative of the function.) b. Secant Method
  • 4. Objectives ▪ Find solutions of Non-Liner equation and Liner Equation (User can Input) ▪ Derive the formula and follow the algorithms for the solutions of equations using the following methods: 1. Bisection 2. False-Position 3. Secant 4. Newton-Raphson ▪ Average time Take by all the method in python as well as c++ So, we can predict the performance. ▪ Graphical representation for better understand
  • 5. Problem Statement ▪ Write a Python program to find the roots of an equation of any non-liner , liner equation & use four different methods and find the root plus find the average time taken by each method.(Menu driven Program )  User will also input the first and second point.  Also user can do new equation in the program.  Output is view as Tabular format.  Graphical representation of Four numerical method  We also create c++ program for checking which language evaluation is faster.  Note:- we also use the Kotlin Language which is use to create a mobile application so, we create a mobile application and run all four method and also check the evaluation time
  • 6. Bisection Method Algorithm 1. Start. 2. Define function f(X). 3. Choose initial guesses x0 and x1 such that f(x0)f(x1)<0. 4. Choose pre specified tolerable error e.(0.0001->4 significant digit) 5. Calculate new approximated root as x2 = (x0 + x1)/2 6. Calculate f(x0)f(x2) a. if f(x0)f(x2) < 0 then x0 = x0 and x1 = x2 b. if f(x0)f(x2) > 0 then x0 = x2 and x1 = x1 c. if f(x0)f(x2) = 0 then go to (8) 7. if |f(x2)| > e then go to (5) otherwise go to (8) 8. Display x2 as root 9. Stop
  • 7. False-Position Method Algorithm 1. Start 2. Define function f(x) 3. Choose initial guesses x0 and x1 such that f(x0)f(x1) < 0 4. Choose pre-specified tolerable error e. 5. Calculate new approximated root as: x2 = x1 * f(x2) – x2*f(x1) / f(x2) – f(x1) 6. Calculate f(x0)f(x2) a. if f(x0)f(x2) < 0 then x0 = x0 and x1 = x2 b. if f(x0)f(x2) > 0 then x0 = x2 and x1 = x1 c. if f(x0)f(x2) = 0 then go to (8) 7. if |f(x2)|>e then go to (5) otherwise go to (8) 8. Display x2 as root. 9. Stop
  • 8. Secant Method Algorithm 1. Start 2. Define function as f(x) 3. Input initial guesses (x0 and x1), tolerable error (e) and maximum iteration (N) 4. Initialize iteration counter i = 1 5. If f(x0) = f(x1) then print "Mathematical Error" and go to (11) otherwise go to (6) 6. Calculate x2 = x1 - (x1-x0) * f(x1) / ( f(x1) - f(x0) ) 7. Increment iteration counter i = i + 1 8. If i >= N then print "Not Convergent" and goto (11) otherwise goto (9) 9. If |f(x2)| > e then set x0 = x1, x1 = x2 and goto (5) otherwise goto (10) 10. Print root as x2 11. Stop
  • 9. Newton Raphson Method Algorithm 1. Start 2. Define function as f(x) 3. Define first derivative of f(x) as g(x) 4. Input initial guess (x0), tolerable error (e) and maximum iteration (N 5. Initialize iteration counter i = 1 6. If g(x0) = 0 then print "Mathematical Error" and goto (12) otherwise goto (7) 7. Calculate x1 = x0 - f(x0) / g(x0) 8. Increment iteration counter i = i + 1 9. If i >= N then print "Not Convergent" and go to (12) otherwise go to (10) 10. If |f(x1)| > e then set x0 = x1 and go to (6) otherwise go to (11) 11. Print root as x1 12. Stop
  • 10. Time Module ▪ Time Module to calculate the execution time of every method every iteration and after calculate average of all iteration of every method. ▪ We use perf_counter() method to calculate the time. ▪ Basically it will work like counter when we start function than we called this function and when function over then we store value of end time. ▪ Than we difference two of them and we find the total time take by that function import time start_time = time.perf_counter() if f(x1) * f(x2) < 0.0: ... else: … end_time = time.perf_counter() diff=end_time - start_time print(f"Execution Time is : {diff:0.6f} seconds")
  • 11. Graph Plotting import matplotlib.pyplot as plt matplotlib library which have pyplot module so that we can use graph in python def graph(ls): plt.plot(*zip(*sorted(ls.items()))) # sorted() sorted by key, return a list of tuples # Zip() unpack a list of pairs into two tuples # items() Function show keys and values #Spines are the lines connecting the axis tick marks and noting the boundaries of the data area. ax.spines['right'].set_position('center')
  • 12. Graph Plotting ax.set_ylim([-20, 20]) #ylim() Function. The ylim() function in pyplot module of #matplotlib library is used to get or set the y-limits of the current axes plt.title('Numerical Methods ') plt.show() #Show() use for display the graph Above is the function which have one argument that is dictionary (ls) which have new point as key and their point’s function evolution as value. ls = dict() ls.update({x3:f(fu,x3)}) so, this is the way to show the graph of each of the numerical method
  • 13. Input Screen (which user can give an equation)
  • 14. Menu For Different operation
  • 17. OUTPUT FOR FALSE POSITION METHOD
  • 19. OUTPUT FOR NEWTON RAPHSON METHOD
  • 21. Graph Bisection X Axis – new Iteration value Y Axis - F(x) where x = new iteration value
  • 22. Graph False Position Method X Axis – new Iteration value Y Axis - F(x) where x = new iteration value
  • 23. Graph Secant Method X Axis – new Iteration value Y Axis - F(x) where x = new iteration value
  • 24. Graph Newton Raphson Method X Axis – new Iteration value Y Axis - F(x) where x = new iteration value
  • 26. Comparisons between C++ & Python & Kotlin (App) (Time Wise) x*x*x+x*x+x+1 x1=8 x2=-3 0.0001 Python C++ Kotlin(App) Bisection 0.004 0.073 0.050016 False Position 0.327 0.521 0.133367 Secant 0.0035 0.023 0.009437 Newton Raphson 0.098 0.047 0.026898 0.004 0.327 0.0035 0.098 0.073 0.521 0.023 0.047 0.050016 0.133367 0.009437 0.026898 0 0.1 0.2 0.3 0.4 0.5 0.6 Bisection False Position Secant Newton Raphson Time Wise Compare Python C++ Kotlin
  • 27. Comparisons between C++ & Python (Time Wise) ▪ 1 0.076627 0.499501 0.047569 0.352328 0.157 1.186 0.141 0.093 0 0.2 0.4 0.6 0.8 1 1.2 1.4 Bisection False potion Secant Newton Eqution X^3 + X^2 + X +7 Initial Guess a=-8 b=3 python cpp
  • 28. Comparisons between C++ & Python (Time Wise) ▪ 2 0.036425 0.028661 0.022824 0.158344 0.069 0.084 0.068 0.068 0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 Bisection False potion Secant Newton Eqution X^2 + 2*x -4 Initial Guess a=1 b=2 python cpp
  • 29. Comparisons between C++ & Python (Time Wise) ▪ 3 0.048465 0.020706 0.017874 0.152216 0.131 0.1 0.078 0.062 0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 Bisection False potion Secant Newton Eqution sin(x) - 3*x Initial Guess a=-1 b=2 python cpp
  • 30. Comparisons between C++ & Python (Time Wise) avg. of above 3 ▪ 4 0.053839 0.182956 0.029422 0.220962 0.119 0.456 0.956 0.074 0 0.2 0.4 0.6 0.8 1 1.2 Bisection False potion Secant Newton 3 Equation Compare x axis- Method y axis- Time (sec) Python C++
  • 31. Comparisons of iteration for each method ▪ ITERATION 19 15 12 106 6 5 11 3 4 7 3 3 0 20 40 60 80 100 120 X^3 + x^2 +x +7 Sin(x) - 3*x X*x +2*x -4 bisection false-position secant newton
  • 32. CONCLUSION ▪ FROM ABOVE OBSERVATIONS WE CONCLUDE THAT AVERAGE TIME TAKEN BY THE SECANT METHOD IS LESS AMONG ALL THE METHOD (IN PYTHON). ▪ AND AVERAGE TIME TAKEN BY THE NEWTON RAPSHON MATHOD IS LESS AMONG THE ALL METHOD (IN C++). ▪ AND AVERAGE TIME TAKEN BY PYTHON IS LESS THEN THE C++. ▪ PYTHON IS FASTER THEN C++ TO SOLVE THE NUMARICAL METHODS. ▪ ALSO WE CAN CONCLUDE THAT NEWTON RAPSHON METHOD HAVE LESS ITERATION IN BOTH PYTHON AND C++.
  • 33. Future Details 1. Using Django, we can also put this method online or create webpage. 2. Automatically Take an initial guess of method. 3. Use ML algorithm or method to solve an equation
  • 34. References ▪ https://www.codesansar.com/numerical-methods/ (1) ▪ Introductory methods of numerical analysis , Sastry, S.S. , , PHI Learning Private Limited ,2015 (2) ▪ https://www.epythonguru.com/2019/12/how-to-find-derivatives-in- python.html (3)