Average Error: 3.6 → 0.8
Time: 10.8s
Precision: binary64
Cost: 3144
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ t_2 := t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+279}:\\ \;\;\;\;t_1 + \frac{t}{z \cdot \left(y \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{y}{3} \cdot \frac{-1}{z}\right) + \frac{\frac{t}{z}}{y \cdot 3}\\ \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- x (/ y (* z 3.0)))) (t_2 (+ t_1 (/ t (* y (* z 3.0))))))
   (if (<= t_2 (- INFINITY))
     (+ x (* (/ 0.3333333333333333 z) (- (/ t y) y)))
     (if (<= t_2 2e+279)
       (+ t_1 (/ t (* z (* y 3.0))))
       (+ (+ x (* (/ y 3.0) (/ -1.0 z))) (/ (/ t z) (* y 3.0)))))))
double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
	double t_1 = x - (y / (z * 3.0));
	double t_2 = t_1 + (t / (y * (z * 3.0)));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = x + ((0.3333333333333333 / z) * ((t / y) - y));
	} else if (t_2 <= 2e+279) {
		tmp = t_1 + (t / (z * (y * 3.0)));
	} else {
		tmp = (x + ((y / 3.0) * (-1.0 / z))) + ((t / z) / (y * 3.0));
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x - (y / (z * 3.0));
	double t_2 = t_1 + (t / (y * (z * 3.0)));
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = x + ((0.3333333333333333 / z) * ((t / y) - y));
	} else if (t_2 <= 2e+279) {
		tmp = t_1 + (t / (z * (y * 3.0)));
	} else {
		tmp = (x + ((y / 3.0) * (-1.0 / z))) + ((t / z) / (y * 3.0));
	}
	return tmp;
}
def code(x, y, z, t):
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
def code(x, y, z, t):
	t_1 = x - (y / (z * 3.0))
	t_2 = t_1 + (t / (y * (z * 3.0)))
	tmp = 0
	if t_2 <= -math.inf:
		tmp = x + ((0.3333333333333333 / z) * ((t / y) - y))
	elif t_2 <= 2e+279:
		tmp = t_1 + (t / (z * (y * 3.0)))
	else:
		tmp = (x + ((y / 3.0) * (-1.0 / z))) + ((t / z) / (y * 3.0))
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y)))
end
function code(x, y, z, t)
	t_1 = Float64(x - Float64(y / Float64(z * 3.0)))
	t_2 = Float64(t_1 + Float64(t / Float64(y * Float64(z * 3.0))))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(x + Float64(Float64(0.3333333333333333 / z) * Float64(Float64(t / y) - y)));
	elseif (t_2 <= 2e+279)
		tmp = Float64(t_1 + Float64(t / Float64(z * Float64(y * 3.0))));
	else
		tmp = Float64(Float64(x + Float64(Float64(y / 3.0) * Float64(-1.0 / z))) + Float64(Float64(t / z) / Float64(y * 3.0)));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
end
function tmp_2 = code(x, y, z, t)
	t_1 = x - (y / (z * 3.0));
	t_2 = t_1 + (t / (y * (z * 3.0)));
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = x + ((0.3333333333333333 / z) * ((t / y) - y));
	elseif (t_2 <= 2e+279)
		tmp = t_1 + (t / (z * (y * 3.0)));
	else
		tmp = (x + ((y / 3.0) * (-1.0 / z))) + ((t / z) / (y * 3.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(x + N[(N[(0.3333333333333333 / z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+279], N[(t$95$1 + N[(t / N[(z * N[(y * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(y / 3.0), $MachinePrecision] * N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t / z), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
t_2 := t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+279}:\\
\;\;\;\;t_1 + \frac{t}{z \cdot \left(y \cdot 3\right)}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.6
Target1.8
Herbie0.8
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y} \]

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{1}{y} \cdot \left(t \cdot \frac{0.3333333333333333}{z}\right)} \]
    3. Applied egg-rr0.3

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

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

    if -inf.0 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < 2.00000000000000012e279

    1. Initial program 0.5

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

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

    if 2.00000000000000012e279 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y)))

    1. Initial program 23.1

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

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\color{blue}{3 \cdot \left(y \cdot z\right)}} \]
    3. Applied egg-rr4.3

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

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

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

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

Alternatives

Alternative 1
Error0.8
Cost3144
\[\begin{array}{l} t_1 := \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+279}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{y}{3} \cdot \frac{-1}{z}\right) + \frac{\frac{t}{z}}{y \cdot 3}\\ \end{array} \]
Alternative 2
Error0.8
Cost3016
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ t_2 := t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+279}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{t}{z}}{y \cdot 3}\\ \end{array} \]
Alternative 3
Error29.2
Cost980
\[\begin{array}{l} t_1 := \frac{t \cdot 0.3333333333333333}{y \cdot z}\\ \mathbf{if}\;x \leq -9.565186528407064 \cdot 10^{-55}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.8001005933579006 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.243849594958199 \cdot 10^{-265}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{elif}\;x \leq 1.5657405700347895 \cdot 10^{-263}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.4214995704030887 \cdot 10^{-63}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error29.3
Cost980
\[\begin{array}{l} \mathbf{if}\;x \leq -3.9250416096531754 \cdot 10^{-64}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.8001005933579006 \cdot 10^{-170}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{z}}{\frac{y}{t}}\\ \mathbf{elif}\;x \leq -4.243849594958199 \cdot 10^{-265}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{elif}\;x \leq 1.5657405700347895 \cdot 10^{-263}:\\ \;\;\;\;\frac{t \cdot 0.3333333333333333}{y \cdot z}\\ \mathbf{elif}\;x \leq 2.4214995704030887 \cdot 10^{-63}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error19.8
Cost976
\[\begin{array}{l} t_1 := x - y \cdot \frac{0.3333333333333333}{z}\\ \mathbf{if}\;x \leq -5.9700770422740825 \cdot 10^{-92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8001005933579006 \cdot 10^{-170}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{z}}{\frac{y}{t}}\\ \mathbf{elif}\;x \leq -4.243849594958199 \cdot 10^{-265}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5657405700347895 \cdot 10^{-263}:\\ \;\;\;\;\frac{t \cdot 0.3333333333333333}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error20.1
Cost976
\[\begin{array}{l} t_1 := x - y \cdot \frac{0.3333333333333333}{z}\\ \mathbf{if}\;x \leq -9.565186528407064 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8001005933579006 \cdot 10^{-170}:\\ \;\;\;\;\frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{elif}\;x \leq -4.243849594958199 \cdot 10^{-265}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5657405700347895 \cdot 10^{-263}:\\ \;\;\;\;\frac{t \cdot 0.3333333333333333}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error2.1
Cost968
\[\begin{array}{l} t_1 := x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)\\ \mathbf{if}\;y \leq -5.815308533420888 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-125}:\\ \;\;\;\;x + \frac{\frac{t}{z}}{y \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error1.8
Cost960
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z}}{y \cdot 3} \]
Alternative 9
Error5.8
Cost840
\[\begin{array}{l} t_1 := x - y \cdot \frac{0.3333333333333333}{z}\\ \mathbf{if}\;y \leq -746665063.9392775:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.0632398596402165 \cdot 10^{-23}:\\ \;\;\;\;x + \frac{\frac{t}{z}}{y \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error28.9
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.593952372859714 \cdot 10^{-125}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.4214995704030887 \cdot 10^{-63}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error28.9
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.593952372859714 \cdot 10^{-125}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.4214995704030887 \cdot 10^{-63}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error37.8
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022298 
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, H"
  :precision binary64

  :herbie-target
  (+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))

  (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))