Average Error: 24.4 → 10.0
Time: 4.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.144165143768362991760089872609493676713 \cdot 10^{186} \lor \neg \left(z \le 2.076744265404525669788852177351907204291 \cdot 10^{154}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{y - z}{a - z}\right)}^{1}, t - x, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -2.144165143768362991760089872609493676713 \cdot 10^{186} \lor \neg \left(z \le 2.076744265404525669788852177351907204291 \cdot 10^{154}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r604494 = x;
        double r604495 = y;
        double r604496 = z;
        double r604497 = r604495 - r604496;
        double r604498 = t;
        double r604499 = r604498 - r604494;
        double r604500 = r604497 * r604499;
        double r604501 = a;
        double r604502 = r604501 - r604496;
        double r604503 = r604500 / r604502;
        double r604504 = r604494 + r604503;
        return r604504;
}

double f(double x, double y, double z, double t, double a) {
        double r604505 = z;
        double r604506 = -2.144165143768363e+186;
        bool r604507 = r604505 <= r604506;
        double r604508 = 2.0767442654045257e+154;
        bool r604509 = r604505 <= r604508;
        double r604510 = !r604509;
        bool r604511 = r604507 || r604510;
        double r604512 = y;
        double r604513 = x;
        double r604514 = r604513 / r604505;
        double r604515 = t;
        double r604516 = r604515 / r604505;
        double r604517 = r604514 - r604516;
        double r604518 = fma(r604512, r604517, r604515);
        double r604519 = r604512 - r604505;
        double r604520 = a;
        double r604521 = r604520 - r604505;
        double r604522 = r604519 / r604521;
        double r604523 = 1.0;
        double r604524 = pow(r604522, r604523);
        double r604525 = r604515 - r604513;
        double r604526 = fma(r604524, r604525, r604513);
        double r604527 = r604511 ? r604518 : r604526;
        return r604527;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.4
Target11.9
Herbie10.0
\[\begin{array}{l} \mathbf{if}\;z \lt -1.253613105609503593846459977496550767343 \cdot 10^{188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811028051510715777703865332 \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 2 regimes
  2. if z < -2.144165143768363e+186 or 2.0767442654045257e+154 < z

    1. Initial program 48.0

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

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

      \[\leadsto \color{blue}{\left(\frac{x \cdot y}{z} + t\right) - \frac{t \cdot y}{z}}\]
    4. Simplified16.4

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

    if -2.144165143768363e+186 < z < 2.0767442654045257e+154

    1. Initial program 16.7

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

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

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

      \[\leadsto \mathsf{fma}\left(\left(y - z\right) \cdot \color{blue}{{\left(\frac{1}{a - z}\right)}^{1}}, t - x, x\right)\]
    7. Applied pow18.0

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y - z\right)}^{1}} \cdot {\left(\frac{1}{a - z}\right)}^{1}, t - x, x\right)\]
    8. Applied pow-prod-down8.0

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - z\right) \cdot \frac{1}{a - z}\right)}^{1}}, t - x, x\right)\]
    9. Simplified7.9

      \[\leadsto \mathsf{fma}\left({\color{blue}{\left(\frac{y - z}{a - z}\right)}}^{1}, t - x, x\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.144165143768362991760089872609493676713 \cdot 10^{186} \lor \neg \left(z \le 2.076744265404525669788852177351907204291 \cdot 10^{154}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{y - z}{a - z}\right)}^{1}, t - x, x\right)\\ \end{array}\]

Reproduce

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

  :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))))