I have been given a project, I need to show the use of a version of Newton's method to solve these non-linear equations. The version of Newton's method I am required to use is: $ X_{n+1} = X_n - J^{(-1)} F(X_n) $. I have all the values required here, and this works to find the point $ X_1 $. However I need to find a code that inputs the following points $ X_2, X_3, ..., X_n $ automatically. Here are the given values:
f[x_, y_] := x^2 + y^2 - 5;
g[x_, y_] := x^3 - y^3 - 7;
x0 = 2.1;
y0 = 0.9;
f[x0, y0]
g[x0, y0]
0.22
1.532
M = {{2*x0, 2*y0}, {3*x0^2, -3*y0^2}}
{{4.2, 1.8}, {13.23, -2.43}}
J = Inverse[M]
{{0.0714286, 0.0529101}, {0.388889, -0.123457}}
F0 = {{f[x0, y0]}, {g[x0, y0]}}
X0 = {{x0}, {y0}}
X1 = X0 - J.F0
{{0.22}, {1.532}}
{{2.1}, {0.9}}
{{2.00323}, {1.00358}}
Thank you in Advance!
FixedPoint
andFixedPointList
and their optionSameTest
.Nest(List)
andNestWhile(List)
also come to mind. You can also useFindRoot
which has all this built-in. $\endgroup$FindRoot
: TryReap[FindRoot[Sin[x] == 0.2, {x, Pi/42}, EvaluationMonitor :> Sow[x]]]
. Btw.: UsingLinearSolve
instead ofInverse
should be faster for larger systems and should prevent certain problems with precision loss. $\endgroup$