Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, B

Percentage Accurate: 99.8% → 99.8%
Time: 5.1s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left(x \cdot 3\right) \cdot y - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* (* x 3.0) y) z))
double code(double x, double y, double z) {
	return ((x * 3.0) * y) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x * 3.0d0) * y) - z
end function
public static double code(double x, double y, double z) {
	return ((x * 3.0) * y) - z;
}
def code(x, y, z):
	return ((x * 3.0) * y) - z
function code(x, y, z)
	return Float64(Float64(Float64(x * 3.0) * y) - z)
end
function tmp = code(x, y, z)
	tmp = ((x * 3.0) * y) - z;
end
code[x_, y_, z_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot 3\right) \cdot y - z
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x \cdot 3\right) \cdot y - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* (* x 3.0) y) z))
double code(double x, double y, double z) {
	return ((x * 3.0) * y) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x * 3.0d0) * y) - z
end function
public static double code(double x, double y, double z) {
	return ((x * 3.0) * y) - z;
}
def code(x, y, z):
	return ((x * 3.0) * y) - z
function code(x, y, z)
	return Float64(Float64(Float64(x * 3.0) * y) - z)
end
function tmp = code(x, y, z)
	tmp = ((x * 3.0) * y) - z;
end
code[x_, y_, z_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot 3\right) \cdot y - z
\end{array}

Alternative 1: 99.8% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \mathsf{fma}\left(x, 3 \cdot y, -z\right) \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (fma x (* 3.0 y) (- z)))
assert(x < y);
double code(double x, double y, double z) {
	return fma(x, (3.0 * y), -z);
}
x, y = sort([x, y])
function code(x, y, z)
	return fma(x, Float64(3.0 * y), Float64(-z))
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(x * N[(3.0 * y), $MachinePrecision] + (-z)), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\mathsf{fma}\left(x, 3 \cdot y, -z\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x \cdot 3\right) \cdot y - z \]
  2. Step-by-step derivation
    1. associate-*l*99.8%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right)} - z \]
    2. fma-neg99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3 \cdot y, -z\right)} \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3 \cdot y, -z\right)} \]
  4. Final simplification99.8%

    \[\leadsto \mathsf{fma}\left(x, 3 \cdot y, -z\right) \]

Alternative 2: 71.0% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -6.3 \cdot 10^{-36} \lor \neg \left(y \leq 1.1 \cdot 10^{-29}\right) \land \left(y \leq 0.00062 \lor \neg \left(y \leq 5.2 \cdot 10^{+58}\right)\right):\\ \;\;\;\;y \cdot \left(x \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -6.3e-36)
         (and (not (<= y 1.1e-29)) (or (<= y 0.00062) (not (<= y 5.2e+58)))))
   (* y (* x 3.0))
   (- z)))
assert(x < y);
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -6.3e-36) || (!(y <= 1.1e-29) && ((y <= 0.00062) || !(y <= 5.2e+58)))) {
		tmp = y * (x * 3.0);
	} else {
		tmp = -z;
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-6.3d-36)) .or. (.not. (y <= 1.1d-29)) .and. (y <= 0.00062d0) .or. (.not. (y <= 5.2d+58))) then
        tmp = y * (x * 3.0d0)
    else
        tmp = -z
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -6.3e-36) || (!(y <= 1.1e-29) && ((y <= 0.00062) || !(y <= 5.2e+58)))) {
		tmp = y * (x * 3.0);
	} else {
		tmp = -z;
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z):
	tmp = 0
	if (y <= -6.3e-36) or (not (y <= 1.1e-29) and ((y <= 0.00062) or not (y <= 5.2e+58))):
		tmp = y * (x * 3.0)
	else:
		tmp = -z
	return tmp
