-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate finitediff into argmin monorepo #479
Conversation
stefan-k
commented
Mar 1, 2024
- Started integrating finitediff into argmin monorepo
- Added CI pipeline for finitediff, fixed doc test
- Updated finitediff Cargo.toml
- Fixed ndarray warning in finitediff
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #479 +/- ##
==========================================
+ Coverage 91.52% 92.50% +0.97%
==========================================
Files 163 178 +15
Lines 21731 24577 +2846
==========================================
+ Hits 19890 22734 +2844
- Misses 1841 1843 +2 ☔ View full report in Codecov by Sentry. |
let mut xt = x.to_owned(); | ||
(0..x.len()) | ||
.map(|i| { | ||
let fx1 = mod_and_calc(&mut xt, fs, i, EPS_F64.sqrt()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For central differencing, you're better off using the cube root so you can improve accuracy to
let fx1 = mod_and_calc(&mut xt, fs, i, EPS_F64.sqrt()); | |
let fx1 = mod_and_calc(&mut xt, fs, i, EPS_F64.cbrt()); |
If you choose sqrt, you get the intersection of the red and magenta lines.
That said, it's dubious to rely on the problem being carefully nondimensionalized in a library implementaion of finite differencing. The two algorithms I know of are from Walker and Pernice and from Dennis and Schnabel. In my experience, some problems benefit significantly from the more expensive (Dennis and Schnabel) method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out! I followed the Nocedal and Wright book on this (p. 169), and after reading that section again it's clear that I must have missed that part. If I understand it correctly, the book states it should be EPS_F64.cbrt().powi(2)
, and not EPS_F64.cbrt()
. What am I missing?
Thanks for pointing me to the other resources which I wasn't aware of. I will have a look, but probably not as part of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, indeed. That's a mistake on page 169 (it was intended to state that as the achievable error), but it refers to the exercises, which has the correct statement (as in my comment and figure above).
In analogy to Equation 7.5, where you want to choose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying and for the explanation! Interestingly, this mistake isn't even mentioned in the errata. I will change it to eps.cbrt()
then :)
4974ea9
to
d3661ba
Compare
d3661ba
to
be1a806
Compare