Average Error: 9.9 → 3.5
Time: 19.6s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{z - a}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.4708440122252604 \cdot 10^{-79}:\\ \;\;\;\;x + \frac{y}{z - a} \cdot \left(z - t\right)\\ \mathbf{elif}\;x \le -8.584217131842657 \cdot 10^{-280}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{z - a} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{z - a} \cdot \left(z - t\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{z - a}
\begin{array}{l}
\mathbf{if}\;x \le -2.4708440122252604 \cdot 10^{-79}:\\
\;\;\;\;x + \frac{y}{z - a} \cdot \left(z - t\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r23771164 = x;
        double r23771165 = y;
        double r23771166 = z;
        double r23771167 = t;
        double r23771168 = r23771166 - r23771167;
        double r23771169 = r23771165 * r23771168;
        double r23771170 = a;
        double r23771171 = r23771166 - r23771170;
        double r23771172 = r23771169 / r23771171;
        double r23771173 = r23771164 + r23771172;
        return r23771173;
}

double f(double x, double y, double z, double t, double a) {
        double r23771174 = x;
        double r23771175 = -2.4708440122252604e-79;
        bool r23771176 = r23771174 <= r23771175;
        double r23771177 = y;
        double r23771178 = z;
        double r23771179 = a;
        double r23771180 = r23771178 - r23771179;
        double r23771181 = r23771177 / r23771180;
        double r23771182 = t;
        double r23771183 = r23771178 - r23771182;
        double r23771184 = r23771181 * r23771183;
        double r23771185 = r23771174 + r23771184;
        double r23771186 = -8.584217131842657e-280;
        bool r23771187 = r23771174 <= r23771186;
        double r23771188 = r23771183 * r23771177;
        double r23771189 = r23771188 / r23771180;
        double r23771190 = r23771189 + r23771174;
        double r23771191 = r23771187 ? r23771190 : r23771185;
        double r23771192 = r23771176 ? r23771185 : r23771191;
        return r23771192;
}

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

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

Derivation

  1. Split input into 2 regimes
  2. if x < -2.4708440122252604e-79 or -8.584217131842657e-280 < x

    1. Initial program 9.9

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

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

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

    if -2.4708440122252604e-79 < x < -8.584217131842657e-280

    1. Initial program 9.7

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

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

      \[\leadsto \color{blue}{\left(z - t\right) \cdot \frac{y}{z - a} + x}\]
    5. Using strategy rm
    6. Applied associate-*r/9.7

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

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

Reproduce

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