Average Error: 10.8 → 2.8
Time: 4.2s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\frac{t}{a - z} \cdot \left(y - z\right) + x\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\frac{t}{a - z} \cdot \left(y - z\right) + x
double f(double x, double y, double z, double t, double a) {
        double r596139 = x;
        double r596140 = y;
        double r596141 = z;
        double r596142 = r596140 - r596141;
        double r596143 = t;
        double r596144 = r596142 * r596143;
        double r596145 = a;
        double r596146 = r596145 - r596141;
        double r596147 = r596144 / r596146;
        double r596148 = r596139 + r596147;
        return r596148;
}

double f(double x, double y, double z, double t, double a) {
        double r596149 = t;
        double r596150 = a;
        double r596151 = z;
        double r596152 = r596150 - r596151;
        double r596153 = r596149 / r596152;
        double r596154 = y;
        double r596155 = r596154 - r596151;
        double r596156 = r596153 * r596155;
        double r596157 = x;
        double r596158 = r596156 + r596157;
        return r596158;
}

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.8
Target0.6
Herbie2.8
\[\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.8

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

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

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

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

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

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

Reproduce

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