Average Error: 16.0 → 7.1
Time: 5.6s
Precision: binary64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \leq -1.0008921998682885 \cdot 10^{-93} \lor \neg \left(a \leq 3.484466297480128 \cdot 10^{-263}\right):\\ \;\;\;\;x + y \cdot \left(1 - \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 -1.0008921998682885 \cdot 10^{-93} \lor \neg \left(a \leq 3.484466297480128 \cdot 10^{-263}\right):\\
\;\;\;\;x + y \cdot \left(1 - \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 -1.0008921998682885e-93) (not (<= a 3.484466297480128e-263)))
   (+ x (* y (- 1.0 (/ (- z t) (- a t)))))
   (+ x (/ z (/ t y)))))
double code(double x, double y, double z, double t, double a) {
	return ((double) (((double) (x + y)) - (((double) (((double) (z - t)) * y)) / ((double) (a - t)))));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((a <= -1.0008921998682885e-93) || !(a <= 3.484466297480128e-263))) {
		tmp = ((double) (x + ((double) (y * ((double) (1.0 - (((double) (z - t)) / ((double) (a - t)))))))));
	} else {
		tmp = ((double) (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.0
Target8.5
Herbie7.1
\[\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 < -1.0008921998682885e-93 or 3.484466297480128e-263 < a

    1. Initial program 15.4

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

      \[\leadsto \left(x + y\right) - \color{blue}{\frac{z - t}{\frac{a - t}{y}}}\]
    4. Using strategy rm
    5. Applied associate--l+_binary648.2

      \[\leadsto \color{blue}{x + \left(y - \frac{z - t}{\frac{a - t}{y}}\right)}\]
    6. Using strategy rm
    7. Applied associate-/r/_binary646.5

      \[\leadsto x + \left(y - \color{blue}{\frac{z - t}{a - t} \cdot y}\right)\]
    8. Applied *-un-lft-identity_binary646.5

      \[\leadsto x + \left(\color{blue}{1 \cdot y} - \frac{z - t}{a - t} \cdot y\right)\]
    9. Applied distribute-rgt-out--_binary646.5

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

    if -1.0008921998682885e-93 < a < 3.484466297480128e-263

    1. Initial program 18.6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.0008921998682885 \cdot 10^{-93} \lor \neg \left(a \leq 3.484466297480128 \cdot 10^{-263}\right):\\ \;\;\;\;x + y \cdot \left(1 - \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \end{array}\]

Reproduce

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