Average Error: 14.5 → 6.1
Time: 11.6s
Precision: binary64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} t_1 := \left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{elif}\;t_1 \leq -1.249178333079565 \cdot 10^{-218}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\left(x + \frac{y \cdot z}{t}\right) - \frac{y \cdot a}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + \mathsf{fma}\left(\frac{y}{a - t}, t, x\right)\right) - \frac{y}{\frac{a - t}{z}}\\ \end{array} \]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
t_1 := \left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\

\mathbf{elif}\;t_1 \leq -1.249178333079565 \cdot 10^{-218}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\left(x + \frac{y \cdot z}{t}\right) - \frac{y \cdot a}{t}\\

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


\end{array}
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (+ x y) (/ (* y (- z t)) (- a t)))))
   (if (<= t_1 (- INFINITY))
     (+ x (* (/ y t) (- z a)))
     (if (<= t_1 -1.249178333079565e-218)
       t_1
       (if (<= t_1 0.0)
         (- (+ x (/ (* y z) t)) (/ (* y a) t))
         (- (+ y (fma (/ y (- a t)) t x)) (/ y (/ (- a t) z))))))))
double code(double x, double y, double z, double t, double a) {
	return (x + y) - (((z - t) * y) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x + y) - ((y * (z - t)) / (a - t));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = x + ((y / t) * (z - a));
	} else if (t_1 <= -1.249178333079565e-218) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = (x + ((y * z) / t)) - ((y * a) / t);
	} else {
		tmp = (y + fma((y / (a - t)), t, x)) - (y / ((a - t) / z));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original14.5
Target7.7
Herbie6.1
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < -1.3664970889390727 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < 1.4754293444577233 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array} \]

Derivation

  1. Split input into 4 regimes
  2. if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -inf.0

    1. Initial program 39.1

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

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

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

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

    if -inf.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -1.24917833307956512e-218

    1. Initial program 1.5

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

    if -1.24917833307956512e-218 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0

    1. Initial program 56.2

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{1}{\frac{a - t}{t - z}}}, x + y\right) \]
    4. Taylor expanded in t around inf 3.8

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

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

    if 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t)))

    1. Initial program 11.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{t - z}{a - t}, x + y\right)} \]
    3. Applied add-cube-cbrt_binary647.0

      \[\leadsto \mathsf{fma}\left(y, \frac{t - z}{\color{blue}{\left(\sqrt[3]{a - t} \cdot \sqrt[3]{a - t}\right) \cdot \sqrt[3]{a - t}}}, x + y\right) \]
    4. Applied *-un-lft-identity_binary647.0

      \[\leadsto \mathsf{fma}\left(y, \frac{\color{blue}{1 \cdot \left(t - z\right)}}{\left(\sqrt[3]{a - t} \cdot \sqrt[3]{a - t}\right) \cdot \sqrt[3]{a - t}}, x + y\right) \]
    5. Applied times-frac_binary647.0

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

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

      \[\leadsto \color{blue}{\left(y + \mathsf{fma}\left(\frac{y}{a - t}, t, x\right)\right) - \frac{y \cdot z}{a - t}} \]
    8. Applied associate-/l*_binary646.8

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

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

Reproduce

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

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))

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