?

Average Error: 4.0 → 1.3
Time: 12.2s
Precision: binary64
Cost: 3016

?

\[\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}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;x + \frac{\frac{\frac{t}{y}}{z}}{3}\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+248}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{t}{y}}{z \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 (* (* z 3.0) y)))))
   (if (<= t_2 (- INFINITY))
     (+ x (/ (/ (/ t y) z) 3.0))
     (if (<= t_2 4e+248) t_2 (+ t_1 (/ (/ t y) (* z 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 / ((z * 3.0) * y));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = x + (((t / y) / z) / 3.0);
	} else if (t_2 <= 4e+248) {
		tmp = t_2;
	} else {
		tmp = t_1 + ((t / y) / (z * 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 / ((z * 3.0) * y));
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = x + (((t / y) / z) / 3.0);
	} else if (t_2 <= 4e+248) {
		tmp = t_2;
	} else {
		tmp = t_1 + ((t / y) / (z * 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 / ((z * 3.0) * y))
	tmp = 0
	if t_2 <= -math.inf:
		tmp = x + (((t / y) / z) / 3.0)
	elif t_2 <= 4e+248:
		tmp = t_2
	else:
		tmp = t_1 + ((t / y) / (z * 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(Float64(z * 3.0) * y)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(x + Float64(Float64(Float64(t / y) / z) / 3.0));
	elseif (t_2 <= 4e+248)
		tmp = t_2;
	else
		tmp = Float64(t_1 + Float64(Float64(t / y) / Float64(z * 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 / ((z * 3.0) * y));
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = x + (((t / y) / z) / 3.0);
	elseif (t_2 <= 4e+248)
		tmp = t_2;
	else
		tmp = t_1 + ((t / y) / (z * 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[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(x + N[(N[(N[(t / y), $MachinePrecision] / z), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e+248], t$95$2, N[(t$95$1 + N[(N[(t / y), $MachinePrecision] / N[(z * 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}{\left(z \cdot 3\right) \cdot y}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;x + \frac{\frac{\frac{t}{y}}{z}}{3}\\

\mathbf{elif}\;t_2 \leq 4 \cdot 10^{+248}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_1 + \frac{\frac{t}{y}}{z \cdot 3}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.0
Target1.5
Herbie1.3
\[\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. Simplified0.3

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

      [Start]64.0

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

      rational.json-simplify-46 [=>]64.0

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

      rational.json-simplify-46 [=>]0.3

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

      rational.json-simplify-44 [=>]0.3

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

      rational.json-simplify-46 [=>]0.3

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

      \[\leadsto \color{blue}{x} + \frac{\frac{\frac{t}{y}}{z}}{3} \]

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

    1. Initial program 0.5

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

    if 4.00000000000000018e248 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y)))

    1. Initial program 15.0

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

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

      [Start]15.0

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

      rational.json-simplify-46 [=>]2.7

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

      rational.json-simplify-44 [=>]5.6

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

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

Alternatives

Alternative 1
Error1.7
Cost3016
\[\begin{array}{l} t_1 := \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + \frac{\frac{\frac{t}{y}}{z}}{3}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+284}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{y}}{z \cdot 3}\\ \end{array} \]
Alternative 2
Error29.0
Cost1108
\[\begin{array}{l} t_1 := 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \mathbf{if}\;x \leq -5.8 \cdot 10^{-58}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{-305}:\\ \;\;\;\;\frac{-0.3333333333333333 \cdot y}{z}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-283}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-246}:\\ \;\;\;\;\frac{-0.3333333333333333}{z} \cdot y\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error29.0
Cost1108
\[\begin{array}{l} t_1 := 0.3333333333333333 \cdot \frac{\frac{t}{y}}{z}\\ \mathbf{if}\;x \leq -6 \cdot 10^{-63}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-305}:\\ \;\;\;\;\frac{-0.3333333333333333 \cdot y}{z}\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-283}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-246}:\\ \;\;\;\;\frac{-0.3333333333333333}{z} \cdot y\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error28.9
Cost1108
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-54}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{-304}:\\ \;\;\;\;\frac{-0.3333333333333333 \cdot y}{z}\\ \mathbf{elif}\;x \leq 10^{-283}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{y}}{z}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-246}:\\ \;\;\;\;\frac{-0.3333333333333333}{z} \cdot y\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-62}:\\ \;\;\;\;\frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error1.5
Cost960
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z}}{y \cdot 3} \]
Alternative 6
Error11.3
Cost840
\[\begin{array}{l} t_1 := x - 0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;x \leq -1.02 \cdot 10^{-115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-60}:\\ \;\;\;\;\frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error8.6
Cost840
\[\begin{array}{l} t_1 := x - 0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -7.1 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-11}:\\ \;\;\;\;x + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error8.7
Cost840
\[\begin{array}{l} t_1 := x - 0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -2.65 \cdot 10^{-12}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-9}:\\ \;\;\;\;x + \frac{\frac{t}{y}}{z \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error5.8
Cost840
\[\begin{array}{l} t_1 := x - 0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -1.55 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.95 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{\frac{t}{z}}{y \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error16.9
Cost712
\[\begin{array}{l} t_1 := x - 0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{-248}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-126}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error16.9
Cost712
\[\begin{array}{l} t_1 := x - 0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -1.5 \cdot 10^{-248}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-126}:\\ \;\;\;\;\frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error15.8
Cost712
\[\begin{array}{l} t_1 := x - 0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -3.8 \cdot 10^{-257}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-126}:\\ \;\;\;\;\frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error28.0
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-54}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-118}:\\ \;\;\;\;\frac{-0.3333333333333333}{z} \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error28.0
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-118}:\\ \;\;\;\;\frac{y}{z} \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 15
Error28.0
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-54}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-118}:\\ \;\;\;\;\frac{-0.3333333333333333 \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 16
Error37.2
Cost64
\[x \]

Error

Reproduce?

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