x, y = sort([x, y])
function code(x, y, z)
	tmp = 0.0
	if ((y <= -6.3e-36) || (!(y <= 1.1e-29) && ((y <= 0.00062) || !(y <= 5.2e+58))))
		tmp = Float64(y * Float64(x * 3.0));
	else
		tmp = Float64(-z);
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -6.3e-36) || (~((y <= 1.1e-29)) && ((y <= 0.00062) || ~((y <= 5.2e+58)))))
		tmp = y * (x * 3.0);
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[Or[LessEqual[y, -6.3e-36], And[N[Not[LessEqual[y, 1.1e-29]], $MachinePrecision], Or[LessEqual[y, 0.00062], N[Not[LessEqual[y, 5.2e+58]], $MachinePrecision]]]], N[(y * N[(x * 3.0), $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.3 \cdot 10^{-36} \lor \neg \left(y \leq 1.1 \cdot 10^{-29}\right) \land \left(y \leq 0.00062 \lor \neg \left(y \leq 5.2 \cdot 10^{+58}\right)\right):\\
\;\;\;\;y \cdot \left(x \cdot 3\right)\\

\mathbf{else}:\\
\;\;\;\;-z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.299999999999999e-36 or 1.09999999999999995e-29 < y < 6.2e-4 or 5.19999999999999976e58 < y

    1. Initial program 99.8%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Step-by-step derivation
      1. add-cbrt-cube49.7%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot 3\right) \cdot y - z\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)}} \]
      2. pow349.7%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(x \cdot 3\right) \cdot y - z\right)}^{3}}} \]
      3. *-commutative49.7%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y - z\right)}^{3}} \]
      4. associate-*l*49.7%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{3 \cdot \left(x \cdot y\right)} - z\right)}^{3}} \]
      5. fma-neg49.7%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(3, x \cdot y, -z\right)\right)}}^{3}} \]
      6. add-sqr-sqrt24.5%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{-z} \cdot \sqrt{-z}}\right)\right)}^{3}} \]
      7. sqrt-unprod40.5%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)\right)}^{3}} \]
      8. sqr-neg40.5%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \sqrt{\color{blue}{z \cdot z}}\right)\right)}^{3}} \]
      9. sqrt-unprod19.6%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right)\right)}^{3}} \]
      10. add-sqr-sqrt37.9%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{z}\right)\right)}^{3}} \]
    3. Applied egg-rr37.9%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, z\right)\right)}^{3}}} \]
    4. Taylor expanded in x around inf 29.2%

      \[\leadsto \sqrt[3]{\color{blue}{27 \cdot \left({y}^{3} \cdot {x}^{3}\right)}} \]
    5. Step-by-step derivation
      1. associate-*r*29.2%

        \[\leadsto \sqrt[3]{\color{blue}{\left(27 \cdot {y}^{3}\right) \cdot {x}^{3}}} \]
      2. metadata-eval29.2%

        \[\leadsto \sqrt[3]{\left(\color{blue}{{3}^{3}} \cdot {y}^{3}\right) \cdot {x}^{3}} \]
      3. cube-prod29.2%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(3 \cdot y\right)}^{3}} \cdot {x}^{3}} \]
      4. *-commutative29.2%

        \[\leadsto \sqrt[3]{\color{blue}{{x}^{3} \cdot {\left(3 \cdot y\right)}^{3}}} \]
      5. cube-prod38.6%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(x \cdot \left(3 \cdot y\right)\right)}^{3}}} \]
      6. associate-*r*38.6%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\left(x \cdot 3\right) \cdot y\right)}}^{3}} \]
      7. *-commutative38.6%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y\right)}^{3}} \]
    6. Simplified38.6%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(3 \cdot x\right) \cdot y\right)}^{3}}} \]
    7. Step-by-step derivation
      1. rem-cbrt-cube67.1%

        \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]
    8. Applied egg-rr67.1%

      \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]

    if -6.299999999999999e-36 < y < 1.09999999999999995e-29 or 6.2e-4 < y < 5.19999999999999976e58

    1. Initial program 99.9%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Taylor expanded in x around 0 70.6%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg70.6%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified70.6%

      \[\leadsto \color{blue}{-z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.3 \cdot 10^{-36} \lor \neg \left(y \leq 1.1 \cdot 10^{-29}\right) \land \left(y \leq 0.00062 \lor \neg \left(y \leq 5.2 \cdot 10^{+58}\right)\right):\\ \;\;\;\;y \cdot \left(x \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]

Alternative 3: 71.1% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} t_0 := y \cdot \left(x \cdot 3\right)\\ \mathbf{if}\;y \leq -7.5 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-29}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+58}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* x 3.0))))
   (if (<= y -7.5e-39)
     t_0
     (if (<= y 2.25e-29)
       (- z)
       (if (<= y 8e-5) t_0 (if (<= y 7.2e+58) (- z) (* 3.0 (* x y))))))))
