You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was reading through the newton_method lecture with codex and here are some potential updates.
I'd be grateful if you could take a look when you have a chance.
Overview
At lines 66–72, the descriptions use “the fixed point” and “the zero,” which can imply uniqueness. Use “a fixed point” and “a zero” instead.
Fixed-point computation using Newton's method
At line 123, specify that the savings rate satisfies $s \in (0,1)$, rather than only $s>0$.
At lines 283–291, define the linear approximation with equality:
$$
\hat g(x):=g(x_0)+g'(x_0)(x-x_0).
$$
At lines 293–306, state that the Newton update requires $1-g'(x_t)\neq 0$.
At lines 336–367, plot_trajectories relies on the global value of k_star, which may have been calculated from different parameters. Calculate k_star = exact_fixed_point(params) inside the function instead.
Root-finding in one dimension
[qe-writing-006] At line 378, change the heading from “Root-Finding in one dimension” to the sentence-case form “Root-finding in one dimension.”
At lines 397–405, define the linear approximation with equality:
$$
\hat f(x):=f(x_0)+f'(x_0)(x-x_0).
$$
At lines 405–418, state that each Newton update requires $f'(x_t)\neq 0$.
At line 460, correct “We can convert to this to a zero-finding problem” to “We can convert this to a zero-finding problem.”
Multivariate Newton's method
At lines 485–486, change “5,000 goods” to “3,000 goods” to match the code implementation later.
At line 492, change “A two-goods market equilibrium” to “A two-good market equilibrium.”
[qe-writing-001] At lines 513, 606, and 701, split each two-sentence paragraph so that it contains one sentence per paragraph.
At line 606, capitalize “Python.”
At lines 621–643, plot_excess_demand reads A, b, and c from mutable global state. Pass these parameters explicitly so that the two-good plots can still be rerun after the variables are reassigned for the 3,000-good example.
At line 624, update the mesh-grid comment from combinations of p_1 and p_2 to combinations of p_0 and p_1 so that it matches with the notation in the text.
[qe-fig-003] At lines 620–643, remove the embedded ax.set_title(). It also causes the combined plot at lines 667–671 to end with the misleading title “Excess demand for good 1,” even though both goods are shown.
At line 661, the prose describes a “black contour line,” but the code does not explicitly set the contour color. Currently it looks like purple not black. We can set the contour color to black.
At lines 725–735, update the manually calculated Jacobian. For
$$
e_i(p)=\exp(-(Ap)_i)+c_i-b_i\sqrt{p_i},
$$
so each exponential derivative contain the complete row product $(Ap)_i$. The element-by-element implementation could be:
At lines 760–768, state that the multivariate Newton update requires $J_e(p_n)$ to be nonsingular.
At lines 777–799, the multivariate newton definition overwrites the scalar implementation from the preceding section. Give it a distinct name such as newton_nd and update all downstream multivariate calls in Section 7.4 and the exercise solutions.
Exercise 1
At lines 904–909, denote the three initial vectors by $k_0^{(1)}$, $k_0^{(2)}$, and $k_0^{(3)}$, currently it looks like $k1_0$, $k2_0$, and $k3_0$.
At lines 917–934, clarify that the three-dimensional analytical benchmark is $(k^,k^,k^)^\top$ , where the linked $k^$ is the scalar analytical solution.
Exercise 2
At lines 1053–1058, denote the three initial price vectors by $p_0^{(1)}$, $p_0^{(2)}$, and $p_0^{(3)}$, currently the number is after the letter: $p1_0$, $p2_0$, and $p3_0$.
Hi @jstac
I was reading through the
newton_methodlecture with codex and here are some potential updates.I'd be grateful if you could take a look when you have a chance.
Overview
Fixed-point computation using Newton's method
At line 123, specify that the savings rate satisfies$s \in (0,1)$ , rather than only $s>0$ .
At lines 283–291, define the linear approximation with equality:
At lines 293–306, state that the Newton update requires$1-g'(x_t)\neq 0$ .
At lines 336–367,
plot_trajectoriesrelies on the global value ofk_star, which may have been calculated from different parameters. Calculatek_star = exact_fixed_point(params)inside the function instead.Root-finding in one dimension
[qe-writing-006] At line 378, change the heading from “Root-Finding in one dimension” to the sentence-case form “Root-finding in one dimension.”
At lines 397–405, define the linear approximation with equality:
At lines 405–418, state that each Newton update requires$f'(x_t)\neq 0$ .
At line 460, correct “We can convert to this to a zero-finding problem” to “We can convert this to a zero-finding problem.”
Multivariate Newton's method
At lines 485–486, change “5,000 goods” to “3,000 goods” to match the code implementation later.
At line 492, change “A two-goods market equilibrium” to “A two-good market equilibrium.”
[qe-writing-001] At lines 513, 606, and 701, split each two-sentence paragraph so that it contains one sentence per paragraph.
At line 606, capitalize “Python.”
At lines 621–643,
plot_excess_demandreadsA,b, andcfrom mutable global state. Pass these parameters explicitly so that the two-good plots can still be rerun after the variables are reassigned for the 3,000-good example.At line 624, update the mesh-grid comment from combinations of
p_1andp_2to combinations ofp_0andp_1so that it matches with the notation in the text.[qe-fig-003] At lines 620–643, remove the embedded
ax.set_title(). It also causes the combined plot at lines 667–671 to end with the misleading title “Excess demand for good 1,” even though both goods are shown.At line 661, the prose describes a “black contour line,” but the code does not explicitly set the contour color. Currently it looks like purple not black. We can set the contour color to black.
At lines 725–735, update the manually calculated Jacobian. For
so each exponential derivative contain the complete row product$(Ap)_i$ . The element-by-element implementation could be:
At lines 760–768, state that the multivariate Newton update requires$J_e(p_n)$ to be nonsingular.
At lines 777–799, the multivariate
newtondefinition overwrites the scalar implementation from the preceding section. Give it a distinct name such asnewton_ndand update all downstream multivariate calls in Section 7.4 and the exercise solutions.Exercise 1
At lines 904–909, denote the three initial vectors by$k_0^{(1)}$ , $k_0^{(2)}$ , and $k_0^{(3)}$ , currently it looks like $k1_0$ , $k2_0$ , and $k3_0$ .
At lines 917–934, clarify that the three-dimensional analytical benchmark is $(k^,k^,k^)^\top$ , where the linked $k^$ is the scalar analytical solution.
Exercise 2
What do you think? Happy to put up a PR.
Best,
Longye