?

Average Error: 3.7 → 0.5
Time: 12.8s
Precision: binary64
Cost: 1224

?

\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{-72}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{+35}:\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{t}{z \cdot \frac{y}{0.3333333333333333}}\right) - \frac{\frac{y}{3}}{z}\\ \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 (<= t -2e-72)
   (+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))
   (if (<= t 1.5e+35)
     (+ x (/ (/ (- y (/ t y)) z) -3.0))
     (- (+ x (/ t (* z (/ y 0.3333333333333333)))) (/ (/ y 3.0) z)))))
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 <= -2e-72) {
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	} else if (t <= 1.5e+35) {
		tmp = x + (((y - (t / y)) / z) / -3.0);
	} else {
		tmp = (x + (t / (z * (y / 0.3333333333333333)))) - ((y / 3.0) / z);
	}
	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 <= (-2d-72)) then
        tmp = (x - (y / (z * 3.0d0))) + (t / (y * (z * 3.0d0)))
    else if (t <= 1.5d+35) then
        tmp = x + (((y - (t / y)) / z) / (-3.0d0))
    else
        tmp = (x + (t / (z * (y / 0.3333333333333333d0)))) - ((y / 3.0d0) / z)
    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 <= -2e-72) {
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	} else if (t <= 1.5e+35) {
		tmp = x + (((y - (t / y)) / z) / -3.0);
	} else {
		tmp = (x + (t / (z * (y / 0.3333333333333333)))) - ((y / 3.0) / z);
	}
	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 <= -2e-72:
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)))
	elif t <= 1.5e+35:
		tmp = x + (((y - (t / y)) / z) / -3.0)
	else:
		tmp = (x + (t / (z * (y / 0.3333333333333333)))) - ((y / 3.0) / z)
	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 <= -2e-72)
		tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(y * Float64(z * 3.0))));
	elseif (t <= 1.5e+35)
		tmp = Float64(x + Float64(Float64(Float64(y - Float64(t / y)) / z) / -3.0));
	else
		tmp = Float64(Float64(x + Float64(t / Float64(z * Float64(y / 0.3333333333333333)))) - Float64(Float64(y / 3.0) / z));
	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 <= -2e-72)
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	elseif (t <= 1.5e+35)
		tmp = x + (((y - (t / y)) / z) / -3.0);
	else
		tmp = (x + (t / (z * (y / 0.3333333333333333)))) - ((y / 3.0) / z);
	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[LessEqual[t, -2e-72], N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.5e+35], N[(x + N[(N[(N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / -3.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(t / N[(z * N[(y / 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y / 3.0), $MachinePrecision] / z), $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 -2 \cdot 10^{-72}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\

\mathbf{elif}\;t \leq 1.5 \cdot 10^{+35}:\\
\;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Split input into 3 regimes
  2. if t < -1.9999999999999999e-72

    1. Initial program 1.0

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

    if -1.9999999999999999e-72 < t < 1.49999999999999995e35

    1. Initial program 6.2

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

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

      [Start]6.2

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

      associate-+l- [=>]6.2

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

      sub-neg [=>]6.2

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

      neg-mul-1 [=>]6.2

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

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

      \[ 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/ [=>]6.2

      \[ 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/ [<=]6.2

      \[ 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/ [=>]6.2

      \[ 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.3

      \[ 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.3

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

      *-commutative [=>]0.3

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

      associate-/r* [=>]0.3

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

      metadata-eval [=>]0.3

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

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

    if 1.49999999999999995e35 < t

    1. Initial program 0.4

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

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

      [Start]0.4

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

      associate-/r* [=>]2.6

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

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

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

Alternatives

Alternative 1
Error0.5
Cost1353
\[\begin{array}{l} \mathbf{if}\;z \cdot 3 \leq -1 \cdot 10^{+55} \lor \neg \left(z \cdot 3 \leq 10^{+27}\right):\\ \;\;\;\;x + \frac{\frac{y}{z} - \frac{t}{y \cdot z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - \frac{t}{y}}{z \cdot -3}\\ \end{array} \]
Alternative 2
Error0.6
Cost1224
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;t \leq -9.5 \cdot 10^{-73}:\\ \;\;\;\;t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 2 \cdot 10^{-107}:\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{t}{z \cdot \left(y \cdot 3\right)}\\ \end{array} \]
Alternative 3
Error1.6
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{-73} \lor \neg \left(y \leq 2.95 \cdot 10^{-102}\right):\\ \;\;\;\;x + \left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{0.3333333333333333 \cdot \frac{t}{z}}{y}\\ \end{array} \]
Alternative 4
Error1.8
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{-74} \lor \neg \left(y \leq 6.6 \cdot 10^{-156}\right):\\ \;\;\;\;x + \frac{y - \frac{t}{y}}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{0.3333333333333333 \cdot \frac{t}{z}}{y}\\ \end{array} \]
Alternative 5
Error11.6
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-47} \lor \neg \left(x \leq 1.7 \cdot 10^{-34}\right):\\ \;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)\\ \end{array} \]
Alternative 6
Error8.3
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-28} \lor \neg \left(y \leq 7.4 \cdot 10^{+22}\right):\\ \;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \end{array} \]
Alternative 7
Error8.2
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{-31} \lor \neg \left(y \leq 9 \cdot 10^{+22}\right):\\ \;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t}{3 \cdot \left(y \cdot z\right)}\\ \end{array} \]
Alternative 8
Error5.6
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -1.86 \cdot 10^{-31} \lor \neg \left(y \leq 2.9 \cdot 10^{+23}\right):\\ \;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{0.3333333333333333 \cdot \frac{t}{z}}{y}\\ \end{array} \]
Alternative 9
Error28.0
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-117}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-32}:\\ \;\;\;\;y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error28.0
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{-118}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-33}:\\ \;\;\;\;\frac{y}{z} \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error18.0
Cost448
\[x + y \cdot \frac{-0.3333333333333333}{z} \]
Alternative 12
Error37.0
Cost64
\[x \]

Error

Reproduce?

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