Average Error: 10.2 → 0.4
Time: 21.5s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;y \le -7.360592058960857 \cdot 10^{-45}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y \le 2.210437770349525 \cdot 10^{-37}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{a - t} + x\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;y \le -7.360592058960857 \cdot 10^{-45}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a - t}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r22961546 = x;
        double r22961547 = y;
        double r22961548 = z;
        double r22961549 = t;
        double r22961550 = r22961548 - r22961549;
        double r22961551 = r22961547 * r22961550;
        double r22961552 = a;
        double r22961553 = r22961552 - r22961549;
        double r22961554 = r22961551 / r22961553;
        double r22961555 = r22961546 + r22961554;
        return r22961555;
}

double f(double x, double y, double z, double t, double a) {
        double r22961556 = y;
        double r22961557 = -7.360592058960857e-45;
        bool r22961558 = r22961556 <= r22961557;
        double r22961559 = x;
        double r22961560 = z;
        double r22961561 = t;
        double r22961562 = r22961560 - r22961561;
        double r22961563 = a;
        double r22961564 = r22961563 - r22961561;
        double r22961565 = r22961562 / r22961564;
        double r22961566 = r22961556 * r22961565;
        double r22961567 = r22961559 + r22961566;
        double r22961568 = 2.210437770349525e-37;
        bool r22961569 = r22961556 <= r22961568;
        double r22961570 = r22961562 * r22961556;
        double r22961571 = r22961570 / r22961564;
        double r22961572 = r22961571 + r22961559;
        double r22961573 = r22961569 ? r22961572 : r22961567;
        double r22961574 = r22961558 ? r22961567 : r22961573;
        return r22961574;
}

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.2
Target1.2
Herbie0.4
\[x + \frac{y}{\frac{a - t}{z - t}}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -7.360592058960857e-45 or 2.210437770349525e-37 < y

    1. Initial program 18.7

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

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

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

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

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

    if -7.360592058960857e-45 < y < 2.210437770349525e-37

    1. Initial program 0.3

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

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

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

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

      \[\leadsto \color{blue}{\frac{z - t}{a - t} \cdot y} + x\]
    8. Using strategy rm
    9. Applied associate-*l/0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -7.360592058960857 \cdot 10^{-45}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y \le 2.210437770349525 \cdot 10^{-37}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{a - t} + x\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array}\]

Reproduce

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

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

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