Average Error: 15.0 → 6.5
Time: 4.5s
Precision: binary64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -2.2944451371658341 \cdot 10^{+77}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{elif}\;t \leq 5.1285840833626966 \cdot 10^{+75}:\\ \;\;\;\;\left(y + \left(x + \frac{t \cdot y}{a - t}\right)\right) - \frac{y \cdot z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \end{array} \]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -2.2944451371658341 \cdot 10^{+77}:\\
\;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\

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

\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{a - 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
 (if (<= t -2.2944451371658341e+77)
   (+ x (* (/ y t) (- z a)))
   (if (<= t 5.1285840833626966e+75)
     (- (+ y (+ x (/ (* t y) (- a t)))) (/ (* y z) (- a t)))
     (- x (/ y (/ t (- a 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 tmp;
	if (t <= -2.2944451371658341e+77) {
		tmp = x + ((y / t) * (z - a));
	} else if (t <= 5.1285840833626966e+75) {
		tmp = (y + (x + ((t * y) / (a - t)))) - ((y * z) / (a - t));
	} else {
		tmp = x - (y / (t / (a - z)));
	}
	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

Original15.0
Target7.9
Herbie6.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 t < -2.29444513716583415e77

    1. Initial program 28.7

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

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

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

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

    if -2.29444513716583415e77 < t < 5.1285840833626966e75

    1. Initial program 6.8

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

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

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

    if 5.1285840833626966e75 < t

    1. Initial program 28.3

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

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

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

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

      \[\leadsto x + \color{blue}{-1 \cdot \frac{y \cdot a - y \cdot z}{t}} \]
    6. Simplified7.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.2944451371658341 \cdot 10^{+77}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{elif}\;t \leq 5.1285840833626966 \cdot 10^{+75}:\\ \;\;\;\;\left(y + \left(x + \frac{t \cdot y}{a - t}\right)\right) - \frac{y \cdot z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \end{array} \]

Reproduce

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