Average Error: 16.4 → 4.8
Time: 9.1s
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{else}:\\ \;\;\;\;\begin{array}{l} t_2 := \frac{y \cdot z}{a - t}\\ \mathbf{if}\;t_1 \leq -6.1628842594079744 \cdot 10^{-226}:\\ \;\;\;\;\left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - t_2\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\left(1 + \frac{a}{t}\right) \cdot \frac{y \cdot z}{t} + \left(x - \frac{y \cdot a}{t}\right)\\ \mathbf{elif}\;t_1 \leq 8.005786514802402 \cdot 10^{+307}:\\ \;\;\;\;\left(y + \left(x + \frac{y}{\frac{a - t}{t}}\right)\right) - t_2\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \sqrt[3]{t - z}\\ \mathsf{fma}\left(y, \left(t_3 \cdot t_3\right) \cdot \frac{t_3}{a - t}, x + y\right) \end{array}\\ \end{array}\\ \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{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \frac{y \cdot z}{a - t}\\
\mathbf{if}\;t_1 \leq -6.1628842594079744 \cdot 10^{-226}:\\
\;\;\;\;\left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - t_2\\

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

\mathbf{elif}\;t_1 \leq 8.005786514802402 \cdot 10^{+307}:\\
\;\;\;\;\left(y + \left(x + \frac{y}{\frac{a - t}{t}}\right)\right) - t_2\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \sqrt[3]{t - z}\\
\mathsf{fma}\left(y, \left(t_3 \cdot t_3\right) \cdot \frac{t_3}{a - t}, x + y\right)
\end{array}\\


\end{array}\\


\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)))
     (let* ((t_2 (/ (* y z) (- a t))))
       (if (<= t_1 -6.1628842594079744e-226)
         (- (+ y (+ x (/ (* y t) (- a t)))) t_2)
         (if (<= t_1 0.0)
           (+ (* (+ 1.0 (/ a t)) (/ (* y z) t)) (- x (/ (* y a) t)))
           (if (<= t_1 8.005786514802402e+307)
             (- (+ y (+ x (/ y (/ (- a t) t)))) t_2)
             (let* ((t_3 (cbrt (- t z))))
               (fma y (* (* t_3 t_3) (/ t_3 (- a t))) (+ x y))))))))))
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 {
		double t_2 = (y * z) / (a - t);
		double tmp_1;
		if (t_1 <= -6.1628842594079744e-226) {
			tmp_1 = (y + (x + ((y * t) / (a - t)))) - t_2;
		} else if (t_1 <= 0.0) {
			tmp_1 = ((1.0 + (a / t)) * ((y * z) / t)) + (x - ((y * a) / t));
		} else if (t_1 <= 8.005786514802402e+307) {
			tmp_1 = (y + (x + (y / ((a - t) / t)))) - t_2;
		} else {
			double t_3 = cbrt(t - z);
			tmp_1 = fma(y, ((t_3 * t_3) * (t_3 / (a - t))), (x + y));
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.4
Target8.2
Herbie4.8
\[\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 5 regimes
  2. if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -inf.0

    1. Initial program 64.0

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

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

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

      \[\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))) < -6.16288425940797438e-226

    1. Initial program 1.4

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

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

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

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

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

    1. Initial program 57.2

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

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

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

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

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

    1. Initial program 1.6

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

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

      \[\leadsto \color{blue}{\left(y + \left(\frac{y \cdot t}{a - t} + x\right)\right) - \frac{y \cdot z}{a - t}} \]
    4. Applied associate-/l*_binary641.3

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

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

    1. Initial program 63.8

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

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

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

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

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

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

    \[\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 -6.1628842594079744 \cdot 10^{-226}:\\ \;\;\;\;\left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - \frac{y \cdot z}{a - t}\\ \mathbf{elif}\;\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 0:\\ \;\;\;\;\left(1 + \frac{a}{t}\right) \cdot \frac{y \cdot z}{t} + \left(x - \frac{y \cdot a}{t}\right)\\ \mathbf{elif}\;\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 8.005786514802402 \cdot 10^{+307}:\\ \;\;\;\;\left(y + \left(x + \frac{y}{\frac{a - t}{t}}\right)\right) - \frac{y \cdot z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \left(\sqrt[3]{t - z} \cdot \sqrt[3]{t - z}\right) \cdot \frac{\sqrt[3]{t - z}}{a - t}, x + y\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, 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))))