Average Error: 16.7 → 9.0
Time: 6.8s
Precision: binary64
Cost: 840
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} t_1 := \left(y - \frac{z}{\frac{a}{y}}\right) + x\\ \mathbf{if}\;a \leq -2.367924782443823 \cdot 10^{+96}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.9145936124777726 \cdot 10^{+30}:\\ \;\;\;\;x - \frac{y}{\frac{a - t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (+ (- y (/ z (/ a y))) x)))
   (if (<= a -2.367924782443823e+96)
     t_1
     (if (<= a 3.9145936124777726e+30) (- x (/ y (/ (- a t) z))) 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 = (y - (z / (a / y))) + x;
	double tmp;
	if (a <= -2.367924782443823e+96) {
		tmp = t_1;
	} else if (a <= 3.9145936124777726e+30) {
		tmp = x - (y / ((a - t) / z));
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_1 = (y - (z / (a / y))) + x
    if (a <= (-2.367924782443823d+96)) then
        tmp = t_1
    else if (a <= 3.9145936124777726d+30) then
        tmp = x - (y / ((a - t) / z))
    else
        tmp = t_1
    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 t_1 = (y - (z / (a / y))) + x;
	double tmp;
	if (a <= -2.367924782443823e+96) {
		tmp = t_1;
	} else if (a <= 3.9145936124777726e+30) {
		tmp = x - (y / ((a - t) / z));
	} else {
		tmp = t_1;
	}
	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 = (y - (z / (a / y))) + x
	tmp = 0
	if a <= -2.367924782443823e+96:
		tmp = t_1
	elif a <= 3.9145936124777726e+30:
		tmp = x - (y / ((a - t) / z))
	else:
		tmp = t_1
	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(y - Float64(z / Float64(a / y))) + x)
	tmp = 0.0
	if (a <= -2.367924782443823e+96)
		tmp = t_1;
	elseif (a <= 3.9145936124777726e+30)
		tmp = Float64(x - Float64(y / Float64(Float64(a - t) / z)));
	else
		tmp = t_1;
	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 = (y - (z / (a / y))) + x;
	tmp = 0.0;
	if (a <= -2.367924782443823e+96)
		tmp = t_1;
	elseif (a <= 3.9145936124777726e+30)
		tmp = x - (y / ((a - t) / z));
	else
		tmp = t_1;
	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[(y - N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -2.367924782443823e+96], t$95$1, If[LessEqual[a, 3.9145936124777726e+30], N[(x - N[(y / N[(N[(a - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
t_1 := \left(y - \frac{z}{\frac{a}{y}}\right) + x\\
\mathbf{if}\;a \leq -2.367924782443823 \cdot 10^{+96}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;a \leq 3.9145936124777726 \cdot 10^{+30}:\\
\;\;\;\;x - \frac{y}{\frac{a - t}{z}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.7
Target8.7
Herbie9.0
\[\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 2 regimes
  2. if a < -2.367924782443823e96 or 3.9145936124777726e30 < a

    1. Initial program 14.4

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

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

      \[\leadsto \left(y - \color{blue}{\frac{z}{a}} \cdot y\right) + x \]
    4. Applied egg-rr7.9

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

    if -2.367924782443823e96 < a < 3.9145936124777726e30

    1. Initial program 18.4

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

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

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

      \[\leadsto \color{blue}{\frac{y}{a - t} \cdot \left(-z\right)} + x \]
    5. Applied egg-rr9.9

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

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

Alternatives

Alternative 1
Error12.3
Cost1104
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ t_2 := \left(y - \frac{z}{\frac{a}{y}}\right) + x\\ \mathbf{if}\;a \leq -6.30759438818877 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2.4042450625833536 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.9 \cdot 10^{-151}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a}}\\ \mathbf{elif}\;a \leq 3.1982577588820746 \cdot 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error10.7
Cost1104
\[\begin{array}{l} t_1 := \left(y - \frac{z}{\frac{a}{y}}\right) + x\\ \mathbf{if}\;a \leq -6.30759438818877 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -2.4042450625833536 \cdot 10^{-31}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{elif}\;a \leq -7.854919655825413 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.1982577588820746 \cdot 10^{-53}:\\ \;\;\;\;x + \frac{z - a}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error15.3
Cost976
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;a \leq -3.2221899379350233 \cdot 10^{+71}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq -2.4042450625833536 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -7.8 \cdot 10^{-131}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a}}\\ \mathbf{elif}\;a \leq 3.1 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 4
Error14.8
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -3.2221899379350233 \cdot 10^{+71}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 3.1 \cdot 10^{-88}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 5
Error19.5
Cost456
\[\begin{array}{l} \mathbf{if}\;a \leq -1.4973598792719362 \cdot 10^{-16}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 7.767984330602927 \cdot 10^{-20}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 6
Error28.6
Cost64
\[x \]

Error

Reproduce

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