Average Error: 0.0 → 0.0
Time: 12.3s
Precision: 64
\[\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 f(double l, double h, double x) {
        double r51185086 = l;
        double r51185087 = h;
        double r51185088 = r51185087 - r51185086;
        double r51185089 = x;
        double r51185090 = r51185088 * r51185089;
        double r51185091 = r51185086 + r51185090;
        double r51185092 = fmin(r51185091, r51185087);
        double r51185093 = fmax(r51185086, r51185092);
        return r51185093;
}

double f(double l, double h, double x) {
        double r51185094 = l;
        double r51185095 = h;
        double r51185096 = r51185095 - r51185094;
        double r51185097 = x;
        double r51185098 = r51185096 * r51185097;
        double r51185099 = r51185094 + r51185098;
        double r51185100 = fmin(r51185099, r51185095);
        double r51185101 = fmax(r51185094, r51185100);
        return r51185101;
}

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 1 
(FPCore (l h x)
  :name "max(l,min( l+(h-l)*x ,h))"
  (fmax l (fmin (+ l (* (- h l) x)) h)))