assert(x < y);
double code(double x, double y, double z) {
	double t_0 = y * (x * 3.0);
	double tmp;
	if (y <= -7.5e-39) {
		tmp = t_0;
	} else if (y <= 2.25e-29) {
		tmp = -z;
	} else if (y <= 8e-5) {
		tmp = t_0;
	} else if (y <= 7.2e+58) {
		tmp = -z;
	} else {
		tmp = 3.0 * (x * y);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (x * 3.0d0)
    if (y <= (-7.5d-39)) then
        tmp = t_0
    else if (y <= 2.25d-29) then
        tmp = -z
    else if (y <= 8d-5) then
        tmp = t_0
    else if (y <= 7.2d+58) then
        tmp = -z
    else
        tmp = 3.0d0 * (x * y)
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
	double t_0 = y * (x * 3.0);
	double tmp;
	if (y <= -7.5e-39) {
		tmp = t_0;
	} else if (y <= 2.25e-29) {
		tmp = -z;
	} else if (y <= 8e-5) {
		tmp = t_0;
	} else if (y <= 7.2e+58) {
		tmp = -z;
	} else {
		tmp = 3.0 * (x * y);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z):
	t_0 = y * (x * 3.0)
	tmp = 0
	if y <= -7.5e-39:
		tmp = t_0
	elif y <= 2.25e-29:
		tmp = -z
	elif y <= 8e-5:
		tmp = t_0
	elif y <= 7.2e+58:
		tmp = -z
	else:
		tmp = 3.0 * (x * y)
	return tmp
x, y = sort([x, y])
function code(x, y, z)
	t_0 = Float64(y * Float64(x * 3.0))
	tmp = 0.0
	if (y <= -7.5e-39)
		tmp = t_0;
	elseif (y <= 2.25e-29)
		tmp = Float64(-z);
	elseif (y <= 8e-5)
		tmp = t_0;
	elseif (y <= 7.2e+58)
		tmp = Float64(-z);
	else
		tmp = Float64(3.0 * Float64(x * y));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
	t_0 = y * (x * 3.0);
	tmp = 0.0;
	if (y <= -7.5e-39)
		tmp = t_0;
	elseif (y <= 2.25e-29)
		tmp = -z;
	elseif (y <= 8e-5)
		tmp = t_0;
	elseif (y <= 7.2e+58)
		tmp = -z;
	else
		tmp = 3.0 * (x * y);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.5e-39], t$95$0, If[LessEqual[y, 2.25e-29], (-z), If[LessEqual[y, 8e-5], t$95$0, If[LessEqual[y, 7.2e+58], (-z), N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot 3\right)\\
\mathbf{if}\;y \leq -7.5 \cdot 10^{-39}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 2.25 \cdot 10^{-29}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 8 \cdot 10^{-5}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 7.2 \cdot 10^{+58}:\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;3 \cdot \left(x \cdot y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.49999999999999971e-39 or 2.2499999999999999e-29 < y < 8.00000000000000065e-5

    1. Initial program 99.9%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Step-by-step derivation
      1. add-cbrt-cube42.3%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot 3\right) \cdot y - z\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)}} \]
      2. pow342.4%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(x \cdot 3\right) \cdot y - z\right)}^{3}}} \]
      3. *-commutative42.4%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y - z\right)}^{3}} \]
      4. associate-*l*42.4%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{3 \cdot \left(x \cdot y\right)} - z\right)}^{3}} \]
      5. fma-neg42.4%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(3, x \cdot y, -z\right)\right)}}^{3}} \]
      6. add-sqr-sqrt20.7%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{-z} \cdot \sqrt{-z}}\right)\right)}^{3}} \]
      7. sqrt-unprod32.1%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)\right)}^{3}} \]
      8. sqr-neg32.1%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \sqrt{\color{blue}{z \cdot z}}\right)\right)}^{3}} \]
      9. sqrt-unprod15.8%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right)\right)}^{3}} \]
      10. add-sqr-sqrt32.2%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{z}\right)\right)}^{3}} \]
    3. Applied egg-rr32.2%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, z\right)\right)}^{3}}} \]
    4. Taylor expanded in x around inf 26.2%

      \[\leadsto \sqrt[3]{\color{blue}{27 \cdot \left({y}^{3} \cdot {x}^{3}\right)}} \]
    5. Step-by-step derivation
      1. associate-*r*26.3%

        \[\leadsto \sqrt[3]{\color{blue}{\left(27 \cdot {y}^{3}\right) \cdot {x}^{3}}} \]
      2. metadata-eval26.3%

        \[\leadsto \sqrt[3]{\left(\color{blue}{{3}^{3}} \cdot {y}^{3}\right) \cdot {x}^{3}} \]
      3. cube-prod26.3%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(3 \cdot y\right)}^{3}} \cdot {x}^{3}} \]
      4. *-commutative26.3%

        \[\leadsto \sqrt[3]{\color{blue}{{x}^{3} \cdot {\left(3 \cdot y\right)}^{3}}} \]
      5. cube-prod32.9%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(x \cdot \left(3 \cdot y\right)\right)}^{3}}} \]
      6. associate-*r*32.9%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\left(x \cdot 3\right) \cdot y\right)}}^{3}} \]
      7. *-commutative32.9%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y\right)}^{3}} \]
    6. Simplified32.9%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(3 \cdot x\right) \cdot y\right)}^{3}}} \]
    7. Step-by-step derivation
      1. rem-cbrt-cube64.0%

        \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]
    8. Applied egg-rr64.0%

      \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]

    if -7.49999999999999971e-39 < y < 2.2499999999999999e-29 or 8.00000000000000065e-5 < y < 7.19999999999999993e58

    1. Initial program 99.9%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Taylor expanded in x around 0 70.4%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg70.4%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified70.4%

      \[\leadsto \color{blue}{-z} \]

    if 7.19999999999999993e58 < y

    1. Initial program 99.8%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Step-by-step derivation
      1. add-cbrt-cube61.5%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot 3\right) \cdot y - z\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)}} \]
      2. pow361.5%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(x \cdot 3\right) \cdot y - z\right)}^{3}}} \]
      3. *-commutative61.5%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y - z\right)}^{3}} \]
      4. associate-*l*61.5%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{3 \cdot \left(x \cdot y\right)} - z\right)}^{3}} \]
      5. fma-neg61.5%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(3, x \cdot y, -z\right)\right)}}^{3}} \]
      6. add-sqr-sqrt30.7%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{-z} \cdot \sqrt{-z}}\right)\right)}^{3}} \]
      7. sqrt-unprod54.3%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)\right)}^{3}} \]
      8. sqr-neg54.3%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \sqrt{\color{blue}{z \cdot z}}\right)\right)}^{3}} \]
      9. sqrt-unprod26.0%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right)\right)}^{3}} \]
      10. add-sqr-sqrt47.0%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{z}\right)\right)}^{3}} \]
    3. Applied egg-rr47.0%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, z\right)\right)}^{3}}} \]
    4. Taylor expanded in x around inf 33.7%

      \[\leadsto \sqrt[3]{\color{blue}{27 \cdot \left({y}^{3} \cdot {x}^{3}\right)}} \]
    5. Step-by-step derivation
      1. associate-*r*33.7%

        \[\leadsto \sqrt[3]{\color{blue}{\left(27 \cdot {y}^{3}\right) \cdot {x}^{3}}} \]
      2. metadata-eval33.7%

        \[\leadsto \sqrt[3]{\left(\color{blue}{{3}^{3}} \cdot {y}^{3}\right) \cdot {x}^{3}} \]
      3. cube-prod33.8%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(3 \cdot y\right)}^{3}} \cdot {x}^{3}} \]
      4. *-commutative33.8%

        \[\leadsto \sqrt[3]{\color{blue}{{x}^{3} \cdot {\left(3 \cdot y\right)}^{3}}} \]
      5. cube-prod47.9%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(x \cdot \left(3 \cdot y\right)\right)}^{3}}} \]
      6. associate-*r*48.0%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\left(x \cdot 3\right) \cdot y\right)}}^{3}} \]
      7. *-commutative48.0%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y\right)}^{3}} \]
    6. Simplified48.0%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(3 \cdot x\right) \cdot y\right)}^{3}}} \]
    7. Step-by-step derivation
      1. rem-cbrt-cube71.1%

        \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]
      2. associate-*l*71.0%

        \[\leadsto \color{blue}{3 \cdot \left(x \cdot y\right)} \]
      3. *-commutative71.0%

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot 3} \]
    8. Applied egg-rr71.0%

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot 3} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification68.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{-39}:\\ \;\;\;\;y \cdot \left(x \cdot 3\right)\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-29}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-5}:\\ \;\;\;\;y \cdot \left(x \cdot 3\right)\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+58}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \end{array} \]

