Skip to content

made first order actually first order and added fourth order#120

Merged
pavelkomarov merged 19 commits intomasterfrom
improve-fd
Jul 16, 2025
Merged

made first order actually first order and added fourth order#120
pavelkomarov merged 19 commits intomasterfrom
improve-fd

Conversation

@pavelkomarov
Copy link
Collaborator

Addressing #104. The resulting first_order is biased to one side, resulting in drift when it's iterated:

Screenshot 2025-07-01 at 10 23 17

This is likely why you attempted some forward-backward averaging, @florisvb.

Honestly, is it worth keeping around first_order? My guess is it's not in wide usage, because the higher order methods are equally usable and right there for the taking. Iterating first_order might be a thing people do, but in that case they're actually iterating second_order, so we should update the code to reflect that and feed them a warning if they try to call first_order.

[(-25, -25), (0, 0), (0, 0), (1, 0)],
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
[(-25, -25), (0, 0), (0, 0), (1, 1)],
[(-25, -25), (1, 0), (0, 0), (1, 1)],
Copy link
Collaborator Author

@pavelkomarov pavelkomarov Jul 1, 2025

Choose a reason for hiding this comment

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

The first order bounds only get a touch worse when we make first_order truly first order.

[(1, 0), (1, 0), (1, 1), (1, 1)],
[(1, 0), (1, 1), (1, 0), (1, 1)],
[(2, 2), (3, 2), (2, 2), (3, 2)],
[(2, 2), (3, 3), (2, 2), (3, 3)]],
Copy link
Collaborator Author

@pavelkomarov pavelkomarov Jul 1, 2025

Choose a reason for hiding this comment

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

The "iterated_first_order" bounds get worse all over the place, because the horizontal bias introduced by a non symmetric first-order method causes drift over the iterations.

@pavelkomarov
Copy link
Collaborator Author

The first_order method has been a workhorse across the repo, so I'm replacing it with second_order internally.

@pavelkomarov pavelkomarov requested a review from florisvb July 8, 2025 03:33
@pavelkomarov pavelkomarov mentioned this pull request Jul 8, 2025
@pavelkomarov
Copy link
Collaborator Author

Let's merge this one after #125. I think I'm going to want to make a couple follow-on commits to it. I need to:

  • move num_iterations to second_order and fourth_order
  • go through the code looking for places iterated first order is called and have them call iterated second order instead
  • address _x_hat_using_finite_difference investigation #87
  • update the usage notebooks to include fourth_order

@pavelkomarov pavelkomarov merged commit 882df8c into master Jul 16, 2025
1 check passed
@pavelkomarov pavelkomarov deleted the improve-fd branch July 16, 2025 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant