?

Average Error: 5.33% → 1.19%
Time: 14.3s
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 -2 \cdot 10^{-11} \lor \neg \left(t \leq 2.9 \cdot 10^{-147}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \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 (<= t -2e-11) (not (<= t 2.9e-147)))
   (+ (- 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 <= -2e-11) || !(t <= 2.9e-147)) {
		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 <= (-2d-11)) .or. (.not. (t <= 2.9d-147))) 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 <= -2e-11) || !(t <= 2.9e-147)) {
		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 <= -2e-11) or not (t <= 2.9e-147):
		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 <= -2e-11) || !(t <= 2.9e-147))
		tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(y * Float64(z * 3.0))));
	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 ((t <= -2e-11) || ~((t <= 2.9e-147)))
		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, -2e-11], N[Not[LessEqual[t, 2.9e-147]], $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[(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}\;t \leq -2 \cdot 10^{-11} \lor \neg \left(t \leq 2.9 \cdot 10^{-147}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\

\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

Original5.33%
Target2.47%
Herbie1.19%
\[\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 < -1.99999999999999988e-11 or 2.9000000000000001e-147 < t

    1. Initial program 1.83

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

    if -1.99999999999999988e-11 < t < 2.9000000000000001e-147

    1. Initial program 9.89

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

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

      [Start]9.89

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

      associate-+l- [=>]9.89

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

      sub-neg [=>]9.89

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

      neg-mul-1 [=>]9.89

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

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

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

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

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

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

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

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

      *-commutative [=>]0.33

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

      associate-/r* [=>]0.35

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

      metadata-eval [=>]0.35

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

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

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

Alternatives

Alternative 1
Error3.05%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -2.55 \cdot 10^{-79} \lor \neg \left(y \leq 5.3 \cdot 10^{-191}\right):\\ \;\;\;\;x + \left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{z}}{y}}{3}\\ \end{array} \]
Alternative 2
Error2.58%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -6.6 \cdot 10^{-164} \lor \neg \left(y \leq 10^{-122}\right):\\ \;\;\;\;x + \frac{y - \frac{t}{y}}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{z}}{y}}{3}\\ \end{array} \]
Alternative 3
Error2.31%
Cost968
\[\begin{array}{l} t_1 := y - \frac{t}{y}\\ \mathbf{if}\;y \leq -2.4 \cdot 10^{-81}:\\ \;\;\;\;x + \frac{\frac{t_1}{z}}{-3}\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-120}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{z}}{y}}{3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t_1}{z \cdot -3}\\ \end{array} \]
Alternative 4
Error2.47%
Cost960
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y} \]
Alternative 5
Error45.43%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -9.6 \cdot 10^{+74}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.5 \cdot 10^{-133}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{elif}\;x \leq -5.3 \cdot 10^{-281}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{y}}{z}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-27}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error45.16%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+75}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-133}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-281}:\\ \;\;\;\;\frac{\frac{t}{z}}{y} \cdot 0.3333333333333333\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-26}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error12.48%
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-39} \lor \neg \left(y \leq 5.5 \cdot 10^{-10}\right):\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;x + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \end{array} \]
Alternative 8
Error12.07%
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{-39} \lor \neg \left(y \leq 4.6 \cdot 10^{-10}\right):\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \end{array} \]
Alternative 9
Error8.55%
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{-39} \lor \neg \left(y \leq 3.8 \cdot 10^{-10}\right):\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{z}}{y}}{3}\\ \end{array} \]
Alternative 10
Error24.15%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-133} \lor \neg \left(y \leq 9.5 \cdot 10^{-192}\right):\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t}{z}}{y} \cdot 0.3333333333333333\\ \end{array} \]
Alternative 11
Error23.98%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{-140} \lor \neg \left(y \leq 8.8 \cdot 10^{-191}\right):\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t}{z}}{y} \cdot 0.3333333333333333\\ \end{array} \]
Alternative 12
Error43.49%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -8.2 \cdot 10^{+74}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-27}:\\ \;\;\;\;y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error43.45%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.16 \cdot 10^{+75}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-26}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error43.44%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -7.8 \cdot 10^{+74}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-27}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 15
Error58.51%
Cost64
\[x \]

Error

Reproduce?

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