Alternative 4: 70.5% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{-40}:\\ \;\;\;\;y \cdot \left(x \cdot 3\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-50}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 0.005:\\ \;\;\;\;x \cdot \left(3 \cdot y\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+59}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.5e-40)
   (* y (* x 3.0))
   (if (<= y 8e-50)
     (- z)
     (if (<= y 0.005)
       (* x (* 3.0 y))
       (if (<= y 8e+59) (- z) (* 3.0 (* x y)))))))
assert(x < y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.5e-40) {
		tmp = y * (x * 3.0);
	} else if (y <= 8e-50) {
		tmp = -z;
	} else if (y <= 0.005) {
		tmp = x * (3.0 * y);
	} else if (y <= 8e+59) {
		tmp = -z;
	} else {
		tmp = 3.0 * (x * y);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.5d-40)) then
        tmp = y * (x * 3.0d0)
    else if (y <= 8d-50) then
        tmp = -z
    else if (y <= 0.005d0) then
        tmp = x * (3.0d0 * y)
    else if (y <= 8d+59) then
        tmp = -z
    else
        tmp = 3.0d0 * (x * y)
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.5e-40) {
		tmp = y * (x * 3.0);
	} else if (y <= 8e-50) {
		tmp = -z;
	} else if (y <= 0.005) {
		tmp = x * (3.0 * y);
	} else if (y <= 8e+59) {
		tmp = -z;
	} else {
		tmp = 3.0 * (x * y);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z):
	tmp = 0
	if y <= -1.5e-40:
		tmp = y * (x * 3.0)
	elif y <= 8e-50:
		tmp = -z
	elif y <= 0.005:
		tmp = x * (3.0 * y)
	elif y <= 8e+59:
		tmp = -z
	else:
		tmp = 3.0 * (x * y)
	return tmp
