Seite - 204 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 204 -
Text der Seite - 204 -
204 6 SolvingNonlinearAlgebraicEquations
canbewritten inourabstract formby introducingx0 Dx andx1 Dy. Then
F0.x0;x1/Dx2 yCxcos. x/D0;
F1.x0;x1/DyxCe y x 1 D0:
6.6.2 TaylorExpansionsforMulti-VariableFunctions
Wefollowthe ideasofNewton’smethodforoneequation inonevariable: approxi-
mate thenonlinearf bya linear functionandfind the root of that function.When
nvariables are involved,weneed to approximate a vector function F.x/by some
linear function QF D JxCc,whereJ is ann nmatrix andc is somevector of
lengthn.
The technique for approximatingF by a linear function is to use the first two
terms in aTaylor series expansion. Given thevalueofF and its partial derivatives
with respect tox at some pointxi, we can approximate the value at some point
xiC1by the twofirst term inaTaylor seriesexpansionaroundxi:
F.xiC1/ F.xi/CrF.xi/.xiC1 xi/:
Thenext terms in theexpansionsareomittedhereandof size jjxiC1 xijj2,which
areassumed tobesmall comparedwith the two termsabove.
TheexpressionrF is thematrixof all thepartial derivativesofF . Component
.i;j/ inrF is
@Fi
@xj :
For example, in our2 2 system (6.11)-(6.12)we canuseSymPy to compute the
Jacobian:
>>> from sympy import *
>>> x0, x1 = symbols(’x0 x1’)
>>> F0 = x0**2 - x1 + x0*cos(pi*x0)
>>> F1 = x0*x1 + exp(-x1) - x0**(-1)
>>> diff(F0, x0)
-pi*x0*sin(pi*x0) + 2*x0 + cos(pi*x0)
>>> diff(F0, x1)
-1
>>> diff(F1, x0)
x1 + x0**(-2)
>>> diff(F1, x1)
x0 - exp(-x1)
Wecan thenwrite
rF D @F0
@x0 @F0
@x1
@F1
@x0 @F1
@x1 !
D 2x0Ccos. x0/ x0sin. x0/ 1
x1Cx 20 x0 e x1 !
ThematrixrF is called theJacobianofF andoftendenotedbyJ.
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2016
- Sprache
- englisch
- Lizenz
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 248
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik