Skip to content

[newton_method] Update lecture code and fix typos - #564

Merged
mmcky merged 9 commits into
mainfrom
newton_update
Sep 14, 2025
Merged

mmcky merged 9 commits into
mainfrom
newton_update

Conversation

@kp992

@kp992 kp992 commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

This PR:

  • updates the code to latest style guide like using typing.NamedTuple
  • pep8 fixes
  • typos and math errors
  • converts code to use jax

@kp992
kp992 requested review from HumphreyYang and mmcky August 19, 2025 03:23
@kp992 kp992 added the ready label Aug 19, 2025
@github-actions

github-actions Bot commented Aug 19, 2025

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request August 19, 2025 03:49 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 19, 2025 03:49 Inactive

@HumphreyYang HumphreyYang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks, @kp992! Great changes!

In this lecture, we used autograd because we were trying to avoid using JAX in the intermediate series. Since we are now migrating to JAX, I think we can use jax.jacobian here by adapting some functions from this lecture:

https://jax.quantecon.org/newtons_method.html

Let me know if that sounds good to you!

(CC @mmcky)

@kp992

kp992 commented Aug 20, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @HumphreyYang for the review. I was wondering if we want to keep just a single lecture on Newton's method using JAX or if we are planning to keep two versions -- one here and the other in JAX series?

@HumphreyYang

Copy link
Copy Markdown
Member

Hi @kp992,

Thanks @HumphreyYang for the review. I was wondering if we want to keep just a single lecture on Newton's method using JAX or if we are planning to keep two versions -- one here and the other in JAX series?

Yes! Our plan is to replace them with JAX implementation and keep the old JAX series and rename it to 'GPU computing for computational economics'.

@mmcky mmcky added new-lecture A new lecture (the marquee outcome) and removed content labels Aug 21, 2025
@kp992

kp992 commented Aug 21, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @HumphreyYang for the clarification. I will update the lecture to use JAX then.

@kp992 kp992 removed the ready label Aug 21, 2025
@kp992
kp992 marked this pull request as draft August 21, 2025 01:00
@kp992

kp992 commented Aug 21, 2025

Copy link
Copy Markdown
Contributor Author

Our plan is to replace them with JAX implementation and keep the old JAX series

So basically, we should host the same lecture in this series too, right? I mean we can copy over the JAX lecture here and update the code with styling fixes and typos?

@HumphreyYang

HumphreyYang commented Aug 21, 2025

Copy link
Copy Markdown
Member

Our plan is to replace them with JAX implementation and keep the old JAX series

So basically, we should host the same lecture in this series too, right? I mean we can copy over the JAX lecture here and update the code with styling fixes and typos?

Hi @kp992, yes, but I recall that for some lectures, the JAX version we wrote is a simplified version without discussions. For code that has overlaps, I think we can copy things over (like the newton)

@kp992
kp992 marked this pull request as ready for review August 22, 2025 01:37
@kp992

kp992 commented Aug 22, 2025

Copy link
Copy Markdown
Contributor Author

The lecture is now updated to optimized version of JAX and removed numpy/autograd support.

@github-actions
github-actions Bot temporarily deployed to pull request August 22, 2025 02:02 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 22, 2025 02:03 Inactive
@mmcky
mmcky requested a review from Copilot August 22, 2025 04:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the Newton's method lecture by updating the code to follow current best practices, fixing typos, and correcting mathematical notation errors. The changes improve code quality and educational clarity while maintaining the lecture's pedagogical structure.

Key changes:

  • Migrates from deprecated autograd to jax for automatic differentiation
  • Updates from collections.namedtuple to typing.NamedTuple for better type support
  • Corrects mathematical notation and fixes various typos throughout

Comment thread lectures/newton_method.md
Comment thread lectures/newton_method.md
Comment thread lectures/newton_method.md Outdated
Comment thread lectures/newton_method.md Outdated
Comment thread lectures/newton_method.md
Comment thread lectures/newton_method.md
Comment thread lectures/newton_method.md Outdated
Comment thread lectures/newton_method.md Outdated
Comment thread lectures/newton_method.md Outdated
Comment thread lectures/newton_method.md

@mmcky mmcky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work @kp992 -- I have left some minor comments for you. Mainly just minor adjustments for pep8 etc.

@kp992

kp992 commented Aug 23, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the review @mmcky.

@github-actions
github-actions Bot temporarily deployed to pull request August 23, 2025 04:53 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 23, 2025 04:53 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 31, 2025 22:28 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 31, 2025 22:29 Inactive
@mmcky
mmcky requested review from HumphreyYang and mmcky September 5, 2025 01:28
@netlify

netlify Bot commented Sep 9, 2025

Copy link
Copy Markdown

Deploy Preview for sunny-cactus-210e3e ready!

Name Link
🔨 Latest commit e3115df
🔍 Latest deploy log https://app.netlify.com/projects/sunny-cactus-210e3e/deploys/68c0f47275d46700082aa6f4
😎 Deploy Preview https://deploy-preview-564--sunny-cactus-210e3e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Sep 9, 2025

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request September 9, 2025 04:15 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request September 9, 2025 05:14 Inactive

@HumphreyYang HumphreyYang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @kp992!

I just pushed some minor changes, setting seed to 0 and removing the link to the JAX series since we are using JAX here.

Other than those it looks great to me!!

@github-actions
github-actions Bot temporarily deployed to pull request September 10, 2025 04:01 Inactive
@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-564--sunny-cactus-210e3e.netlify.app (f786112)

📚 Changed Lecture Pages: newton_method

@mmcky mmcky added the ready label Sep 11, 2025
@mmcky

mmcky commented Sep 12, 2025

Copy link
Copy Markdown
Contributor

@HumphreyYang are you happy for this to be merged?

@mmcky
mmcky merged commit 0184d5e into main Sep 14, 2025
1 check passed
@mmcky
mmcky deleted the newton_update branch September 14, 2025 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jax-conversion new-lecture A new lecture (the marquee outcome) ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants