Average Error: 16.8 → 4.5
Time: 17.7s
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}\\ t_2 := x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \frac{y \cdot z}{a - t}\\ t_4 := \left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - t_3\\ \mathbf{if}\;t_1 \leq -9.834406028251618 \cdot 10^{-271}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_1 \leq 8.645163535653227 \cdot 10^{-224}:\\ \;\;\;\;\left(x - \frac{y \cdot a}{t}\right) - t_3\\ \mathbf{elif}\;t_1 \leq 1.3639970178885283 \cdot 10^{+305}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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}\\
t_2 := x + \frac{y}{t} \cdot \left(z - a\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \frac{y \cdot z}{a - t}\\
t_4 := \left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - t_3\\
\mathbf{if}\;t_1 \leq -9.834406028251618 \cdot 10^{-271}:\\
\;\;\;\;t_4\\

\mathbf{elif}\;t_1 \leq 8.645163535653227 \cdot 10^{-224}:\\
\;\;\;\;\left(x - \frac{y \cdot a}{t}\right) - t_3\\

\mathbf{elif}\;t_1 \leq 1.3639970178885283 \cdot 10^{+305}:\\
\;\;\;\;t_4\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\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))))
        (t_2 (+ x (* (/ y t) (- z a)))))
   (if (<= t_1 (- INFINITY))
     t_2
     (let* ((t_3 (/ (* y z) (- a t)))
            (t_4 (- (+ y (+ x (/ (* y t) (- a t)))) t_3)))
       (if (<= t_1 -9.834406028251618e-271)
         t_4
         (if (<= t_1 8.645163535653227e-224)
           (- (- x (/ (* y a) t)) t_3)
           (if (<= t_1 1.3639970178885283e+305) t_4 t_2)))))))
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 t_2 = x + ((y / t) * (z - a));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = t_2;
	} else {
		double t_3 = (y * z) / (a - t);
		double t_4 = (y + (x + ((y * t) / (a - t)))) - t_3;
		double tmp_1;
		if (t_1 <= -9.834406028251618e-271) {
			tmp_1 = t_4;
		} else if (t_1 <= 8.645163535653227e-224) {
			tmp_1 = (x - ((y * a) / t)) - t_3;
		} else if (t_1 <= 1.3639970178885283e+305) {
			tmp_1 = t_4;
		} else {
			tmp_1 = t_2;
		}
		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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

    1. Initial program 62.8

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

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

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

      \[\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))) < -9.8344060282516176e-271 or 8.64516e-224 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 1.3639970178885283e305

    1. Initial program 1.3

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

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

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

    if -9.8344060282516176e-271 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 8.64516e-224

    1. Initial program 57.5

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

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

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

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

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

    \[\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 -9.834406028251618 \cdot 10^{-271}:\\ \;\;\;\;\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 8.645163535653227 \cdot 10^{-224}:\\ \;\;\;\;\left(x - \frac{y \cdot a}{t}\right) - \frac{y \cdot z}{a - t}\\ \mathbf{elif}\;\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 1.3639970178885283 \cdot 10^{+305}:\\ \;\;\;\;\left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - \frac{y \cdot z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \end{array} \]

Reproduce

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