Average Error: 10.7 → 1.7
Time: 9.8s
Precision: binary64
\[x + \frac{\left(y - z\right) \cdot t}{a - z} \]
\[\begin{array}{l} \mathbf{if}\;a \leq -4.362131686997494 \cdot 10^{-102} \lor \neg \left(a \leq -1.726985926064031 \cdot 10^{-268}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z} + x\\ \mathbf{else}:\\ \;\;\;\;t + \left(x + \frac{t \cdot y}{a - z}\right)\\ \end{array} \]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;a \leq -4.362131686997494 \cdot 10^{-102} \lor \neg \left(a \leq -1.726985926064031 \cdot 10^{-268}\right):\\
\;\;\;\;t \cdot \frac{y - z}{a - z} + x\\

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


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= a -4.362131686997494e-102) (not (<= a -1.726985926064031e-268)))
   (+ (* t (/ (- y z) (- a z))) x)
   (+ t (+ x (/ (* t y) (- a z))))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - z) * t) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((a <= -4.362131686997494e-102) || !(a <= -1.726985926064031e-268)) {
		tmp = (t * ((y - z) / (a - z))) + x;
	} else {
		tmp = t + (x + ((t * y) / (a - z)));
	}
	return tmp;
}

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.7
Target0.6
Herbie1.7
\[\begin{array}{l} \mathbf{if}\;t < -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t < 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. Split input into 2 regimes
  2. if a < -4.36213168699749418e-102 or -1.7269859260640311e-268 < a

    1. Initial program 10.7

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

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

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

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

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

    if -4.36213168699749418e-102 < a < -1.7269859260640311e-268

    1. Initial program 10.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t}{a - z}, x\right)} \]
    3. Taylor expanded in y around 0 10.5

      \[\leadsto \color{blue}{\left(\frac{y \cdot t}{a - z} + x\right) - \frac{t \cdot z}{a - z}} \]
    4. Taylor expanded in z around inf 5.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.362131686997494 \cdot 10^{-102} \lor \neg \left(a \leq -1.726985926064031 \cdot 10^{-268}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z} + x\\ \mathbf{else}:\\ \;\;\;\;t + \left(x + \frac{t \cdot y}{a - z}\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2021340 
(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))))