?

Average Error: 16.3 → 5.9
Time: 13.9s
Precision: binary64
Cost: 1096

?

\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -1.12 \cdot 10^{+185}:\\ \;\;\;\;x + \frac{\frac{y}{t}}{\frac{-1}{a - z}}\\ \mathbf{elif}\;t \leq 1.8 \cdot 10^{+84}:\\ \;\;\;\;x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - 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
 (if (<= t -1.12e+185)
   (+ x (/ (/ y t) (/ -1.0 (- a z))))
   (if (<= t 1.8e+84)
     (+ x (- y (* y (/ (- z t) (- a t)))))
     (+ x (* y (/ (- 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 (t <= -1.12e+185) {
		tmp = x + ((y / t) / (-1.0 / (a - z)));
	} else if (t <= 1.8e+84) {
		tmp = x + (y - (y * ((z - t) / (a - t))));
	} else {
		tmp = x + (y * ((z - a) / t));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = (x + y) - (((z - t) * y) / (a - t))
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: tmp
    if (t <= (-1.12d+185)) then
        tmp = x + ((y / t) / ((-1.0d0) / (a - z)))
    else if (t <= 1.8d+84) then
        tmp = x + (y - (y * ((z - t) / (a - t))))
    else
        tmp = x + (y * ((z - a) / t))
    end if
    code = tmp
end function
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 tmp;
	if (t <= -1.12e+185) {
		tmp = x + ((y / t) / (-1.0 / (a - z)));
	} else if (t <= 1.8e+84) {
		tmp = x + (y - (y * ((z - t) / (a - t))));
	} else {
		tmp = x + (y * ((z - 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):
	tmp = 0
	if t <= -1.12e+185:
		tmp = x + ((y / t) / (-1.0 / (a - z)))
	elif t <= 1.8e+84:
		tmp = x + (y - (y * ((z - t) / (a - t))))
	else:
		tmp = x + (y * ((z - 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)
	tmp = 0.0
	if (t <= -1.12e+185)
		tmp = Float64(x + Float64(Float64(y / t) / Float64(-1.0 / Float64(a - z))));
	elseif (t <= 1.8e+84)
		tmp = Float64(x + Float64(y - Float64(y * Float64(Float64(z - t) / Float64(a - t)))));
	else
		tmp = Float64(x + Float64(y * Float64(Float64(z - 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)
	tmp = 0.0;
	if (t <= -1.12e+185)
		tmp = x + ((y / t) / (-1.0 / (a - z)));
	elseif (t <= 1.8e+84)
		tmp = x + (y - (y * ((z - t) / (a - t))));
	else
		tmp = x + (y * ((z - 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_] := If[LessEqual[t, -1.12e+185], N[(x + N[(N[(y / t), $MachinePrecision] / N[(-1.0 / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.8e+84], N[(x + N[(y - N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(z - a), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -1.12 \cdot 10^{+185}:\\
\;\;\;\;x + \frac{\frac{y}{t}}{\frac{-1}{a - z}}\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.3
Target8.4
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.11999999999999996e185

    1. Initial program 34.8

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

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

      [Start]34.8

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

      rational.json-simplify-1 [=>]34.8

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

      rational.json-simplify-48 [=>]30.3

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

      rational.json-simplify-2 [=>]30.3

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

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

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

      [Start]13.9

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

      rational.json-simplify-2 [<=]13.9

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

      rational.json-simplify-43 [=>]13.9

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

      rational.json-simplify-43 [=>]13.9

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

      rational.json-simplify-2 [=>]13.9

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

      rational.json-simplify-52 [=>]13.9

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

      rational.json-simplify-9 [=>]13.9

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

      rational.json-simplify-12 [=>]13.9

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

      rational.json-simplify-42 [=>]13.9

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

      rational.json-simplify-8 [<=]13.9

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

      rational.json-simplify-12 [=>]13.9

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

      rational.json-simplify-45 [=>]13.9

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

      metadata-eval [=>]13.9

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

      rational.json-simplify-5 [=>]13.9

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

      rational.json-simplify-2 [=>]13.9

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

      rational.json-simplify-49 [=>]4.4

      \[ x + \color{blue}{y \cdot \frac{z - a}{t}} \]
    5. Applied egg-rr4.7

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

    if -1.11999999999999996e185 < t < 1.8e84

    1. Initial program 9.5

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

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

      [Start]9.5

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

      rational.json-simplify-1 [=>]9.5

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

      rational.json-simplify-48 [=>]8.4

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

      rational.json-simplify-49 [=>]5.4

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

    if 1.8e84 < t

    1. Initial program 29.8

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

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

      [Start]29.8

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

      rational.json-simplify-1 [=>]29.8

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

      rational.json-simplify-48 [=>]26.0

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

      rational.json-simplify-2 [=>]26.0

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

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

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

      [Start]15.9

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

      rational.json-simplify-2 [<=]15.9

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

      rational.json-simplify-43 [=>]15.9

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

      rational.json-simplify-43 [=>]15.9

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

      rational.json-simplify-2 [=>]15.9

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

      rational.json-simplify-52 [=>]15.9

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

      rational.json-simplify-9 [=>]15.9

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

      rational.json-simplify-12 [=>]15.9

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

      rational.json-simplify-42 [=>]15.9

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

      rational.json-simplify-8 [<=]15.9

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

      rational.json-simplify-12 [=>]15.9

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

      rational.json-simplify-45 [=>]15.9

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

      metadata-eval [=>]15.9

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

      rational.json-simplify-5 [=>]15.9

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

      rational.json-simplify-2 [=>]15.9

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

      rational.json-simplify-49 [=>]8.3

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

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

Alternatives

Alternative 1
Error14.5
Cost1236
\[\begin{array}{l} t_1 := x + \frac{y \cdot z}{t - a}\\ \mathbf{if}\;t \leq -1.9 \cdot 10^{+122}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{elif}\;t \leq -1.15 \cdot 10^{-78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-230}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 1.9 \cdot 10^{-95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5200000000:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \end{array} \]
Alternative 2
Error15.0
Cost1104
\[\begin{array}{l} t_1 := x + y \cdot \frac{z - a}{t}\\ \mathbf{if}\;t \leq -2.7 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -7 \cdot 10^{+51}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq -8.5 \cdot 10^{-79}:\\ \;\;\;\;\frac{y \cdot z}{t} + x\\ \mathbf{elif}\;t \leq 6000000000:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error13.4
Cost840
\[\begin{array}{l} \mathbf{if}\;a \leq -3.6 \cdot 10^{+70}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 1.15 \cdot 10^{-9}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 4
Error11.2
Cost840
\[\begin{array}{l} t_1 := y + \left(x - y \cdot \frac{z}{a}\right)\\ \mathbf{if}\;a \leq -1.5 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5 \cdot 10^{-48}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error22.7
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{-197}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-137}:\\ \;\;\;\;y \cdot \frac{z}{t - a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 6
Error22.9
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{-196}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-138}:\\ \;\;\;\;z \cdot \frac{y}{t - a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 7
Error14.8
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -1.5 \cdot 10^{+70}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 1.7 \cdot 10^{-9}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 8
Error20.2
Cost456
\[\begin{array}{l} \mathbf{if}\;a \leq -2.8 \cdot 10^{+41}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 1.2 \cdot 10^{-9}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 9
Error29.0
Cost64
\[x \]

Error

Reproduce?

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