Average Error: 0.0 → 0.0
Time: 809.0ms
Precision: binary64
\[\mathsf{max}\left(\ell, \mathsf{min}\left(\ell + \left(h - \ell\right) \cdot x, h\right)\right)\]
\[\mathsf{max}\left(\ell, \mathsf{min}\left(\ell + \left(h - \ell\right) \cdot x, h\right)\right)\]
\mathsf{max}\left(\ell, \mathsf{min}\left(\ell + \left(h - \ell\right) \cdot x, h\right)\right)
\mathsf{max}\left(\ell, \mathsf{min}\left(\ell + \left(h - \ell\right) \cdot x, h\right)\right)
double code(double l, double h, double x) {
	return ((double) fmax(l, ((double) fmin(((double) (l + ((double) (((double) (h - l)) * x)))), h))));
}
double code(double l, double h, double x) {
	return ((double) fmax(l, ((double) fmin(((double) (l + ((double) (((double) (h - l)) * x)))), h))));
}

Error

Bits error versus l

Bits error versus h

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\mathsf{max}\left(\ell, \mathsf{min}\left(\ell + \left(h - \ell\right) \cdot x, h\right)\right)\]
  2. Final simplification0.0

    \[\leadsto \mathsf{max}\left(\ell, \mathsf{min}\left(\ell + \left(h - \ell\right) \cdot x, h\right)\right)\]

Reproduce

herbie shell --seed 2020153 
(FPCore (l h x)
  :name "(fmax l (fmin (+ l (* (- h l) x)) h))"
  :precision binary64
  (fmax l (fmin (+ l (* (- h l) x)) h)))