Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - 180 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 180 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - 180 -

Bild der Seite - 180 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 180 -

180 7 SolvingNonlinearAlgebraicEquations # Return x and y values return [(x[i], y[i]) for i in minima], \ [(x[i], y[i]) for i in maxima] Themaxandmin functionsare standardPythonfunctionsforfinding themaximum andminimumelementofa listoranobject thatonecan iterateoverwitha for loop. Anapplication tof(x)= e−x2 cos(4x) looks like def demo(): from numpy import exp, cos minima, maxima = brute_force_optimizer( lambda x: exp(-x**2)*cos(4*x), 0, 4, 1001) print(’Minima:\n’, minima) print(’Maxima:\n’, maxima) Runningtheprogramgives Minima: [(0.70000000000000007, -0.5772302750838405), (2.1520000000000001, -0.0066704807422565023), (3.6600000000000001, -7.3338267339366542e-07)] Maxima: [(1.4159999999999999, 0.10965467991643564), (2.8999999999999999, 0.00012651823896373234), (0.0, 1.0)] 7.1.3 ModelProblemforAlgebraicEquations We shall consider the very simple problem of finding the square root of 9. That is, we want to solve x2 = 9, but will (for simplicity) seek only the positive solution. Knowingthesolutionbeforehand,allowsus toeasily investigatehowthenumerical method (and the implementation of it) performs in the search for a solution. The f(x) function thatcorrespondsto the equationx2 =9 is f(x)=x2−9 . Ourintervalof interest forsolutionswillbe [0,1000](theupperlimithereischosen somewhatarbitrarily). In the following,wewillpresent severalefficientandaccuratemethodsfor solv- ing nonlinear algebraic equations, both single equation and systems of equations. The methods all have in common that they search for approximate solutions. The methodsdiffer,however, in the way theyperformthesearch for solutions.The idea for the search influences the efficiency of the search and the reliability of actually findingasolution.Forexample,Newton’smethodisveryfast,butnotreliable,while thebisectionmethod is the slowest, butabsolutely reliable.Nomethod isbest at all problems,so weneeddifferentmethodsfordifferentproblems.
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python 3.6
Band
Second Edition
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2020
Sprache
englisch
Lizenz
CC BY 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
356
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python