Average Error: 16.8 → 3.3
Time: 15.3s
Precision: binary64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) + \frac{y \cdot \left(t - z\right)}{a - t} \leq -6.561161651869361 \cdot 10^{-249} \lor \neg \left(\left(x + y\right) + \frac{y \cdot \left(t - z\right)}{a - t} \leq 0\right):\\ \;\;\;\;x - y \cdot \left(\frac{z}{a - t} + \left(-1 - \frac{t}{a - t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - a}}\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;\left(x + y\right) + \frac{y \cdot \left(t - z\right)}{a - t} \leq -6.561161651869361 \cdot 10^{-249} \lor \neg \left(\left(x + y\right) + \frac{y \cdot \left(t - z\right)}{a - t} \leq 0\right):\\
\;\;\;\;x - y \cdot \left(\frac{z}{a - t} + \left(-1 - \frac{t}{a - t}\right)\right)\\

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

\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 (<= (+ (+ x y) (/ (* y (- t z)) (- a t))) -6.561161651869361e-249)
         (not (<= (+ (+ x y) (/ (* y (- t z)) (- a t))) 0.0)))
   (- x (* y (+ (/ z (- a t)) (- -1.0 (/ t (- a t))))))
   (+ x (/ y (/ t (- z a))))))
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 ((((x + y) + ((y * (t - z)) / (a - t))) <= -6.561161651869361e-249) || !(((x + y) + ((y * (t - z)) / (a - t))) <= 0.0)) {
		tmp = x - (y * ((z / (a - t)) + (-1.0 - (t / (a - t)))));
	} else {
		tmp = x + (y / (t / (z - a)));
	}
	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.7
Herbie3.3
\[\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 (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -6.5611616518693612e-249 or 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t)))

    1. Initial program 12.9

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

      \[\leadsto \color{blue}{x + \left(y + \frac{y}{a - t} \cdot \left(t - z\right)\right)}\]
    3. Taylor expanded around 0 3.6

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

    if -6.5611616518693612e-249 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0

    1. Initial program 59.8

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

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

      \[\leadsto x + \color{blue}{\frac{z \cdot y - a \cdot y}{t}}\]
    4. Simplified0.7

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

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

Reproduce

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