x, y = sort([x, y])
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.5e-40)
		tmp = Float64(y * Float64(x * 3.0));
	elseif (y <= 8e-50)
		tmp = Float64(-z);
	elseif (y <= 0.005)
		tmp = Float64(x * Float64(3.0 * y));
	elseif (y <= 8e+59)
		tmp = Float64(-z);
	else
		tmp = Float64(3.0 * Float64(x * y));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.5e-40)
		tmp = y * (x * 3.0);
	elseif (y <= 8e-50)
		tmp = -z;
	elseif (y <= 0.005)
		tmp = x * (3.0 * y);
	elseif (y <= 8e+59)
		tmp = -z;
	else
		tmp = 3.0 * (x * y);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, -1.5e-40], N[(y * N[(x * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e-50], (-z), If[LessEqual[y, 0.005], N[(x * N[(3.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e+59], (-z), N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-40}:\\
\;\;\;\;y \cdot \left(x \cdot 3\right)\\

\mathbf{elif}\;y \leq 8 \cdot 10^{-50}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 0.005:\\
\;\;\;\;x \cdot \left(3 \cdot y\right)\\

\mathbf{elif}\;y \leq 8 \cdot 10^{+59}:\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;3 \cdot \left(x \cdot y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.5000000000000001e-40

    1. Initial program 99.9%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Step-by-step derivation
      1. add-cbrt-cube43.4%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot 3\right) \cdot y - z\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)}} \]
      2. pow343.4%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(x \cdot 3\right) \cdot y - z\right)}^{3}}} \]
      3. *-commutative43.4%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y - z\right)}^{3}} \]
      4. associate-*l*43.4%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{3 \cdot \left(x \cdot y\right)} - z\right)}^{3}} \]
      5. fma-neg43.4%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(3, x \cdot y, -z\right)\right)}}^{3}} \]
      6. add-sqr-sqrt19.7%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{-z} \cdot \sqrt{-z}}\right)\right)}^{3}} \]
      7. sqrt-unprod32.2%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)\right)}^{3}} \]
      8. sqr-neg32.2%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \sqrt{\color{blue}{z \cdot z}}\right)\right)}^{3}} \]
      9. sqrt-unprod17.2%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right)\right)}^{3}} \]
      10. add-sqr-sqrt33.6%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{z}\right)\right)}^{3}} \]
    3. Applied egg-rr33.6%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, z\right)\right)}^{3}}} \]
    4. Taylor expanded in x around inf 27.0%

      \[\leadsto \sqrt[3]{\color{blue}{27 \cdot \left({y}^{3} \cdot {x}^{3}\right)}} \]
    5. Step-by-step derivation
      1. associate-*r*27.0%

        \[\leadsto \sqrt[3]{\color{blue}{\left(27 \cdot {y}^{3}\right) \cdot {x}^{3}}} \]
      2. metadata-eval27.0%

        \[\leadsto \sqrt[3]{\left(\color{blue}{{3}^{3}} \cdot {y}^{3}\right) \cdot {x}^{3}} \]
      3. cube-prod27.0%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(3 \cdot y\right)}^{3}} \cdot {x}^{3}} \]
      4. *-commutative27.0%

        \[\leadsto \sqrt[3]{\color{blue}{{x}^{3} \cdot {\left(3 \cdot y\right)}^{3}}} \]
      5. cube-prod34.3%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(x \cdot \left(3 \cdot y\right)\right)}^{3}}} \]
      6. associate-*r*34.3%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\left(x \cdot 3\right) \cdot y\right)}}^{3}} \]
      7. *-commutative34.3%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y\right)}^{3}} \]
    6. Simplified34.3%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(3 \cdot x\right) \cdot y\right)}^{3}}} \]
    7. Step-by-step derivation
      1. rem-cbrt-cube63.1%

        \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]
    8. Applied egg-rr63.1%

      \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]

    if -1.5000000000000001e-40 < y < 8.00000000000000006e-50 or 0.0050000000000000001 < y < 7.99999999999999977e59

    1. Initial program 99.9%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Taylor expanded in x around 0 71.2%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg71.2%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified71.2%

      \[\leadsto \color{blue}{-z} \]

    if 8.00000000000000006e-50 < y < 0.0050000000000000001

    1. Initial program 99.5%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Step-by-step derivation
      1. add-cbrt-cube24.8%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot 3\right) \cdot y - z\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)}} \]
      2. pow324.9%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(x \cdot 3\right) \cdot y - z\right)}^{3}}} \]
      3. *-commutative24.9%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y - z\right)}^{3}} \]
      4. associate-*l*24.9%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{3 \cdot \left(x \cdot y\right)} - z\right)}^{3}} \]
      5. fma-neg24.9%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(3, x \cdot y, -z\right)\right)}}^{3}} \]
      6. add-sqr-sqrt23.3%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{-z} \cdot \sqrt{-z}}\right)\right)}^{3}} \]
      7. sqrt-unprod24.2%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)\right)}^{3}} \]
      8. sqr-neg24.2%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \sqrt{\color{blue}{z \cdot z}}\right)\right)}^{3}} \]
      9. sqrt-unprod1.5%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right)\right)}^{3}} \]
      10. add-sqr-sqrt14.0%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{z}\right)\right)}^{3}} \]
    3. Applied egg-rr14.0%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, z\right)\right)}^{3}}} \]
    4. Taylor expanded in x around inf 14.1%

      \[\leadsto \sqrt[3]{\color{blue}{27 \cdot \left({y}^{3} \cdot {x}^{3}\right)}} \]
    5. Step-by-step derivation
      1. associate-*r*14.3%

        \[\leadsto \sqrt[3]{\color{blue}{\left(27 \cdot {y}^{3}\right) \cdot {x}^{3}}} \]
      2. metadata-eval14.3%

        \[\leadsto \sqrt[3]{\left(\color{blue}{{3}^{3}} \cdot {y}^{3}\right) \cdot {x}^{3}} \]
      3. cube-prod14.3%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(3 \cdot y\right)}^{3}} \cdot {x}^{3}} \]
      4. *-commutative14.3%

        \[\leadsto \sqrt[3]{\color{blue}{{x}^{3} \cdot {\left(3 \cdot y\right)}^{3}}} \]
      5. cube-prod14.3%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(x \cdot \left(3 \cdot y\right)\right)}^{3}}} \]
      6. associate-*r*14.3%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\left(x \cdot 3\right) \cdot y\right)}}^{3}} \]
      7. *-commutative14.3%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y\right)}^{3}} \]
    6. Simplified14.3%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(3 \cdot x\right) \cdot y\right)}^{3}}} \]
    7. Step-by-step derivation
      1. rem-cbrt-cube70.4%

        \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]
      2. *-commutative70.4%

        \[\leadsto \color{blue}{y \cdot \left(3 \cdot x\right)} \]
      3. associate-*r*70.9%

        \[\leadsto \color{blue}{\left(y \cdot 3\right) \cdot x} \]
    8. Applied egg-rr70.9%

      \[\leadsto \color{blue}{\left(y \cdot 3\right) \cdot x} \]

    if 7.99999999999999977e59 < y

    1. Initial program 99.8%

      \[\left(x \cdot 3\right) \cdot y - z \]
    2. Step-by-step derivation
      1. add-cbrt-cube61.5%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot 3\right) \cdot y - z\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)}} \]
      2. pow361.5%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(x \cdot 3\right) \cdot y - z\right)}^{3}}} \]
      3. *-commutative61.5%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y - z\right)}^{3}} \]
      4. associate-*l*61.5%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{3 \cdot \left(x \cdot y\right)} - z\right)}^{3}} \]
      5. fma-neg61.5%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(3, x \cdot y, -z\right)\right)}}^{3}} \]
      6. add-sqr-sqrt30.7%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{-z} \cdot \sqrt{-z}}\right)\right)}^{3}} \]
      7. sqrt-unprod54.3%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)\right)}^{3}} \]
      8. sqr-neg54.3%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \sqrt{\color{blue}{z \cdot z}}\right)\right)}^{3}} \]
      9. sqrt-unprod26.0%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right)\right)}^{3}} \]
      10. add-sqr-sqrt47.0%

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{z}\right)\right)}^{3}} \]
    3. Applied egg-rr47.0%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, z\right)\right)}^{3}}} \]
    4. Taylor expanded in x around inf 33.7%

      \[\leadsto \sqrt[3]{\color{blue}{27 \cdot \left({y}^{3} \cdot {x}^{3}\right)}} \]
    5. Step-by-step derivation
      1. associate-*r*33.7%

        \[\leadsto \sqrt[3]{\color{blue}{\left(27 \cdot {y}^{3}\right) \cdot {x}^{3}}} \]
      2. metadata-eval33.7%

        \[\leadsto \sqrt[3]{\left(\color{blue}{{3}^{3}} \cdot {y}^{3}\right) \cdot {x}^{3}} \]
      3. cube-prod33.8%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(3 \cdot y\right)}^{3}} \cdot {x}^{3}} \]
      4. *-commutative33.8%

        \[\leadsto \sqrt[3]{\color{blue}{{x}^{3} \cdot {\left(3 \cdot y\right)}^{3}}} \]
      5. cube-prod47.9%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(x \cdot \left(3 \cdot y\right)\right)}^{3}}} \]
      6. associate-*r*48.0%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(\left(x \cdot 3\right) \cdot y\right)}}^{3}} \]
      7. *-commutative48.0%

        \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y\right)}^{3}} \]
    6. Simplified48.0%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(3 \cdot x\right) \cdot y\right)}^{3}}} \]
    7. Step-by-step derivation
      1. rem-cbrt-cube71.1%

        \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot y} \]
      2. associate-*l*71.0%

        \[\leadsto \color{blue}{3 \cdot \left(x \cdot y\right)} \]
      3. *-commutative71.0%

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot 3} \]
    8. Applied egg-rr71.0%

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot 3} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification68.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{-40}:\\ \;\;\;\;y \cdot \left(x \cdot 3\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-50}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 0.005:\\ \;\;\;\;x \cdot \left(3 \cdot y\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+59}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \end{array} \]

Alternative 5: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ 3 \cdot \left(x \cdot y\right) - z \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (- (* 3.0 (* x y)) z))
assert(x < y);
double code(double x, double y, double z) {
	return (3.0 * (x * y)) - z;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (3.0d0 * (x * y)) - z
end function
assert x < y;
public static double code(double x, double y, double z) {
	return (3.0 * (x * y)) - z;
}
[x, y] = sort([x, y])
def code(x, y, z):
	return (3.0 * (x * y)) - z
x, y = sort([x, y])
function code(x, y, z)
	return Float64(Float64(3.0 * Float64(x * y)) - z)
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
	tmp = (3.0 * (x * y)) - z;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
3 \cdot \left(x \cdot y\right) - z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x \cdot 3\right) \cdot y - z \]
  2. Taylor expanded in x around 0 99.8%

    \[\leadsto \color{blue}{3 \cdot \left(y \cdot x\right)} - z \]
  3. Final simplification99.8%

    \[\leadsto 3 \cdot \left(x \cdot y\right) - z \]

Alternative 6: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ x \cdot \left(3 \cdot y\right) - z \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (- (* x (* 3.0 y)) z))
assert(x < y);
double code(double x, double y, double z) {
	return (x * (3.0 * y)) - z;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (3.0d0 * y)) - z
end function
assert x < y;
public static double code(double x, double y, double z) {
	return (x * (3.0 * y)) - z;
}
[x, y] = sort([x, y])
def code(x, y, z):
	return (x * (3.0 * y)) - z
x, y = sort([x, y])
function code(x, y, z)
	return Float64(Float64(x * Float64(3.0 * y)) - z)
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
	tmp = (x * (3.0 * y)) - z;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(N[(x * N[(3.0 * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
x \cdot \left(3 \cdot y\right) - z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x \cdot 3\right) \cdot y - z \]
  2. Step-by-step derivation
    1. associate-*l*99.8%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right)} - z \]
    2. fma-neg99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3 \cdot y, -z\right)} \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3 \cdot y, -z\right)} \]
  4. Step-by-step derivation
    1. fma-neg99.8%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
  5. Applied egg-rr99.8%

    \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
  6. Final simplification99.8%

    \[\leadsto x \cdot \left(3 \cdot y\right) - z \]

Alternative 7: 50.9% accurate, 3.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ -z \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (- z))
assert(x < y);
double code(double x, double y, double z) {
	return -z;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = -z
end function
assert x < y;
public static double code(double x, double y, double z) {
	return -z;
}
[x, y] = sort([x, y])
def code(x, y, z):
	return -z
x, y = sort([x, y])
function code(x, y, z)
	return Float64(-z)
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
	tmp = -z;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := (-z)
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
-z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x \cdot 3\right) \cdot y - z \]
  2. Taylor expanded in x around 0 53.2%

    \[\leadsto \color{blue}{-1 \cdot z} \]
  3. Step-by-step derivation
    1. mul-1-neg53.2%

      \[\leadsto \color{blue}{-z} \]
  4. Simplified53.2%

    \[\leadsto \color{blue}{-z} \]
  5. Final simplification53.2%

    \[\leadsto -z \]

Alternative 8: 2.2% accurate, 7.0× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ z \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 z)
assert(x < y);
double code(double x, double y, double z) {
	return z;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = z
end function
assert x < y;
public static double code(double x, double y, double z) {
	return z;
}
[x, y] = sort([x, y])
def code(x, y, z):
	return z
x, y = sort([x, y])
function code(x, y, z)
	return z
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
	tmp = z;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := z
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x \cdot 3\right) \cdot y - z \]
  2. Step-by-step derivation
    1. add-cbrt-cube47.1%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot 3\right) \cdot y - z\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)\right) \cdot \left(\left(x \cdot 3\right) \cdot y - z\right)}} \]
    2. pow347.1%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\left(x \cdot 3\right) \cdot y - z\right)}^{3}}} \]
    3. *-commutative47.1%

      \[\leadsto \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y - z\right)}^{3}} \]
    4. associate-*l*47.1%

      \[\leadsto \sqrt[3]{{\left(\color{blue}{3 \cdot \left(x \cdot y\right)} - z\right)}^{3}} \]
    5. fma-neg47.1%

      \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(3, x \cdot y, -z\right)\right)}}^{3}} \]
    6. add-sqr-sqrt23.7%

      \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{-z} \cdot \sqrt{-z}}\right)\right)}^{3}} \]
    7. sqrt-unprod34.1%

      \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)\right)}^{3}} \]
    8. sqr-neg34.1%

      \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \sqrt{\color{blue}{z \cdot z}}\right)\right)}^{3}} \]
    9. sqrt-unprod12.1%

      \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right)\right)}^{3}} \]
    10. add-sqr-sqrt27.2%

      \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, \color{blue}{z}\right)\right)}^{3}} \]
  3. Applied egg-rr27.2%

    \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(3, x \cdot y, z\right)\right)}^{3}}} \]
  4. Taylor expanded in x around 0 2.3%

    \[\leadsto \color{blue}{z} \]
  5. Final simplification2.3%

    \[\leadsto z \]

Developer target: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \left(3 \cdot y\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (* 3.0 y)) z))
double code(double x, double y, double z) {
	return (x * (3.0 * y)) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (3.0d0 * y)) - z
end function
public static double code(double x, double y, double z) {
	return (x * (3.0 * y)) - z;
}
def code(x, y, z):
	return (x * (3.0 * y)) - z
function code(x, y, z)
	return Float64(Float64(x * Float64(3.0 * y)) - z)
end
function tmp = code(x, y, z)
	tmp = (x * (3.0 * y)) - z;
end
code[x_, y_, z_] := N[(N[(x * N[(3.0 * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(3 \cdot y\right) - z
\end{array}

Reproduce

?
herbie shell --seed 2023221 
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (- (* x (* 3.0 y)) z)

  (- (* (* x 3.0) y) z))