Average Error: 25.1 → 11.9
Time: 49.4s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -2.335375383468043 \cdot 10^{-253}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 4.422650758851032 \cdot 10^{-257}:\\ \;\;\;\;t\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 2.5105206001942476 \cdot 10^{+288}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -2.335375383468043 \cdot 10^{-253}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)\\

\mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 4.422650758851032 \cdot 10^{-257}:\\
\;\;\;\;t\\

\mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 2.5105206001942476 \cdot 10^{+288}:\\
\;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r28701480 = x;
        double r28701481 = y;
        double r28701482 = z;
        double r28701483 = r28701481 - r28701482;
        double r28701484 = t;
        double r28701485 = r28701484 - r28701480;
        double r28701486 = r28701483 * r28701485;
        double r28701487 = a;
        double r28701488 = r28701487 - r28701482;
        double r28701489 = r28701486 / r28701488;
        double r28701490 = r28701480 + r28701489;
        return r28701490;
}

double f(double x, double y, double z, double t, double a) {
        double r28701491 = x;
        double r28701492 = y;
        double r28701493 = z;
        double r28701494 = r28701492 - r28701493;
        double r28701495 = t;
        double r28701496 = r28701495 - r28701491;
        double r28701497 = r28701494 * r28701496;
        double r28701498 = a;
        double r28701499 = r28701498 - r28701493;
        double r28701500 = r28701497 / r28701499;
        double r28701501 = r28701491 + r28701500;
        double r28701502 = -2.335375383468043e-253;
        bool r28701503 = r28701501 <= r28701502;
        double r28701504 = r28701496 / r28701499;
        double r28701505 = fma(r28701504, r28701494, r28701491);
        double r28701506 = 4.422650758851032e-257;
        bool r28701507 = r28701501 <= r28701506;
        double r28701508 = 2.5105206001942476e+288;
        bool r28701509 = r28701501 <= r28701508;
        double r28701510 = r28701509 ? r28701501 : r28701505;
        double r28701511 = r28701507 ? r28701495 : r28701510;
        double r28701512 = r28701503 ? r28701505 : r28701511;
        return r28701512;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.1
Target12.3
Herbie11.9
\[\begin{array}{l} \mathbf{if}\;z \lt -1.2536131056095036 \cdot 10^{+188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811 \cdot 10^{+64}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (+ x (/ (* (- y z) (- t x)) (- a z))) < -2.335375383468043e-253 or 2.5105206001942476e+288 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 31.9

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
    2. Simplified12.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)}\]
    3. Using strategy rm
    4. Applied div-inv12.7

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(t - x\right) \cdot \frac{1}{a - z}}, y - z, x\right)\]
    5. Using strategy rm
    6. Applied un-div-inv12.6

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{t - x}{a - z}}, y - z, x\right)\]

    if -2.335375383468043e-253 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 4.422650758851032e-257

    1. Initial program 52.4

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
    2. Simplified53.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)}\]
    3. Taylor expanded around 0 38.3

      \[\leadsto \color{blue}{t}\]

    if 4.422650758851032e-257 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 2.5105206001942476e+288

    1. Initial program 2.1

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification11.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -2.335375383468043 \cdot 10^{-253}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 4.422650758851032 \cdot 10^{-257}:\\ \;\;\;\;t\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 2.5105206001942476 \cdot 10^{+288}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019165 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"

  :herbie-target
  (if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

  (+ x (/ (* (- y z) (- t x)) (- a z))))