Skip to content
Permalink
Browse files

dp_integrator: fix error estimation

  • Loading branch information...
fizyk20 committed Apr 12, 2019
1 parent b7533b2 commit e9f4f16a56ba148c30b736051d8392e036eed747
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/integration/dormand_prince.rs
@@ -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)

3 comments on commit e9f4f16

@earthengine

This comment has been minimized.

Copy link

replied Apr 13, 2019

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

@fizyk20

This comment has been minimized.

Copy link
Owner Author

replied Apr 13, 2019

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

This comment has been minimized.

Copy link

replied Apr 13, 2019

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.
You can’t perform that action at this time.