Average Error: 12.3 → 12.3
Time: 2.2s
Precision: binary64
\[\left(\frac{n - 1}{2} + \frac{x \cdot \left(n \cdot n - 1\right)}{12}\right) + \frac{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(1 - \left(\left(n \cdot n\right) \cdot n\right) \cdot n\right)}{720}\]
\[\left(\frac{n - 1}{2} + \frac{x \cdot \left(n \cdot n - 1\right)}{12}\right) + \frac{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(1 - \left(\left(n \cdot n\right) \cdot n\right) \cdot n\right)}{720}\]
\left(\frac{n - 1}{2} + \frac{x \cdot \left(n \cdot n - 1\right)}{12}\right) + \frac{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(1 - \left(\left(n \cdot n\right) \cdot n\right) \cdot n\right)}{720}
\left(\frac{n - 1}{2} + \frac{x \cdot \left(n \cdot n - 1\right)}{12}\right) + \frac{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(1 - \left(\left(n \cdot n\right) \cdot n\right) \cdot n\right)}{720}
double code(double n, double x) {
	return ((double) (((double) (((double) (((double) (n - 1.0)) / 2.0)) + ((double) (((double) (x * ((double) (((double) (n * n)) - 1.0)))) / 12.0)))) + ((double) (((double) (((double) (((double) (x * x)) * x)) * ((double) (1.0 - ((double) (((double) (((double) (n * n)) * n)) * n)))))) / 720.0))));
}
double code(double n, double x) {
	return ((double) (((double) (((double) (((double) (n - 1.0)) / 2.0)) + ((double) (((double) (x * ((double) (((double) (n * n)) - 1.0)))) / 12.0)))) + ((double) (((double) (((double) (((double) (x * x)) * x)) * ((double) (1.0 - ((double) (((double) (((double) (n * n)) * n)) * n)))))) / 720.0))));
}

Error

Bits error versus n

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 12.3

    \[\left(\frac{n - 1}{2} + \frac{x \cdot \left(n \cdot n - 1\right)}{12}\right) + \frac{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(1 - \left(\left(n \cdot n\right) \cdot n\right) \cdot n\right)}{720}\]
  2. Final simplification12.3

    \[\leadsto \left(\frac{n - 1}{2} + \frac{x \cdot \left(n \cdot n - 1\right)}{12}\right) + \frac{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(1 - \left(\left(n \cdot n\right) \cdot n\right) \cdot n\right)}{720}\]

Reproduce

herbie shell --seed 2020153 
(FPCore (n x)
  :name "(+ (+ (/ (- n 1) 2) (/ (* x (- (* n n) 1)) 12)) (/ (* (* (* x x) x) (- 1 (* (* (* n n) n) n))) 720))"
  :precision binary64
  (+ (+ (/ (- n 1.0) 2.0) (/ (* x (- (* n n) 1.0)) 12.0)) (/ (* (* (* x x) x) (- 1.0 (* (* (* n n) n) n))) 720.0)))