Average Error: 14.5 → 5.9
Time: 5.2s
Precision: binary64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} t_1 := x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{if}\;t \leq -1.9658820839659733 \cdot 10^{+171}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\ \mathbf{if}\;t \leq -1.1983208753291875 \cdot 10^{+129}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.8329458807432838 \cdot 10^{+68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.085746189680331 \cdot 10^{-107}:\\ \;\;\;\;\begin{array}{l} t_3 := \sqrt[3]{a - t}\\ \left(x + y\right) - \frac{z - t}{t_3 \cdot t_3} \cdot \frac{y}{t_3} \end{array}\\ \mathbf{elif}\;t \leq 6.631897434957769 \cdot 10^{+108}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ \end{array} \]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
t_1 := x + \frac{y}{t} \cdot \left(z - a\right)\\
\mathbf{if}\;t \leq -1.9658820839659733 \cdot 10^{+171}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\
\mathbf{if}\;t \leq -1.1983208753291875 \cdot 10^{+129}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq -1.8329458807432838 \cdot 10^{+68}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq 7.085746189680331 \cdot 10^{-107}:\\
\;\;\;\;\begin{array}{l}
t_3 := \sqrt[3]{a - t}\\
\left(x + y\right) - \frac{z - t}{t_3 \cdot t_3} \cdot \frac{y}{t_3}
\end{array}\\

\mathbf{elif}\;t \leq 6.631897434957769 \cdot 10^{+108}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}\\


\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
 (let* ((t_1 (+ x (* (/ y t) (- z a)))))
   (if (<= t -1.9658820839659733e+171)
     t_1
     (let* ((t_2 (+ x (- y (* y (/ (- z t) (- a t)))))))
       (if (<= t -1.1983208753291875e+129)
         t_2
         (if (<= t -1.8329458807432838e+68)
           t_1
           (if (<= t 7.085746189680331e-107)
             (let* ((t_3 (cbrt (- a t))))
               (- (+ x y) (* (/ (- z t) (* t_3 t_3)) (/ y t_3))))
             (if (<= t 6.631897434957769e+108) t_2 t_1))))))))
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 t_1 = x + ((y / t) * (z - a));
	double tmp;
	if (t <= -1.9658820839659733e+171) {
		tmp = t_1;
	} else {
		double t_2 = x + (y - (y * ((z - t) / (a - t))));
		double tmp_1;
		if (t <= -1.1983208753291875e+129) {
			tmp_1 = t_2;
		} else if (t <= -1.8329458807432838e+68) {
			tmp_1 = t_1;
		} else if (t <= 7.085746189680331e-107) {
			double t_3 = cbrt(a - t);
			tmp_1 = (x + y) - (((z - t) / (t_3 * t_3)) * (y / t_3));
		} else if (t <= 6.631897434957769e+108) {
			tmp_1 = t_2;
		} else {
			tmp_1 = t_1;
		}
		tmp = tmp_1;
	}
	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

Original14.5
Target7.7
Herbie5.9
\[\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 < -1.96588208396597326e171 or -1.19832087532918747e129 < t < -1.8329458807432838e68 or 6.63189743495776931e108 < t

    1. Initial program 29.0

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

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

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

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

    if -1.96588208396597326e171 < t < -1.19832087532918747e129 or 7.0857461896803313e-107 < t < 6.63189743495776931e108

    1. Initial program 13.9

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

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

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

    if -1.8329458807432838e68 < t < 7.0857461896803313e-107

    1. Initial program 4.9

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
    2. Applied add-cube-cbrt_binary645.1

      \[\leadsto \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{\color{blue}{\left(\sqrt[3]{a - t} \cdot \sqrt[3]{a - t}\right) \cdot \sqrt[3]{a - t}}} \]
    3. Applied times-frac_binary644.3

      \[\leadsto \left(x + y\right) - \color{blue}{\frac{z - t}{\sqrt[3]{a - t} \cdot \sqrt[3]{a - t}} \cdot \frac{y}{\sqrt[3]{a - t}}} \]
    4. Applied cancel-sign-sub-inv_binary644.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.9658820839659733 \cdot 10^{+171}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{elif}\;t \leq -1.1983208753291875 \cdot 10^{+129}:\\ \;\;\;\;x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\ \mathbf{elif}\;t \leq -1.8329458807432838 \cdot 10^{+68}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{elif}\;t \leq 7.085746189680331 \cdot 10^{-107}:\\ \;\;\;\;\left(x + y\right) - \frac{z - t}{\sqrt[3]{a - t} \cdot \sqrt[3]{a - t}} \cdot \frac{y}{\sqrt[3]{a - t}}\\ \mathbf{elif}\;t \leq 6.631897434957769 \cdot 10^{+108}:\\ \;\;\;\;x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \end{array} \]

Reproduce

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