?

Average Error: 3.6 → 0.9
Time: 15.4s
Precision: binary64
Cost: 1481

?

\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\begin{array}{l} \mathbf{if}\;z \cdot 3 \leq -2 \cdot 10^{+36} \lor \neg \left(z \cdot 3 \leq 10^{-137}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-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 (<= (* z 3.0) -2e+36) (not (<= (* z 3.0) 1e-137)))
   (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y)))
   (+ 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 (((z * 3.0) <= -2e+36) || !((z * 3.0) <= 1e-137)) {
		tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
	} 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 (((z * 3.0d0) <= (-2d+36)) .or. (.not. ((z * 3.0d0) <= 1d-137))) then
        tmp = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
    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 (((z * 3.0) <= -2e+36) || !((z * 3.0) <= 1e-137)) {
		tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
	} 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 ((z * 3.0) <= -2e+36) or not ((z * 3.0) <= 1e-137):
		tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
	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 ((Float64(z * 3.0) <= -2e+36) || !(Float64(z * 3.0) <= 1e-137))
		tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y)));
	else
		tmp = Float64(x + Float64(Float64(Float64(y - Float64(t / y)) / 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 (((z * 3.0) <= -2e+36) || ~(((z * 3.0) <= 1e-137)))
		tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
	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[N[(z * 3.0), $MachinePrecision], -2e+36], N[Not[LessEqual[N[(z * 3.0), $MachinePrecision], 1e-137]], $MachinePrecision]], N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / -3.0), $MachinePrecision]), $MachinePrecision]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq -2 \cdot 10^{+36} \lor \neg \left(z \cdot 3 \leq 10^{-137}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 z 3) < -2.00000000000000008e36 or 9.99999999999999978e-138 < (*.f64 z 3)

    1. Initial program 1.0

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

    if -2.00000000000000008e36 < (*.f64 z 3) < 9.99999999999999978e-138

    1. Initial program 11.6

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

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

      [Start]11.6

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

      associate-+l- [=>]11.6

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

      sub-neg [=>]11.6

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

      neg-mul-1 [=>]11.6

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

      distribute-lft-out-- [<=]11.6

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

      associate-*r/ [=>]11.6

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

      associate-*l/ [<=]11.6

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

      associate-*r/ [=>]11.6

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

      times-frac [=>]0.5

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

      distribute-lft-out-- [=>]0.5

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

      *-commutative [=>]0.5

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

      associate-/r* [=>]0.5

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

      metadata-eval [=>]0.5

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

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

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

Alternatives

Alternative 1
Error28.0
Cost1112
\[\begin{array}{l} t_1 := 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{-203}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-272}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-153}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1700000:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error27.9
Cost1112
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-229}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-269}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{y}}{z}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-156}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{-116}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{t}{z \cdot y}\\ \mathbf{elif}\;x \leq 1820000:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error28.1
Cost1112
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{-24}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-201}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq 7.4 \cdot 10^{-268}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-156}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-117}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{t}{z \cdot y}\\ \mathbf{elif}\;x \leq 11600000:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error1.7
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{-72} \lor \neg \left(y \leq 3.3 \cdot 10^{-122}\right):\\ \;\;\;\;x + \left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \end{array} \]
Alternative 5
Error1.6
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{-70} \lor \neg \left(y \leq 3 \cdot 10^{-123}\right):\\ \;\;\;\;x + \left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{3}}{z}}{y}\\ \end{array} \]
Alternative 6
Error1.6
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -1.36 \cdot 10^{-76} \lor \neg \left(y \leq 5 \cdot 10^{-123}\right):\\ \;\;\;\;x + \frac{y - \frac{t}{y}}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{3}}{z}}{y}\\ \end{array} \]
Alternative 7
Error1.7
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -1.85 \cdot 10^{-78} \lor \neg \left(y \leq 2.9 \cdot 10^{-119}\right):\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{3}}{z}}{y}\\ \end{array} \]
Alternative 8
Error11.2
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-29}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-71}:\\ \;\;\;\;\frac{y - \frac{t}{y}}{z} \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \end{array} \]
Alternative 9
Error8.6
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{-68}:\\ \;\;\;\;x + \frac{y}{-3} \cdot \frac{1}{z}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-17}:\\ \;\;\;\;x + \frac{t \cdot 0.3333333333333333}{z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \end{array} \]
Alternative 10
Error6.1
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{-68}:\\ \;\;\;\;x + \frac{y}{-3} \cdot \frac{1}{z}\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{-18}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \end{array} \]
Alternative 11
Error15.5
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{-130} \lor \neg \left(y \leq 7 \cdot 10^{-119}\right):\\ \;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \end{array} \]
Alternative 12
Error15.5
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-131} \lor \neg \left(y \leq 10^{-121}\right):\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \end{array} \]
Alternative 13
Error15.5
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{-128}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{-120}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{z \cdot -3}\\ \end{array} \]
Alternative 14
Error15.5
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{-129}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-117}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \end{array} \]
Alternative 15
Error15.5
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{-131}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-120}:\\ \;\;\;\;\frac{t \cdot \frac{0.3333333333333333}{z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \end{array} \]
Alternative 16
Error27.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{-27}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1850000:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 17
Error27.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{-27}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7400000:\\ \;\;\;\;y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 18
Error27.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 96000000:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 19
Error27.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 70000000:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 20
Error36.9
Cost64
\[x \]

Error

Reproduce?

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