Average Error: 3.6 → 0.6
Time: 13.8s
Precision: binary64
Cost: 1225
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -50000 \lor \neg \left(t \leq 10^{+101}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - \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
 (if (or (<= t -50000.0) (not (<= t 1e+101)))
   (+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))
   (+ x (/ (- y (/ 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 tmp;
	if ((t <= -50000.0) || !(t <= 1e+101)) {
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	} else {
		tmp = x + ((y - (t / y)) / (z * -3.0));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((t <= (-50000.0d0)) .or. (.not. (t <= 1d+101))) then
        tmp = (x - (y / (z * 3.0d0))) + (t / (y * (z * 3.0d0)))
    else
        tmp = x + ((y - (t / y)) / (z * (-3.0d0)))
    end if
    code = tmp
end function
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 tmp;
	if ((t <= -50000.0) || !(t <= 1e+101)) {
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	} else {
		tmp = x + ((y - (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):
	tmp = 0
	if (t <= -50000.0) or not (t <= 1e+101):
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)))
	else:
		tmp = x + ((y - (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)
	tmp = 0.0
	if ((t <= -50000.0) || !(t <= 1e+101))
		tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(y * Float64(z * 3.0))));
	else
		tmp = Float64(x + Float64(Float64(y - 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)
	tmp = 0.0;
	if ((t <= -50000.0) || ~((t <= 1e+101)))
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	else
		tmp = x + ((y - (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_] := If[Or[LessEqual[t, -50000.0], N[Not[LessEqual[t, 1e+101]], $MachinePrecision]], N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - N[(t / y), $MachinePrecision]), $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}
\mathbf{if}\;t \leq -50000 \lor \neg \left(t \leq 10^{+101}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if t < -5e4 or 9.9999999999999998e100 < t

    1. Initial program 0.8

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

    if -5e4 < t < 9.9999999999999998e100

    1. Initial program 5.1

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

      \[\leadsto \color{blue}{x + \frac{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)} \]
      Proof
      (+.f64 x (*.f64 (/.f64 -1/3 z) (-.f64 y (/.f64 t y)))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (*.f64 (/.f64 (Rewrite<= metadata-eval (/.f64 -1 3)) z) (-.f64 y (/.f64 t y)))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (*.f64 (Rewrite<= associate-/r*_binary64 (/.f64 -1 (*.f64 3 z))) (-.f64 y (/.f64 t y)))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (*.f64 (/.f64 -1 (Rewrite<= *-commutative_binary64 (*.f64 z 3))) (-.f64 y (/.f64 t y)))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite<= distribute-lft-out--_binary64 (-.f64 (*.f64 (/.f64 -1 (*.f64 z 3)) y) (*.f64 (/.f64 -1 (*.f64 z 3)) (/.f64 t y))))): 13 points increase in error, 0 points decrease in error
      (+.f64 x (-.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 -1 y) (*.f64 z 3))) (*.f64 (/.f64 -1 (*.f64 z 3)) (/.f64 t y)))): 0 points increase in error, 13 points decrease in error
      (+.f64 x (-.f64 (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 y (*.f64 z 3)))) (*.f64 (/.f64 -1 (*.f64 z 3)) (/.f64 t y)))): 2 points increase in error, 0 points decrease in error
      (+.f64 x (-.f64 (*.f64 -1 (/.f64 y (*.f64 z 3))) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 t) (*.f64 (*.f64 z 3) y))))): 0 points increase in error, 2 points decrease in error
      (+.f64 x (-.f64 (*.f64 -1 (/.f64 y (*.f64 z 3))) (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 t (*.f64 (*.f64 z 3) y)))))): 13 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite=> distribute-lft-out--_binary64 (*.f64 -1 (-.f64 (/.f64 y (*.f64 z 3)) (/.f64 t (*.f64 (*.f64 z 3) y)))))): 0 points increase in error, 13 points decrease in error
      (+.f64 x (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 (/.f64 y (*.f64 z 3)) (/.f64 t (*.f64 (*.f64 z 3) y)))))): 11 points increase in error, 0 points decrease in error
      (Rewrite<= sub-neg_binary64 (-.f64 x (-.f64 (/.f64 y (*.f64 z 3)) (/.f64 t (*.f64 (*.f64 z 3) y))))): 0 points increase in error, 11 points decrease in error
      (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y)))): 5 points increase in error, 0 points decrease in error
    3. Applied egg-rr0.5

      \[\leadsto x + \color{blue}{\frac{y - \frac{t}{y}}{z \cdot -3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -50000 \lor \neg \left(t \leq 10^{+101}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - \frac{t}{y}}{z \cdot -3}\\ \end{array} \]

Alternatives

Alternative 1
Error1.9
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 -1 \cdot 10^{+203}:\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+256}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{t}{z} \cdot 0.3333333333333333}{y}\\ \end{array} \]
Alternative 2
Error9.0
Cost1368
\[\begin{array}{l} t_1 := x + \frac{\frac{y}{z}}{-3}\\ t_2 := x + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \mathbf{if}\;y \leq -0.112:\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{-169}:\\ \;\;\;\;x + \frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{-17}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3350:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.65 \cdot 10^{+31}:\\ \;\;\;\;\frac{y - \frac{t}{y}}{z} \cdot -0.3333333333333333\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{+45}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error8.9
Cost1368
\[\begin{array}{l} t_1 := x + \frac{\frac{y}{z}}{-3}\\ \mathbf{if}\;y \leq -10:\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-170}:\\ \;\;\;\;x + \frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-17}:\\ \;\;\;\;x + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \mathbf{elif}\;y \leq 3350:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+32}:\\ \;\;\;\;\frac{y - \frac{t}{y}}{z} \cdot -0.3333333333333333\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+44}:\\ \;\;\;\;x + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error8.9
Cost1368
\[\begin{array}{l} t_1 := x + \frac{\frac{y}{z}}{-3}\\ \mathbf{if}\;y \leq -19:\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-170}:\\ \;\;\;\;x + \frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-18}:\\ \;\;\;\;x + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \mathbf{elif}\;y \leq 1300:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{+31}:\\ \;\;\;\;\frac{\left(y - \frac{t}{y}\right) \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{+44}:\\ \;\;\;\;x + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error29.7
Cost1244
\[\begin{array}{l} t_1 := \frac{y}{z \cdot -3}\\ \mathbf{if}\;x \leq -32000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.1 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-227}:\\ \;\;\;\;\frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-237}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-106}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 8000000000000:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error29.9
Cost1112
\[\begin{array}{l} t_1 := \frac{y}{z \cdot -3}\\ \mathbf{if}\;y \leq -31:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4.1 \cdot 10^{-90}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-76}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \mathbf{elif}\;y \leq 7800000:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+144}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \end{array} \]
Alternative 7
Error30.0
Cost980
\[\begin{array}{l} t_1 := \frac{y}{z \cdot -3}\\ t_2 := 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \mathbf{if}\;x \leq -2.45 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-239}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9000000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error3.9
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq 4.8 \cdot 10^{-170} \lor \neg \left(y \leq 5 \cdot 10^{-98}\right):\\ \;\;\;\;x + \left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \end{array} \]
Alternative 9
Error3.9
Cost968
\[\begin{array}{l} t_1 := y - \frac{t}{y}\\ \mathbf{if}\;y \leq 9.5 \cdot 10^{-170}:\\ \;\;\;\;x + \frac{t_1}{z \cdot -3}\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-96}:\\ \;\;\;\;x + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t_1 \cdot -0.3333333333333333}{z}\\ \end{array} \]
Alternative 10
Error3.9
Cost968
\[\begin{array}{l} t_1 := y - \frac{t}{y}\\ \mathbf{if}\;y \leq 2.95 \cdot 10^{-170}:\\ \;\;\;\;x + \frac{t_1}{z \cdot -3}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-98}:\\ \;\;\;\;x + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t_1}{z}}{-3}\\ \end{array} \]
Alternative 11
Error11.5
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -6.8 \cdot 10^{-50}:\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \mathbf{elif}\;x \leq 8000000000000:\\ \;\;\;\;\frac{y - \frac{t}{y}}{z} \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \end{array} \]
Alternative 12
Error8.3
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -0.175:\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-15}:\\ \;\;\;\;x + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \end{array} \]
Alternative 13
Error15.8
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{-101} \lor \neg \left(y \leq 2.5 \cdot 10^{-73}\right):\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \end{array} \]
Alternative 14
Error15.6
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.3 \cdot 10^{-101} \lor \neg \left(y \leq 2.4 \cdot 10^{-77}\right):\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \end{array} \]
Alternative 15
Error15.6
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-101} \lor \neg \left(y \leq 3.8 \cdot 10^{-78}\right):\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t}{z}}{\frac{y}{0.3333333333333333}}\\ \end{array} \]
Alternative 16
Error3.8
Cost704
\[x + \frac{\left(y - \frac{t}{y}\right) \cdot -0.3333333333333333}{z} \]
Alternative 17
Error27.6
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-5}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{+19}:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 18
Error27.6
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -14500000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+19}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 19
Error37.1
Cost64
\[x \]

Error

Reproduce

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