Average Error: 9.9 → 0.5
Time: 10.9s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{z - a}\]
\[\begin{array}{l} \mathbf{if}\;y \le -8.07137190913606 \cdot 10^{-119}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)\\ \mathbf{elif}\;y \le 4.8750961897520596 \cdot 10^{-23}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{z - a} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{z - a}
\begin{array}{l}
\mathbf{if}\;y \le -8.07137190913606 \cdot 10^{-119}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r10335097 = x;
        double r10335098 = y;
        double r10335099 = z;
        double r10335100 = t;
        double r10335101 = r10335099 - r10335100;
        double r10335102 = r10335098 * r10335101;
        double r10335103 = a;
        double r10335104 = r10335099 - r10335103;
        double r10335105 = r10335102 / r10335104;
        double r10335106 = r10335097 + r10335105;
        return r10335106;
}

double f(double x, double y, double z, double t, double a) {
        double r10335107 = y;
        double r10335108 = -8.07137190913606e-119;
        bool r10335109 = r10335107 <= r10335108;
        double r10335110 = z;
        double r10335111 = t;
        double r10335112 = r10335110 - r10335111;
        double r10335113 = a;
        double r10335114 = r10335110 - r10335113;
        double r10335115 = r10335112 / r10335114;
        double r10335116 = x;
        double r10335117 = fma(r10335115, r10335107, r10335116);
        double r10335118 = 4.8750961897520596e-23;
        bool r10335119 = r10335107 <= r10335118;
        double r10335120 = r10335112 * r10335107;
        double r10335121 = r10335120 / r10335114;
        double r10335122 = r10335121 + r10335116;
        double r10335123 = r10335119 ? r10335122 : r10335117;
        double r10335124 = r10335109 ? r10335117 : r10335123;
        return r10335124;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original9.9
Target1.2
Herbie0.5
\[x + \frac{y}{\frac{z - a}{z - t}}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -8.07137190913606e-119 or 4.8750961897520596e-23 < y

    1. Initial program 16.9

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z - t}{z - a} \cdot y} + x\]
    10. Applied fma-def0.6

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

    if -8.07137190913606e-119 < y < 4.8750961897520596e-23

    1. Initial program 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -8.07137190913606 \cdot 10^{-119}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)\\ \mathbf{elif}\;y \le 4.8750961897520596 \cdot 10^{-23}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{z - a} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019156 +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))))