Average Error: 10.9 → 1.7
Time: 4.4s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;a \leq -6.129063740118231 \cdot 10^{-63}:\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\ \mathbf{elif}\;a \leq 7.682638558877552 \cdot 10^{-286}:\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\ \end{array} \]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;a \leq -6.129063740118231 \cdot 10^{-63}:\\
\;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\

\mathbf{elif}\;a \leq 7.682638558877552 \cdot 10^{-286}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\

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


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= a -6.129063740118231e-63)
   (+ x (/ y (/ (- a t) (- z t))))
   (if (<= a 7.682638558877552e-286)
     (+ x (* (- z t) (/ y (- a t))))
     (fma y (/ (- z t) (- a t)) x))))
double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (a <= -6.129063740118231e-63) {
		tmp = x + (y / ((a - t) / (z - t)));
	} else if (a <= 7.682638558877552e-286) {
		tmp = x + ((z - t) * (y / (a - t)));
	} else {
		tmp = fma(y, ((z - t) / (a - t)), x);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.9
Target1.2
Herbie1.7
\[x + \frac{y}{\frac{a - t}{z - t}} \]

Derivation

  1. Split input into 3 regimes
  2. if a < -6.12906374011823067e-63

    1. Initial program 11.8

      \[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
    2. Applied associate-/l*_binary640.4

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

    if -6.12906374011823067e-63 < a < 7.6826385588775523e-286

    1. Initial program 9.7

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

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

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

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

    if 7.6826385588775523e-286 < a

    1. Initial program 10.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -6.129063740118231 \cdot 10^{-63}:\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\ \mathbf{elif}\;a \leq 7.682638558877552 \cdot 10^{-286}:\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2021280 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, B"
  :precision binary64

  :herbie-target
  (+ x (/ y (/ (- a t) (- z t))))

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