Average Error: 16.4 → 6.9
Time: 10.1s
Precision: binary64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \leq -5.872757969820095 \cdot 10^{-163} \lor \neg \left(a \leq 5.980147012370445 \cdot 10^{-155}\right):\\ \;\;\;\;x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;a \leq -5.872757969820095 \cdot 10^{-163} \lor \neg \left(a \leq 5.980147012370445 \cdot 10^{-155}\right):\\
\;\;\;\;x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\

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

\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 (or (<= a -5.872757969820095e-163) (not (<= a 5.980147012370445e-155)))
   (+ x (- y (* y (/ (- z t) (- a t)))))
   (+ x (/ z (/ t 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 tmp;
	if ((a <= -5.872757969820095e-163) || !(a <= 5.980147012370445e-155)) {
		tmp = x + (y - (y * ((z - t) / (a - t))));
	} else {
		tmp = x + (z / (t / y));
	}
	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.4
Target8.5
Herbie6.9
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < -1.3664970889390727 \cdot 10^{-07}:\\ \;\;\;\;\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 2 regimes
  2. if a < -5.87283e-163 or 5.98012e-155 < a

    1. Initial program 15.2

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Using strategy rm
    3. Applied associate--l+_binary64_512413.7

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

      \[\leadsto x + \color{blue}{\left(y - \frac{y}{a - t} \cdot \left(z - t\right)\right)}\]
    5. Using strategy rm
    6. Applied div-inv_binary64_50698.2

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

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

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

    if -5.87283e-163 < a < 5.98012e-155

    1. Initial program 20.5

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Using strategy rm
    3. Applied associate-/l*_binary64_513219.5

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

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
    5. Simplified8.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -5.872757969820095 \cdot 10^{-163} \lor \neg \left(a \leq 5.980147012370445 \cdot 10^{-155}\right):\\ \;\;\;\;x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020231 
(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-07) (- (+ 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))))