Skip to content

Commit

Permalink
dp_integrator: fix error estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
fizyk20 committed Apr 12, 2019
1 parent b7533b2 commit e9f4f16
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/integration/dormand_prince.rs
Expand Up @@ -77,7 +77,7 @@ impl<S: State> Integrator<S> for DPIntegrator<S> {

let k7 = diff_eq(&new_state);

let error = ((k1 * 71.0 / 576000.0 - k3 * 71.0 / 16695.0 + k4 * 71.0 / 1920.0
let error = ((k1 * 71.0 / 57600.0 - k3 * 71.0 / 16695.0 + k4 * 71.0 / 1920.0
- k5 * 17253.0 / 339200.0
+ k6 * 22.0 / 525.0
- k7.clone() / 40.0)
Expand Down

3 comments on commit e9f4f16

@earthengine
Copy link

Choose a reason for hiding this comment

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

This is why we should name constants wisely and stop using magic numbers.

@fizyk20
Copy link
Owner Author

Choose a reason for hiding this comment

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

What names would you propose here? ;) Those are just coefficients coming from the Dormand-Prince method, they don't really carry any meaning that would warrant naming them... And I could make the same mistake by doing for example:
const COEFF_ERROR_1: f64 = 71.0 / 576000.0;

@scriptandcompile
Copy link

Choose a reason for hiding this comment

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

Knowing that this value is a coefficient error term is useful for anyone trying to understand what this bit of code is doing. This is reason enough to name it.

Please sign in to comment.