Average Error: 15.9 → 2.8
Time: 6.5s
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(z - t\right)}{a - t} \leq -2.4909642387543203 \cdot 10^{-274}:\\ \;\;\;\;x + y \cdot \left(\left(\frac{t}{a - t} + 1\right) - \frac{z}{a - t}\right)\\ \mathbf{elif}\;\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 0:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot a}{t}\\ \mathbf{elif}\;\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 1.716543440126991 \cdot 10^{+291}:\\ \;\;\;\;x + \left(\left(y + \frac{y \cdot t}{a - t}\right) - \frac{y \cdot z}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(\left(\frac{t}{a - t} + 1\right) - \frac{z}{a - t}\right)\\ \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(z - t\right)}{a - t} \leq -2.4909642387543203 \cdot 10^{-274}:\\
\;\;\;\;x + y \cdot \left(\left(\frac{t}{a - t} + 1\right) - \frac{z}{a - t}\right)\\

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

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

\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(\left(\frac{t}{a - t} + 1\right) - \frac{z}{a - t}\right)\\

\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 (<= (- (+ x y) (/ (* y (- z t)) (- a t))) -2.4909642387543203e-274)
   (+ x (* y (- (+ (/ t (- a t)) 1.0) (/ z (- a t)))))
   (if (<= (- (+ x y) (/ (* y (- z t)) (- a t))) 0.0)
     (+ x (/ (- (* y z) (* y a)) t))
     (if (<= (- (+ x y) (/ (* y (- z t)) (- a t))) 1.716543440126991e+291)
       (+ x (- (+ y (/ (* y t) (- a t))) (/ (* y z) (- a t))))
       (+ x (* y (- (+ (/ t (- a t)) 1.0) (/ 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 tmp;
	if (((x + y) - ((y * (z - t)) / (a - t))) <= -2.4909642387543203e-274) {
		tmp = x + (y * (((t / (a - t)) + 1.0) - (z / (a - t))));
	} else if (((x + y) - ((y * (z - t)) / (a - t))) <= 0.0) {
		tmp = x + (((y * z) - (y * a)) / t);
	} else if (((x + y) - ((y * (z - t)) / (a - t))) <= 1.716543440126991e+291) {
		tmp = x + ((y + ((y * t) / (a - t))) - ((y * z) / (a - t)));
	} else {
		tmp = x + (y * (((t / (a - t)) + 1.0) - (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

Original15.9
Target8.4
Herbie2.8
\[\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 3 regimes
  2. if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -2.4909642387543203e-274 or 1.716543440126991e291 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t)))

    1. Initial program 19.1

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

      \[\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 - \left(z - t\right) \cdot \frac{y}{a - t}\right)}\]
    5. Taylor expanded around 0 4.0

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

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

    1. Initial program 60.2

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

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

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

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

    if 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 1.716543440126991e291

    1. Initial program 1.7

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Taylor expanded around 0 1.4

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

      \[\leadsto \color{blue}{\left(\left(y + \frac{t \cdot y}{a - t}\right) - \frac{y \cdot z}{a - t}\right) + x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq -2.4909642387543203 \cdot 10^{-274}:\\ \;\;\;\;x + y \cdot \left(\left(\frac{t}{a - t} + 1\right) - \frac{z}{a - t}\right)\\ \mathbf{elif}\;\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 0:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot a}{t}\\ \mathbf{elif}\;\left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t} \leq 1.716543440126991 \cdot 10^{+291}:\\ \;\;\;\;x + \left(\left(y + \frac{y \cdot t}{a - t}\right) - \frac{y \cdot z}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(\left(\frac{t}{a - t} + 1\right) - \frac{z}{a - t}\right)\\ \end{array}\]

Alternatives

Reproduce

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