Average Error: 1.3 → 1.1
Time: 20.2s
Precision: 64
\[x + y \cdot \frac{z - t}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.0685894439031453 \cdot 10^{101} \lor \neg \left(y \le 1.8958912622994213 \cdot 10^{-91}\right):\\ \;\;\;\;\frac{y}{\frac{a - t}{z - t}} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{a - t} \cdot \left(y \cdot \left(z - t\right)\right) + x\\ \end{array}\]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
\mathbf{if}\;y \le -2.0685894439031453 \cdot 10^{101} \lor \neg \left(y \le 1.8958912622994213 \cdot 10^{-91}\right):\\
\;\;\;\;\frac{y}{\frac{a - t}{z - t}} + x\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{a - t} \cdot \left(y \cdot \left(z - t\right)\right) + x\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r438364 = x;
        double r438365 = y;
        double r438366 = z;
        double r438367 = t;
        double r438368 = r438366 - r438367;
        double r438369 = a;
        double r438370 = r438369 - r438367;
        double r438371 = r438368 / r438370;
        double r438372 = r438365 * r438371;
        double r438373 = r438364 + r438372;
        return r438373;
}

double f(double x, double y, double z, double t, double a) {
        double r438374 = y;
        double r438375 = -2.0685894439031453e+101;
        bool r438376 = r438374 <= r438375;
        double r438377 = 1.8958912622994213e-91;
        bool r438378 = r438374 <= r438377;
        double r438379 = !r438378;
        bool r438380 = r438376 || r438379;
        double r438381 = a;
        double r438382 = t;
        double r438383 = r438381 - r438382;
        double r438384 = z;
        double r438385 = r438384 - r438382;
        double r438386 = r438383 / r438385;
        double r438387 = r438374 / r438386;
        double r438388 = x;
        double r438389 = r438387 + r438388;
        double r438390 = 1.0;
        double r438391 = r438390 / r438383;
        double r438392 = r438374 * r438385;
        double r438393 = r438391 * r438392;
        double r438394 = r438393 + r438388;
        double r438395 = r438380 ? r438389 : r438394;
        return r438395;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original1.3
Target0.4
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;y \lt -8.50808486055124107 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y \lt 2.8944268627920891 \cdot 10^{-49}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -2.0685894439031453e+101 or 1.8958912622994213e-91 < y

    1. Initial program 0.6

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Simplified0.6

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a - t}{z - t}} \cdot y + x}\]
    7. Simplified0.6

      \[\leadsto \color{blue}{\frac{y}{\frac{a - t}{z - t}}} + x\]

    if -2.0685894439031453e+101 < y < 1.8958912622994213e-91

    1. Initial program 1.9

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Simplified1.9

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a - t}{z - t}} \cdot y + x}\]
    7. Simplified1.5

      \[\leadsto \color{blue}{\frac{y}{\frac{a - t}{z - t}}} + x\]
    8. Using strategy rm
    9. Applied div-inv1.6

      \[\leadsto \frac{y}{\color{blue}{\left(a - t\right) \cdot \frac{1}{z - t}}} + x\]
    10. Applied *-un-lft-identity1.6

      \[\leadsto \frac{\color{blue}{1 \cdot y}}{\left(a - t\right) \cdot \frac{1}{z - t}} + x\]
    11. Applied times-frac1.6

      \[\leadsto \color{blue}{\frac{1}{a - t} \cdot \frac{y}{\frac{1}{z - t}}} + x\]
    12. Simplified1.6

      \[\leadsto \frac{1}{a - t} \cdot \color{blue}{\left(y \cdot \left(z - t\right)\right)} + x\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.0685894439031453 \cdot 10^{101} \lor \neg \left(y \le 1.8958912622994213 \cdot 10^{-91}\right):\\ \;\;\;\;\frac{y}{\frac{a - t}{z - t}} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{a - t} \cdot \left(y \cdot \left(z - t\right)\right) + x\\ \end{array}\]

Reproduce

herbie shell --seed 2019198 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, B"

  :herbie-target
  (if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1.0 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))

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