Average Error: 17.0 → 5.0
Time: 7.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{elif}\;t_1 \leq -8.395939912127468 \cdot 10^{-255} \lor \neg \left(t_1 \leq 0\right) \land t_1 \leq 1.1118112080121773 \cdot 10^{+296}:\\ \;\;\;\;\left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - \frac{y \cdot z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \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 -8.395939912127468 \cdot 10^{-255} \lor \neg \left(t_1 \leq 0\right) \land t_1 \leq 1.1118112080121773 \cdot 10^{+296}:\\
\;\;\;\;\left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - \frac{y \cdot z}{a - t}\\

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


\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 (or (<= t_1 -8.395939912127468e-255)
             (and (not (<= t_1 0.0)) (<= t_1 1.1118112080121773e+296)))
       (- (+ y (+ x (/ (* y t) (- a t)))) (/ (* y z) (- a t)))
       (+ x (* y (/ (- z a) t)))))))
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 <= -8.395939912127468e-255) || (!(t_1 <= 0.0) && (t_1 <= 1.1118112080121773e+296))) {
		tmp = (y + (x + ((y * t) / (a - t)))) - ((y * z) / (a - t));
	} else {
		tmp = x + (y * ((z - a) / t));
	}
	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

Original17.0
Target8.5
Herbie5.0
\[\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

    1. Initial program 64.0

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

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

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

      \[\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))) < -8.3959399121274677e-255 or 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 1.11181120801217729e296

    1. Initial program 1.6

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

      \[\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}} \]

    if -8.3959399121274677e-255 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0 or 1.11181120801217729e296 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t)))

    1. Initial program 57.4

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

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

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

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

      \[\leadsto x + \color{blue}{\left(y \cdot \frac{1}{t}\right)} \cdot \left(z - a\right) \]
    6. Applied associate-*l*_binary6411.6

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

      \[\leadsto x + y \cdot \color{blue}{\frac{z - a}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification5.0

    \[\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 -8.395939912127468 \cdot 10^{-255} \lor \neg \left(\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 0\right) \land \left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 1.1118112080121773 \cdot 10^{+296}:\\ \;\;\;\;\left(y + \left(x + \frac{y \cdot t}{a - t}\right)\right) - \frac{y \cdot z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \end{array} \]

Reproduce

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