Skip to content
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

they're good algorithms for finding a zero of a function Brent #2731

Merged
merged 11 commits into from
Sep 23, 2020

Conversation

eggrobin
Copy link
Member

@eggrobin eggrobin commented Sep 23, 2020

The other Brent method should speed up #2400; implement zero before the trickier localmin.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Member

@pleroy pleroy left a comment

Choose a reason for hiding this comment

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

First round of review, I'll need to read the papers to review more deeper.

documentation/bibliography.bib Outdated Show resolved Hide resolved
documentation/bibliography.bib Outdated Show resolved Hide resolved
numerics/root_finders_body.hpp Outdated Show resolved Hide resolved
numerics/root_finders_body.hpp Outdated Show resolved Hide resolved
numerics/root_finders_body.hpp Outdated Show resolved Hide resolved
documentation/bibliography.bib Show resolved Hide resolved
numerics/scale_b.h Outdated Show resolved Hide resolved
numerics/scale_b.h Outdated Show resolved Hide resolved
numerics/scale_b.h Outdated Show resolved Hide resolved
numerics/root_finders_body.hpp Show resolved Hide resolved
numerics/root_finders_test.cpp Show resolved Hide resolved
numerics/root_finders_test.cpp Outdated Show resolved Hide resolved
numerics/root_finders_test.cpp Outdated Show resolved Hide resolved
numerics/root_finders_test.cpp Show resolved Hide resolved
numerics/root_finders_test.cpp Show resolved Hide resolved
double const x,
int* const evaluations,
bool const expect_brent_calls) -> double {
double const f_a = -100;
Copy link
Member

Choose a reason for hiding this comment

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

This is weird. Comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the ϵ < 0.

}
// [WG13] define f only on X. We extend it as a step function, returning the
// value for the element of X nearest to the given x.
int j;
Copy link
Member

Choose a reason for hiding this comment

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

Document how this relates to m in the paper.

Sorry, something went wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does not; m is constant in the paper.

Sorry, something went wrong.

numerics/root_finders_test.cpp Outdated Show resolved Hide resolved
numerics/root_finders_test.cpp Outdated Show resolved Hide resolved
b += Abs(d) > δ ? d : δ * Sign(m);
f_b = f(b);
if (Sign(f_b) == Sign(f_c)) {
goto interpolation;
Copy link
Member

Choose a reason for hiding this comment

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

I realise that you are trying to stick to the paper, but I am going to claim that two nested loop would read better and, unlike, say, integrators, the control structure is not hard to transform into loops (break if the signs match, return if the condition at line 116 is false).

p = -p;
Difference<Argument> const δ = 2 * ϵ * Abs(b - Argument{});
Difference<Argument> const m = 0.5 * (c - b);
if (!(Abs(m) > δ && f_b != zero)) {
Copy link
Member

Choose a reason for hiding this comment

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

All hail De Morgan!

X[k],
X[k - 1],
f_a,
f(X[k - 1], /*evaluations=*/nullptr, /*expect_brent_calls=*/false));
Copy link
Member

Choose a reason for hiding this comment

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

One column.

@pleroy pleroy added the LGTM label Sep 23, 2020
@eggrobin eggrobin merged commit 2743593 into mockingbirdnest:master Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants