?

Average Error: 3.0 → 0.5
Time: 22.9s
Precision: binary64
Cost: 1220

?

\[ \begin{array}{c}[y, z, t] = \mathsf{sort}([y, z, t])\\ \end{array} \]
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
\[\begin{array}{l} \mathbf{if}\;z \leq 1.3 \cdot 10^{-62}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
(FPCore (x y z t a b)
 :precision binary64
 (if (<= z 1.3e-62)
   (+ (- (* x 2.0) (* y (* 9.0 (* z t)))) (* a (* 27.0 b)))
   (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (z <= 1.3e-62) {
		tmp = ((x * 2.0) - (y * (9.0 * (z * t)))) + (a * (27.0 * b));
	} else {
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (z <= 1.3d-62) then
        tmp = ((x * 2.0d0) - (y * (9.0d0 * (z * t)))) + (a * (27.0d0 * b))
    else
        tmp = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (z <= 1.3e-62) {
		tmp = ((x * 2.0) - (y * (9.0 * (z * t)))) + (a * (27.0 * b));
	} else {
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
def code(x, y, z, t, a, b):
	tmp = 0
	if z <= 1.3e-62:
		tmp = ((x * 2.0) - (y * (9.0 * (z * t)))) + (a * (27.0 * b))
	else:
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
	return tmp
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b))
end
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (z <= 1.3e-62)
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(y * Float64(9.0 * Float64(z * t)))) + Float64(a * Float64(27.0 * b)));
	else
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b));
	end
	return tmp
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (z <= 1.3e-62)
		tmp = ((x * 2.0) - (y * (9.0 * (z * t)))) + (a * (27.0 * b));
	else
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, 1.3e-62], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(y * N[(9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
\mathbf{if}\;z \leq 1.3 \cdot 10^{-62}:\\
\;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.0
Target3.5
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;y < 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if z < 1.3e-62

    1. Initial program 3.6

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Simplified0.6

      \[\leadsto \color{blue}{\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + a \cdot \left(27 \cdot b\right)} \]
      Proof

      [Start]3.6

      \[ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]

      rational.json-simplify-2 [=>]3.6

      \[ \left(x \cdot 2 - \color{blue}{t \cdot \left(\left(y \cdot 9\right) \cdot z\right)}\right) + \left(a \cdot 27\right) \cdot b \]

      rational.json-simplify-43 [=>]0.6

      \[ \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]

      rational.json-simplify-2 [=>]0.6

      \[ \left(x \cdot 2 - \color{blue}{\left(z \cdot t\right) \cdot \left(y \cdot 9\right)}\right) + \left(a \cdot 27\right) \cdot b \]

      rational.json-simplify-43 [=>]0.5

      \[ \left(x \cdot 2 - \color{blue}{y \cdot \left(9 \cdot \left(z \cdot t\right)\right)}\right) + \left(a \cdot 27\right) \cdot b \]

      rational.json-simplify-2 [=>]0.5

      \[ \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \color{blue}{b \cdot \left(a \cdot 27\right)} \]

      rational.json-simplify-43 [=>]0.6

      \[ \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \color{blue}{a \cdot \left(27 \cdot b\right)} \]

    if 1.3e-62 < z

    1. Initial program 0.3

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.3 \cdot 10^{-62}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \end{array} \]

Alternatives

Alternative 1
Error28.6
Cost1376
\[\begin{array}{l} t_1 := a \cdot \left(27 \cdot b\right)\\ \mathbf{if}\;x \leq -490:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -4.1 \cdot 10^{-26}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-88}:\\ \;\;\;\;y \cdot \left(\left(t \cdot z\right) \cdot -9\right)\\ \mathbf{elif}\;x \leq -1.06 \cdot 10^{-234}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-285}:\\ \;\;\;\;y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-246}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-129}:\\ \;\;\;\;\left(-9 \cdot t\right) \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 2
Error28.7
Cost1376
\[\begin{array}{l} t_1 := a \cdot \left(27 \cdot b\right)\\ \mathbf{if}\;x \leq -1720000:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -1.95 \cdot 10^{-26}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-89}:\\ \;\;\;\;\left(y \cdot \left(t \cdot z\right)\right) \cdot -9\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{-234}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-284}:\\ \;\;\;\;y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-129}:\\ \;\;\;\;\left(-9 \cdot t\right) \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 3
Error17.3
Cost1368
\[\begin{array}{l} t_1 := 2 \cdot x + a \cdot \left(27 \cdot b\right)\\ t_2 := 2 \cdot x - 9 \cdot \left(z \cdot \left(y \cdot t\right)\right)\\ \mathbf{if}\;t \leq -1.05 \cdot 10^{-154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 0.0075:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.5 \cdot 10^{+27}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{+115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.4 \cdot 10^{+295}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.6 \cdot 10^{+303}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right) + 2 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\ \end{array} \]
Alternative 4
Error11.8
Cost1360
\[\begin{array}{l} t_1 := a \cdot \left(27 \cdot b\right)\\ t_2 := t_1 - y \cdot \left(9 \cdot \left(t \cdot z\right)\right)\\ t_3 := 27 \cdot \left(a \cdot b\right) + 2 \cdot x\\ \mathbf{if}\;x \leq -44000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.82 \cdot 10^{-57}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-35}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 3.75 \cdot 10^{+28}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x + t_1\\ \end{array} \]
Alternative 5
Error15.5
Cost1232
\[\begin{array}{l} t_1 := 2 \cdot x - y \cdot \left(z \cdot \left(t \cdot 9\right)\right)\\ t_2 := 2 \cdot x + a \cdot \left(27 \cdot b\right)\\ \mathbf{if}\;t \leq -3.6 \cdot 10^{-156}:\\ \;\;\;\;2 \cdot x - 9 \cdot \left(z \cdot \left(y \cdot t\right)\right)\\ \mathbf{elif}\;t \leq 0.015:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.42 \cdot 10^{+79}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error1.3
Cost1220
\[\begin{array}{l} \mathbf{if}\;z \leq 9.8 \cdot 10^{+72}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x - 9 \cdot \left(z \cdot \left(y \cdot t\right)\right)\\ \end{array} \]
Alternative 7
Error1.3
Cost1220
\[\begin{array}{l} \mathbf{if}\;z \leq 3.6 \cdot 10^{+76}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x - 9 \cdot \left(z \cdot \left(y \cdot t\right)\right)\\ \end{array} \]
Alternative 8
Error28.3
Cost1112
\[\begin{array}{l} t_1 := a \cdot \left(27 \cdot b\right)\\ t_2 := y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\ \mathbf{if}\;x \leq -1680:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-25}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-88}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-235}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-285}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 9
Error28.4
Cost1112
\[\begin{array}{l} t_1 := a \cdot \left(27 \cdot b\right)\\ \mathbf{if}\;x \leq -33000000:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{-26}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-89}:\\ \;\;\;\;y \cdot \left(\left(t \cdot z\right) \cdot -9\right)\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-235}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{-285}:\\ \;\;\;\;y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 10
Error19.4
Cost972
\[\begin{array}{l} t_1 := 2 \cdot x + a \cdot \left(27 \cdot b\right)\\ \mathbf{if}\;t \leq 4.3 \cdot 10^{+198}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;\left(t \cdot z\right) \cdot \left(-9 \cdot y\right)\\ \mathbf{elif}\;t \leq 1.55 \cdot 10^{+303}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\ \end{array} \]
Alternative 11
Error19.4
Cost972
\[\begin{array}{l} \mathbf{if}\;t \leq 4.5 \cdot 10^{+198}:\\ \;\;\;\;2 \cdot x + a \cdot \left(27 \cdot b\right)\\ \mathbf{elif}\;t \leq 4 \cdot 10^{+239}:\\ \;\;\;\;\left(t \cdot z\right) \cdot \left(-9 \cdot y\right)\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{+302}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right) + 2 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\ \end{array} \]
Alternative 12
Error28.2
Cost848
\[\begin{array}{l} t_1 := 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;x \leq -10000000:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-88}:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 13
Error28.3
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -56000000:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-31}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-88}:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+29}:\\ \;\;\;\;a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 14
Error37.0
Cost192
\[2 \cdot x \]

Error

Reproduce?

herbie shell --seed 2023064 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))

  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))