Skip to content

Commit 791a0be

Browse files
committed
adding more explanations on formulas
1 parent 9f48fa0 commit 791a0be

File tree

1 file changed

+47
-8
lines changed

1 file changed

+47
-8
lines changed

lectures/newton_method.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import jax.numpy as jnp
4949
plt.rcParams["figure.figsize"] = (10, 5.7)
5050
```
5151

52-
## One-dimensional Fixed Point Computation Using Newton's Method
52+
## Fixed Point Computation Using Newton's Method
5353

5454
(solow)=
5555
### The Solow Model
@@ -61,6 +61,15 @@ Assuming Cobb-Douglas production technology, the law of motion for capital is
6161
k_{t+1} = sAk_t^\alpha + (1-\delta) k_t
6262
```
6363

64+
where
65+
- $k_t$ is capital stock per worker,
66+
- $A, \alpha>0$ are production parameters, $\alpha<1$
67+
- $s>0$ is a savings rate, and
68+
- $\delta \in(0,1)$ is a rate of depreciation
69+
70+
In this example, we will try to calculate the fixed point for the law of motion for capital.
71+
72+
6473
Since we will use these parameters in many functions for this example, let's store our parameters in [`namedtuple`](https://docs.python.org/3/library/collections.html#collections.namedtuple) to help us keep our code clean and concise.
6574

6675
```{code-cell} python3
@@ -181,7 +190,23 @@ k_star
181190

182191
#### Newton's Method
183192

184-
To find the fixed point of a scalar function $g$, Newton's method iterates on
193+
To implement Newton's method, we propose an initial value $x_0$ as fixed point, and then iterate towards the a point where $x_t = g(x_{t-1})$.
194+
195+
To begin with, we know that
196+
197+
```{math}
198+
:label: motivation
199+
200+
\hat{g}(x) \approx g\left(x_0\right)+g^{\prime}\left(x_0\right)\left(x-x_0\right)
201+
```
202+
203+
Setting $\hat{g}(x_1) = x_1$ and solve for $x_1$ to get
204+
205+
$$
206+
x_1=\frac{g\left(x_0\right)-g^{\prime}\left(x_0\right) x_0}{1-g^{\prime}\left(x_0\right)}
207+
$$
208+
209+
Generalising the process above, Newton's method iterates on
185210

186211
```{math}
187212
:label: newtons_method
@@ -258,7 +283,21 @@ We can see that Newton's Method reaches convergence faster than the successive a
258283

259284
The above fixed-point calculation can be seen as a root-finding problem since the computation of a fixed point can be seen as approximating $x^*$ iteratively such that $g(x^*) - x^* = 0$.
260285

261-
For one-dimensional root-finding problems, Newton's method iterates on:
286+
Therefore, assuming $f(x) = g(x) - x$, we can rewrite the formula [](motivation) to
287+
288+
$$
289+
\hat{f}(x) \approx f\left(x_0\right)+f^{\prime}\left(x_0\right)\left(x-x_0\right)
290+
$$
291+
292+
293+
Setting $\hat{f}(x_1) = 0$ and solve for $x_1$ to get
294+
295+
$$
296+
x_1 = x_0 - \frac{ f(x_0) }{ f'(x_0) },
297+
\qquad x_0 \text{ given}
298+
$$
299+
300+
Therefore, generalizing the formula above, for one-dimensional root-finding problems, Newton's method iterates on
262301

263302
```{math}
264303
:label: oneD-newton
@@ -267,17 +306,17 @@ x_{t+1} = x_t - \frac{ g(x_t) }{ g'(x_t) },
267306
\qquad x_0 \text{ given}
268307
```
269308

270-
Root-finding formula is also a more frequently used form of Newton's method.
309+
Root-finding formula is also a more frequently used iteration.
271310

272311
The following code implements the iteration
273312

274313
(first_newton_attempt)=
275314
```{code-cell} python3
276-
def newton(g, Dg, x_0, tol, params=params, maxIter=10):
315+
def newton(f, Df, x_0, tol, params=params, maxIter=10):
277316
x = x_0
278317
279318
# Implement the root-finding formula
280-
iteration = lambda x, params: x - g(x, params)/Dg(x, params)
319+
iteration = lambda x, params: x - f(x, params)/Df(x, params)
281320
282321
error = tol + 1
283322
n = 0
@@ -296,8 +335,8 @@ def newton(g, Dg, x_0, tol, params=params, maxIter=10):
296335
```{code-cell} python3
297336
# Apply our transformation
298337
k_star_approx_newton = newton(
299-
g=lambda x, params: g(x, params) - x,
300-
Dg=lambda x, params: Dg(x, params) - 1,
338+
f=lambda x, params: g(x, params) - x,
339+
Df=lambda x, params: Dg(x, params) - 1,
301340
x_0=0.8,
302341
tol=1e-7)
303342
```

0 commit comments

Comments
 (0)