Average Error: 10.6 → 3.0
Time: 4.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\frac{t}{a - z} \cdot y + \mathsf{fma}\left(-z, t \cdot \frac{1}{a - z}, x\right)\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\frac{t}{a - z} \cdot y + \mathsf{fma}\left(-z, t \cdot \frac{1}{a - z}, x\right)
double f(double x, double y, double z, double t, double a) {
        double r574193 = x;
        double r574194 = y;
        double r574195 = z;
        double r574196 = r574194 - r574195;
        double r574197 = t;
        double r574198 = r574196 * r574197;
        double r574199 = a;
        double r574200 = r574199 - r574195;
        double r574201 = r574198 / r574200;
        double r574202 = r574193 + r574201;
        return r574202;
}

double f(double x, double y, double z, double t, double a) {
        double r574203 = t;
        double r574204 = a;
        double r574205 = z;
        double r574206 = r574204 - r574205;
        double r574207 = r574203 / r574206;
        double r574208 = y;
        double r574209 = r574207 * r574208;
        double r574210 = -r574205;
        double r574211 = 1.0;
        double r574212 = r574211 / r574206;
        double r574213 = r574203 * r574212;
        double r574214 = x;
        double r574215 = fma(r574210, r574213, r574214);
        double r574216 = r574209 + r574215;
        return r574216;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.6
Target0.6
Herbie3.0
\[\begin{array}{l} \mathbf{if}\;t \lt -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.9110949887586375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array}\]

Derivation

  1. Initial program 10.6

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

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

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

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

    \[\leadsto \color{blue}{\frac{t}{a - z} \cdot \left(y - z\right)} + x\]
  8. Using strategy rm
  9. Applied sub-neg3.0

    \[\leadsto \frac{t}{a - z} \cdot \color{blue}{\left(y + \left(-z\right)\right)} + x\]
  10. Applied distribute-lft-in3.0

    \[\leadsto \color{blue}{\left(\frac{t}{a - z} \cdot y + \frac{t}{a - z} \cdot \left(-z\right)\right)} + x\]
  11. Applied associate-+l+3.0

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

    \[\leadsto \frac{t}{a - z} \cdot y + \color{blue}{\mathsf{fma}\left(-z, \frac{t}{a - z}, x\right)}\]
  13. Using strategy rm
  14. Applied div-inv3.0

    \[\leadsto \frac{t}{a - z} \cdot y + \mathsf{fma}\left(-z, \color{blue}{t \cdot \frac{1}{a - z}}, x\right)\]
  15. Final simplification3.0

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

Reproduce

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

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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