Skip to content

Coefficients for Cohen-Hubbard-Oesterwinter #1733

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

Merged
merged 3 commits into from
Feb 25, 2018

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Feb 24, 2018

and a fix for the order of the backward difference method.

// Definition of a Cohen-Hubbard-Oesterwinter formula. |order_| is the order of
// the approximation, that is, the error on the derivative is h^(order + 1).
// The formula requires |order_| values of the acceleration. numerators[0]
// corresponds to f"(x₀), numerators[1] to f"(x₋₁), etc.
Copy link
Member

Choose a reason for hiding this comment

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

Use ″.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

using numerics::FixedVector;

// Definition of a Cohen-Hubbard-Oesterwinter formula. |order_| is the order of
// the approximation, that is, the error on the derivative is h^(order + 1).
Copy link
Member

Choose a reason for hiding this comment

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

O()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

// the approximation, that is, the error on the derivative is h^(order + 1).
// The formula requires |order_| values of the acceleration. numerators[0]
// corresponds to f"(x₀), numerators[1] to f"(x₋₁), etc.
// TODO(phl): This struct shows up in many places. Factor it out.
Copy link
Member

Choose a reason for hiding this comment

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

I don’t understand this TODO.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have 3 or 4 occurrences of a struct containing a FixedVector for numerators and a single value for the denominator.


using numerics::FixedVector;

// Definition of a Cohen-Hubbard-Oesterwinter formula. |order_| is the order of
Copy link
Member

Choose a reason for hiding this comment

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

Cite the paper, document any notational differences from the paper (I think we're off-by-one compared to it?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.



(fs[-h,\[ScriptCapitalN]+3]-fs[-2h,\[ScriptCapitalN]+3])/h+h Sum[f2s[-i h,\[ScriptCapitalN]+3]\[Beta][[i]],{i,1,Length[\[Beta]]}]//Expand
ReleaseHold[Hold[(fs[-h,\[ScriptCapitalN]+3]-fs[-2h,\[ScriptCapitalN]+3])/h+h Sum[f2s[-i h,\[ScriptCapitalN]+3]\[Beta][\[ScriptCapitalN]][[i]],{i,1,Length[\[Beta][\[ScriptCapitalN]]]}]]/.\[ScriptCapitalN]->14]//Expand
Copy link
Member

Choose a reason for hiding this comment

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

What is going on with this ReleaseHold and Hold?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mathematica magic: (1) Hold prevents the functions like fs from being evaluated at a place (2) N is being substituted in the argument of fs et al. (3) releasing the hold causes the whole thing to evaluate.


// Definition of a Cohen-Hubbard-Oesterwinter formula. |order_| is the order of
// the approximation, that is, the error on the derivative is h^(order + 1).
// The formula requires |order_| values of the acceleration. numerators[0]
Copy link
Member

Choose a reason for hiding this comment

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

Document what the formula is, and what it approximates.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@eggrobin eggrobin added the LGTM label Feb 25, 2018
@pleroy pleroy merged commit 15012c3 into mockingbirdnest:master Feb 25, 2018
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