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

Percentage Accurate: 99.8% → 99.8%
Time: 7.1s
Alternatives: 6
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 6 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, 1.0× speedup?

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

\\
3 \cdot \left(x \cdot y\right) - z
\end{array}
Derivation
  1. Initial program 99.5%

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

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

    \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 99.7%

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

    \[\leadsto 3 \cdot \left(x \cdot y\right) - z \]
  7. Add Preprocessing

Alternative 2: 69.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+91} \lor \neg \left(z \leq -0.78\right) \land \left(z \leq -5 \cdot 10^{-71} \lor \neg \left(z \leq 880000000000\right)\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -4.3e+91)
         (and (not (<= z -0.78))
              (or (<= z -5e-71) (not (<= z 880000000000.0)))))
   (- z)
   (* 3.0 (* x y))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -4.3e+91) || (!(z <= -0.78) && ((z <= -5e-71) || !(z <= 880000000000.0)))) {
		tmp = -z;
	} else {
		tmp = 3.0 * (x * y);
	}
	return tmp;
}
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 ((z <= (-4.3d+91)) .or. (.not. (z <= (-0.78d0))) .and. (z <= (-5d-71)) .or. (.not. (z <= 880000000000.0d0))) then
        tmp = -z
    else
        tmp = 3.0d0 * (x * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -4.3e+91) || (!(z <= -0.78) && ((z <= -5e-71) || !(z <= 880000000000.0)))) {
		tmp = -z;
	} else {
		tmp = 3.0 * (x * y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -4.3e+91) or (not (z <= -0.78) and ((z <= -5e-71) or not (z <= 880000000000.0))):
		tmp = -z
	else:
		tmp = 3.0 * (x * y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -4.3e+91) || (!(z <= -0.78) && ((z <= -5e-71) || !(z <= 880000000000.0))))
		tmp = Float64(-z);
	else
		tmp = Float64(3.0 * Float64(x * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -4.3e+91) || (~((z <= -0.78)) && ((z <= -5e-71) || ~((z <= 880000000000.0)))))
		tmp = -z;
	else
		tmp = 3.0 * (x * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.3e+91], And[N[Not[LessEqual[z, -0.78]], $MachinePrecision], Or[LessEqual[z, -5e-71], N[Not[LessEqual[z, 880000000000.0]], $MachinePrecision]]]], (-z), N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{+91} \lor \neg \left(z \leq -0.78\right) \land \left(z \leq -5 \cdot 10^{-71} \lor \neg \left(z \leq 880000000000\right)\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.3000000000000001e91 or -0.78000000000000003 < z < -4.99999999999999998e-71 or 8.8e11 < z

    1. Initial program 99.2%

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

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

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 75.1%

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

        \[\leadsto \color{blue}{-z} \]
    7. Simplified75.1%

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

    if -4.3000000000000001e91 < z < -0.78000000000000003 or -4.99999999999999998e-71 < z < 8.8e11

    1. Initial program 99.7%

      \[\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 \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 99.6%

      \[\leadsto \color{blue}{3 \cdot \left(x \cdot y\right)} - z \]
    6. Taylor expanded in x around inf 78.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+91} \lor \neg \left(z \leq -0.78\right) \land \left(z \leq -5 \cdot 10^{-71} \lor \neg \left(z \leq 880000000000\right)\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x \cdot y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 69.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+91} \lor \neg \left(z \leq -0.00365 \lor \neg \left(z \leq -2.7 \cdot 10^{-71}\right) \land z \leq 4300000000000\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(3 \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -6e+91)
         (not
          (or (<= z -0.00365)
              (and (not (<= z -2.7e-71)) (<= z 4300000000000.0)))))
   (- z)
   (* y (* 3.0 x))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -6e+91) || !((z <= -0.00365) || (!(z <= -2.7e-71) && (z <= 4300000000000.0)))) {
		tmp = -z;
	} else {
		tmp = y * (3.0 * x);
	}
	return tmp;
}
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 ((z <= (-6d+91)) .or. (.not. (z <= (-0.00365d0)) .or. (.not. (z <= (-2.7d-71))) .and. (z <= 4300000000000.0d0))) then
        tmp = -z
    else
        tmp = y * (3.0d0 * x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -6e+91) || !((z <= -0.00365) || (!(z <= -2.7e-71) && (z <= 4300000000000.0)))) {
		tmp = -z;
	} else {
		tmp = y * (3.0 * x);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -6e+91) or not ((z <= -0.00365) or (not (z <= -2.7e-71) and (z <= 4300000000000.0))):
		tmp = -z
	else:
		tmp = y * (3.0 * x)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -6e+91) || !((z <= -0.00365) || (!(z <= -2.7e-71) && (z <= 4300000000000.0))))
		tmp = Float64(-z);
	else
		tmp = Float64(y * Float64(3.0 * x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -6e+91) || ~(((z <= -0.00365) || (~((z <= -2.7e-71)) && (z <= 4300000000000.0)))))
		tmp = -z;
	else
		tmp = y * (3.0 * x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -6e+91], N[Not[Or[LessEqual[z, -0.00365], And[N[Not[LessEqual[z, -2.7e-71]], $MachinePrecision], LessEqual[z, 4300000000000.0]]]], $MachinePrecision]], (-z), N[(y * N[(3.0 * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+91} \lor \neg \left(z \leq -0.00365 \lor \neg \left(z \leq -2.7 \cdot 10^{-71}\right) \land z \leq 4300000000000\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.00000000000000012e91 or -0.00365000000000000003 < z < -2.7000000000000001e-71 or 4.3e12 < z

    1. Initial program 99.2%

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

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

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 75.1%

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

        \[\leadsto \color{blue}{-z} \]
    7. Simplified75.1%

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

    if -6.00000000000000012e91 < z < -0.00365000000000000003 or -2.7000000000000001e-71 < z < 4.3e12

    1. Initial program 99.7%

      \[\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 \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 99.0%

      \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \frac{z}{y} + 3 \cdot x\right)} \]
    6. Step-by-step derivation
      1. +-commutative99.0%

        \[\leadsto y \cdot \color{blue}{\left(3 \cdot x + -1 \cdot \frac{z}{y}\right)} \]
      2. fma-define99.0%

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(3, x, -1 \cdot \frac{z}{y}\right)} \]
      3. mul-1-neg99.0%

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

        \[\leadsto y \cdot \color{blue}{\left(3 \cdot x - \frac{z}{y}\right)} \]
    7. Simplified99.0%

      \[\leadsto \color{blue}{y \cdot \left(3 \cdot x - \frac{z}{y}\right)} \]
    8. Taylor expanded in x around inf 78.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+91} \lor \neg \left(z \leq -0.00365 \lor \neg \left(z \leq -2.7 \cdot 10^{-71}\right) \land z \leq 4300000000000\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(3 \cdot x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 69.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{+91}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -0.34:\\ \;\;\;\;y \cdot \left(3 \cdot x\right)\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-71} \lor \neg \left(z \leq 650000000000\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(3 \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -2.45e+91)
   (- z)
   (if (<= z -0.34)
     (* y (* 3.0 x))
     (if (or (<= z -3.1e-71) (not (<= z 650000000000.0)))
       (- z)
       (* x (* 3.0 y))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.45e+91) {
		tmp = -z;
	} else if (z <= -0.34) {
		tmp = y * (3.0 * x);
	} else if ((z <= -3.1e-71) || !(z <= 650000000000.0)) {
		tmp = -z;
	} else {
		tmp = x * (3.0 * y);
	}
	return tmp;
}
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 (z <= (-2.45d+91)) then
        tmp = -z
    else if (z <= (-0.34d0)) then
        tmp = y * (3.0d0 * x)
    else if ((z <= (-3.1d-71)) .or. (.not. (z <= 650000000000.0d0))) then
        tmp = -z
    else
        tmp = x * (3.0d0 * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.45e+91) {
		tmp = -z;
	} else if (z <= -0.34) {
		tmp = y * (3.0 * x);
	} else if ((z <= -3.1e-71) || !(z <= 650000000000.0)) {
		tmp = -z;
	} else {
		tmp = x * (3.0 * y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -2.45e+91:
		tmp = -z
	elif z <= -0.34:
		tmp = y * (3.0 * x)
	elif (z <= -3.1e-71) or not (z <= 650000000000.0):
		tmp = -z
	else:
		tmp = x * (3.0 * y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -2.45e+91)
		tmp = Float64(-z);
	elseif (z <= -0.34)
		tmp = Float64(y * Float64(3.0 * x));
	elseif ((z <= -3.1e-71) || !(z <= 650000000000.0))
		tmp = Float64(-z);
	else
		tmp = Float64(x * Float64(3.0 * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -2.45e+91)
		tmp = -z;
	elseif (z <= -0.34)
		tmp = y * (3.0 * x);
	elseif ((z <= -3.1e-71) || ~((z <= 650000000000.0)))
		tmp = -z;
	else
		tmp = x * (3.0 * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -2.45e+91], (-z), If[LessEqual[z, -0.34], N[(y * N[(3.0 * x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -3.1e-71], N[Not[LessEqual[z, 650000000000.0]], $MachinePrecision]], (-z), N[(x * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.45 \cdot 10^{+91}:\\
\;\;\;\;-z\\

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

\mathbf{elif}\;z \leq -3.1 \cdot 10^{-71} \lor \neg \left(z \leq 650000000000\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.45000000000000015e91 or -0.340000000000000024 < z < -3.10000000000000002e-71 or 6.5e11 < z

    1. Initial program 99.2%

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

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

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 75.1%

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

        \[\leadsto \color{blue}{-z} \]
    7. Simplified75.1%

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

    if -2.45000000000000015e91 < z < -0.340000000000000024

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 94.0%

      \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \frac{z}{y} + 3 \cdot x\right)} \]
    6. Step-by-step derivation
      1. +-commutative94.0%

        \[\leadsto y \cdot \color{blue}{\left(3 \cdot x + -1 \cdot \frac{z}{y}\right)} \]
      2. fma-define94.0%

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(3, x, -1 \cdot \frac{z}{y}\right)} \]
      3. mul-1-neg94.0%

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

        \[\leadsto y \cdot \color{blue}{\left(3 \cdot x - \frac{z}{y}\right)} \]
    7. Simplified94.0%

      \[\leadsto \color{blue}{y \cdot \left(3 \cdot x - \frac{z}{y}\right)} \]
    8. Taylor expanded in x around inf 93.8%

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

    if -3.10000000000000002e-71 < z < 6.5e11

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 99.6%

      \[\leadsto \color{blue}{3 \cdot \left(x \cdot y\right)} - z \]
    6. Taylor expanded in x around inf 76.4%

      \[\leadsto \color{blue}{3 \cdot \left(x \cdot y\right)} \]
    7. Step-by-step derivation
      1. *-commutative76.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{+91}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -0.34:\\ \;\;\;\;y \cdot \left(3 \cdot x\right)\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-71} \lor \neg \left(z \leq 650000000000\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(3 \cdot y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 49.6% accurate, 3.5× speedup?

\[\begin{array}{l} \\ -z \end{array} \]
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
	return -z;
}
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
public static double code(double x, double y, double z) {
	return -z;
}
def code(x, y, z):
	return -z
function code(x, y, z)
	return Float64(-z)
end
function tmp = code(x, y, z)
	tmp = -z;
end
code[x_, y_, z_] := (-z)
\begin{array}{l}

\\
-z
\end{array}
Derivation
  1. Initial program 99.5%

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

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

    \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 45.8%

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

      \[\leadsto \color{blue}{-z} \]
  7. Simplified45.8%

    \[\leadsto \color{blue}{-z} \]
  8. Final simplification45.8%

    \[\leadsto -z \]
  9. Add Preprocessing

Alternative 6: 2.3% accurate, 7.0× speedup?

\[\begin{array}{l} \\ z \end{array} \]
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
	return z;
}
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
public static double code(double x, double y, double z) {
	return z;
}
def code(x, y, z):
	return z
function code(x, y, z)
	return z
end
function tmp = code(x, y, z)
	tmp = z;
end
code[x_, y_, z_] := z
\begin{array}{l}

\\
z
\end{array}
Derivation
  1. Initial program 99.5%

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

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

    \[\leadsto \color{blue}{x \cdot \left(3 \cdot y\right) - z} \]
  4. Add Preprocessing
  5. Taylor expanded in y around inf 87.1%

    \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \frac{z}{y} + 3 \cdot x\right)} \]
  6. Step-by-step derivation
    1. +-commutative87.1%

      \[\leadsto y \cdot \color{blue}{\left(3 \cdot x + -1 \cdot \frac{z}{y}\right)} \]
    2. fma-define87.1%

      \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(3, x, -1 \cdot \frac{z}{y}\right)} \]
    3. mul-1-neg87.1%

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

      \[\leadsto y \cdot \color{blue}{\left(3 \cdot x - \frac{z}{y}\right)} \]
  7. Simplified87.1%

    \[\leadsto \color{blue}{y \cdot \left(3 \cdot x - \frac{z}{y}\right)} \]
  8. Taylor expanded in x around 0 33.5%

    \[\leadsto y \cdot \color{blue}{\left(-1 \cdot \frac{z}{y}\right)} \]
  9. Step-by-step derivation
    1. mul-1-neg33.5%

      \[\leadsto y \cdot \color{blue}{\left(-\frac{z}{y}\right)} \]
    2. distribute-neg-frac233.5%

      \[\leadsto y \cdot \color{blue}{\frac{z}{-y}} \]
  10. Simplified33.5%

    \[\leadsto y \cdot \color{blue}{\frac{z}{-y}} \]
  11. Step-by-step derivation
    1. clear-num33.4%

      \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{-y}{z}}} \]
    2. un-div-inv33.8%

      \[\leadsto \color{blue}{\frac{y}{\frac{-y}{z}}} \]
    3. add-sqr-sqrt15.6%

      \[\leadsto \frac{y}{\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{z}} \]
    4. sqrt-unprod11.2%

      \[\leadsto \frac{y}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{z}} \]
    5. sqr-neg11.2%

      \[\leadsto \frac{y}{\frac{\sqrt{\color{blue}{y \cdot y}}}{z}} \]
    6. sqrt-unprod1.1%

      \[\leadsto \frac{y}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{z}} \]
    7. add-sqr-sqrt2.4%

      \[\leadsto \frac{y}{\frac{\color{blue}{y}}{z}} \]
  12. Applied egg-rr2.4%

    \[\leadsto \color{blue}{\frac{y}{\frac{y}{z}}} \]
  13. Step-by-step derivation
    1. associate-/r/2.5%

      \[\leadsto \color{blue}{\frac{y}{y} \cdot z} \]
    2. *-inverses2.5%

      \[\leadsto \color{blue}{1} \cdot z \]
    3. *-lft-identity2.5%

      \[\leadsto \color{blue}{z} \]
  14. Simplified2.5%

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

    \[\leadsto z \]
  16. Add Preprocessing

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 2024059 
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, B"
  :precision binary64

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

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