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 - 199 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

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

Bild der Seite - 199 -

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

Text der Seite - 199 -

7.7 Exercises 199 3. x0 =1andx1 =2.3 4. x0 =1andx1 =2.4 Filename:secant_failure.*. Exercise7.3:UnderstandWhythe BisectionMethod CannotFail Solve the same problem as in Exercise 7.1, using the bisection method, but let the initial interval be [−5,3]. Report how the interval containing the solution evolves during the iterations. Filename:bisection_nonfailure.*. Exercise7.4:Combine the BisectionMethod withNewton’sMethod Anattractiveideais tocombinethereliabilityofthebisectionmethodwiththespeed of Newton’s method. Such a combination is implemented by running the bisection method until we have a narrow interval, and then switch to Newton’s method for speed. Writeafunctionthat implementsthisidea.Startwithaninterval[a,b]andswitch toNewton’smethodwhenthecurrent interval in thebisectionmethodisa fractions oftheinitial interval(i.e.,whentheintervalhaslengths(b−a)).Potentialdivergence of Newton’s method is still an issue, so if the approximate root jumps out of the narrowed interval (where the solution is known to lie), one can switch back to the bisection method.The value of smust be givenas an argument to the function,but itmayhaveadefaultvalueof0.1. Try thenewmethodon tanh(x)=0withan initial interval [−10,15]. Filename:bisection_Newton.py. Exercise7.5:WriteaTest FunctionforNewton’sMethod The purpose of this function is to verify the implementation of Newton’s method in theNewton functionin thefilenonlinear_solvers.py.Constructanalgebraic equationandperformtwo iterationsofNewton’smethodbyhandorwith theaidof SymPy. Find the corresponding size of |f(x)| and use this as value forepswhen callingNewton.Thefunctionshould thenalsoperformtwoiterationsandreturn the sameapproximationto therootasyoucalculatedmanually. Implement this idea for aunit test asa test functiontest_Newton(). Filename:test_Newton.py. Exercise7.6:Halley’sMethodand theDecimal Module A nonlinearalgebraicequationf(x)= 0 may also be solvedby Halley’s method,7 givenas: xn+1 =xn− 2f(xn)f ′(xn) 2f ′(xn)2−f(xn)f ′′(xn), n=0,1,.. . , withsomestartingvaluex0. 7 http://mathworld.wolfram.com/HalleysMethod.html.
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