Average Error: 10.4 → 1.4
Time: 22.6s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{z - a}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.6661982335298339 \cdot 10^{-218} \lor \neg \left(z \le 4.6473611547607236 \cdot 10^{-162}\right):\\ \;\;\;\;\frac{\frac{z - t}{z - a}}{\frac{1}{y}} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{z - t}{\frac{z - a}{y}} + x\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{z - a}
\begin{array}{l}
\mathbf{if}\;z \le -2.6661982335298339 \cdot 10^{-218} \lor \neg \left(z \le 4.6473611547607236 \cdot 10^{-162}\right):\\
\;\;\;\;\frac{\frac{z - t}{z - a}}{\frac{1}{y}} + x\\

\mathbf{else}:\\
\;\;\;\;\frac{z - t}{\frac{z - a}{y}} + x\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r390528 = x;
        double r390529 = y;
        double r390530 = z;
        double r390531 = t;
        double r390532 = r390530 - r390531;
        double r390533 = r390529 * r390532;
        double r390534 = a;
        double r390535 = r390530 - r390534;
        double r390536 = r390533 / r390535;
        double r390537 = r390528 + r390536;
        return r390537;
}

double f(double x, double y, double z, double t, double a) {
        double r390538 = z;
        double r390539 = -2.666198233529834e-218;
        bool r390540 = r390538 <= r390539;
        double r390541 = 4.647361154760724e-162;
        bool r390542 = r390538 <= r390541;
        double r390543 = !r390542;
        bool r390544 = r390540 || r390543;
        double r390545 = t;
        double r390546 = r390538 - r390545;
        double r390547 = a;
        double r390548 = r390538 - r390547;
        double r390549 = r390546 / r390548;
        double r390550 = 1.0;
        double r390551 = y;
        double r390552 = r390550 / r390551;
        double r390553 = r390549 / r390552;
        double r390554 = x;
        double r390555 = r390553 + r390554;
        double r390556 = r390548 / r390551;
        double r390557 = r390546 / r390556;
        double r390558 = r390557 + r390554;
        double r390559 = r390544 ? r390555 : r390558;
        return r390559;
}

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

Original10.4
Target1.2
Herbie1.4
\[x + \frac{y}{\frac{z - a}{z - t}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -2.666198233529834e-218 or 4.647361154760724e-162 < z

    1. Initial program 11.9

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{z - a}{y}} \cdot \left(z - t\right) + x}\]
    7. Simplified3.0

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

      \[\leadsto \frac{z - t}{\color{blue}{\left(z - a\right) \cdot \frac{1}{y}}} + x\]
    10. Applied associate-/r*1.0

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

    if -2.666198233529834e-218 < z < 4.647361154760724e-162

    1. Initial program 3.7

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{z - a}{y}} \cdot \left(z - t\right) + x}\]
    7. Simplified3.7

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

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

Reproduce

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

  :herbie-target
  (+ x (/ y (/ (- z a) (- z t))))

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