?

Average Error: 16.4 → 5.6
Time: 14.8s
Precision: binary64
Cost: 3532

?

\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} t_1 := \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + \left(z - a\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{-237}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{y \cdot \left(z - a\right)}{t} + x\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) - y \cdot \frac{z - t}{a - t}\\ \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) (/ (* (- z t) y) (- a t)))))
   (if (<= t_1 (- INFINITY))
     (+ x (* (- z a) (/ y t)))
     (if (<= t_1 -1e-237)
       t_1
       (if (<= t_1 0.0)
         (+ (/ (* y (- z a)) t) x)
         (- (+ x y) (* y (/ (- z t) (- 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 t_1 = (x + y) - (((z - t) * y) / (a - t));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = x + ((z - a) * (y / t));
	} else if (t_1 <= -1e-237) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = ((y * (z - a)) / t) + x;
	} else {
		tmp = (x + y) - (y * ((z - t) / (a - t)));
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	return (x + y) - (((z - t) * y) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (x + y) - (((z - t) * y) / (a - t));
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = x + ((z - a) * (y / t));
	} else if (t_1 <= -1e-237) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = ((y * (z - a)) / t) + x;
	} else {
		tmp = (x + y) - (y * ((z - t) / (a - t)));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return (x + y) - (((z - t) * y) / (a - t))
def code(x, y, z, t, a):
	t_1 = (x + y) - (((z - t) * y) / (a - t))
	tmp = 0
	if t_1 <= -math.inf:
		tmp = x + ((z - a) * (y / t))
	elif t_1 <= -1e-237:
		tmp = t_1
	elif t_1 <= 0.0:
		tmp = ((y * (z - a)) / t) + x
	else:
		tmp = (x + y) - (y * ((z - t) / (a - t)))
	return tmp
function code(x, y, z, t, a)
	return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t)))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t)))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(x + Float64(Float64(z - a) * Float64(y / t)));
	elseif (t_1 <= -1e-237)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = Float64(Float64(Float64(y * Float64(z - a)) / t) + x);
	else
		tmp = Float64(Float64(x + y) - Float64(y * Float64(Float64(z - t) / Float64(a - t))));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = (x + y) - (((z - t) * y) / (a - t));
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x + y) - (((z - t) * y) / (a - t));
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = x + ((z - a) * (y / t));
	elseif (t_1 <= -1e-237)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = ((y * (z - a)) / t) + x;
	else
		tmp = (x + y) - (y * ((z - t) / (a - t)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x + N[(N[(z - a), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-237], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(N[(y * N[(z - a), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(x + y), $MachinePrecision] - N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
t_1 := \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x + \left(z - a\right) \cdot \frac{y}{t}\\

\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-237}:\\
\;\;\;\;t_1\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.4
Target8.4
Herbie5.6
\[\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 4 regimes
  2. if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -inf.0

    1. Initial program 64.0

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

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

      [Start]64.0

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

      rational_best-simplify-47 [=>]28.6

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot a - y \cdot z}{t} + x} \]
    4. Simplified17.9

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

      [Start]39.0

      \[ -1 \cdot \frac{y \cdot a - y \cdot z}{t} + x \]

      rational_best-simplify-1 [=>]39.0

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

      rational_best-simplify-2 [=>]39.0

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

      rational_best-simplify-12 [=>]39.0

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

      rational_best-simplify-10 [=>]39.0

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

      rational_best-simplify-53 [=>]39.0

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

      rational_best-simplify-46 [=>]39.0

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

      rational_best-simplify-4 [=>]39.0

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

      rational_best-simplify-53 [<=]39.0

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

      rational_best-simplify-50 [=>]39.0

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

      rational_best-simplify-47 [=>]17.9

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

    if -inf.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -9.9999999999999999e-238

    1. Initial program 1.5

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

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

    1. Initial program 57.2

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

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

      [Start]57.2

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

      rational_best-simplify-2 [=>]57.2

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

      rational_best-simplify-47 [=>]57.5

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot a - y \cdot z}{t} + x} \]
    4. Simplified2.3

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

      [Start]2.5

      \[ -1 \cdot \frac{y \cdot a - y \cdot z}{t} + x \]

      rational_best-simplify-1 [=>]2.5

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

      rational_best-simplify-2 [=>]2.5

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

      rational_best-simplify-12 [=>]2.5

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

      rational_best-simplify-10 [=>]2.5

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

      rational_best-simplify-53 [=>]2.5

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

      rational_best-simplify-46 [=>]2.5

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

      rational_best-simplify-4 [=>]2.5

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

      rational_best-simplify-53 [<=]2.5

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

      rational_best-simplify-50 [=>]2.5

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

      rational_best-simplify-2 [=>]2.5

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

      rational_best-simplify-47 [=>]2.3

      \[ x + \color{blue}{y \cdot \frac{z - a}{t}} \]
    5. Taylor expanded in x around 0 2.5

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

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

    1. Initial program 12.8

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

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

      [Start]12.8

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

      rational_best-simplify-47 [=>]7.3

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

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

Alternatives

Alternative 1
Error14.5
Cost1104
\[\begin{array}{l} t_1 := x + y \cdot \frac{z - a}{t}\\ \mathbf{if}\;a \leq -1.6 \cdot 10^{+74}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 0.0048:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 7.9 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 2
Error14.6
Cost1104
\[\begin{array}{l} t_1 := x + \left(z - a\right) \cdot \frac{y}{t}\\ \mathbf{if}\;t \leq -195000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.3 \cdot 10^{+36}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 7.5 \cdot 10^{+61}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{+77}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error11.5
Cost1104
\[\begin{array}{l} t_1 := x + \left(z - a\right) \cdot \frac{y}{t}\\ \mathbf{if}\;t \leq -7900000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{+36}:\\ \;\;\;\;\left(y + x\right) - y \cdot \frac{z}{a}\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{+56}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{+77}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error7.6
Cost1096
\[\begin{array}{l} t_1 := x + \left(z - a\right) \cdot \frac{y}{t}\\ \mathbf{if}\;t \leq -1200000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.4 \cdot 10^{+90}:\\ \;\;\;\;\left(x + y\right) - y \cdot \frac{z - t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error20.5
Cost720
\[\begin{array}{l} \mathbf{if}\;a \leq -3.5 \cdot 10^{-88}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq -6.6 \cdot 10^{-259}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq -6.2 \cdot 10^{-299}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-117}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 6
Error15.1
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -1.35 \cdot 10^{+74}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{-103}:\\ \;\;\;\;y \cdot \frac{z}{t} + x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 7
Error28.3
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-108}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-215}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-292}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-87}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error20.7
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -4.8 \cdot 10^{+71}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{+192}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error29.0
Cost64
\[x \]

Error

Reproduce?

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