Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A

Percentage Accurate: 89.6% → 97.2%
Time: 16.8s
Alternatives: 13
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
real(8) function code(x, y, z, t, a, b, c, i)
    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), intent (in) :: c
    real(8), intent (in) :: i
    code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
def code(x, y, z, t, a, b, c, i):
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
function code(x, y, z, t, a, b, c, i)
	return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i)))
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\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 13 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: 89.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
real(8) function code(x, y, z, t, a, b, c, i)
    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), intent (in) :: c
    real(8), intent (in) :: i
    code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
def code(x, y, z, t, a, b, c, i):
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
function code(x, y, z, t, a, b, c, i)
	return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i)))
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\end{array}

Alternative 1: 97.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ 2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot \left(-i\right)\right)\right)\right) \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (* 2.0 (fma z t (fma x y (* (fma b c a) (* c (- i)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return 2.0 * fma(z, t, fma(x, y, (fma(b, c, a) * (c * -i))));
}
function code(x, y, z, t, a, b, c, i)
	return Float64(2.0 * fma(z, t, fma(x, y, Float64(fma(b, c, a) * Float64(c * Float64(-i))))))
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(z * t + N[(x * y + N[(N[(b * c + a), $MachinePrecision] * N[(c * (-i)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot \left(-i\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 90.1%

    \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto 2 \cdot \color{blue}{\left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)} \]
    2. sub-negN/A

      \[\leadsto 2 \cdot \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + \left(\mathsf{neg}\left(\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right)\right)} \]
    3. +-commutativeN/A

      \[\leadsto 2 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right) + \left(x \cdot y + z \cdot t\right)\right)} \]
    4. lift-*.f64N/A

      \[\leadsto 2 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i}\right)\right) + \left(x \cdot y + z \cdot t\right)\right) \]
    5. lift-*.f64N/A

      \[\leadsto 2 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\left(a + b \cdot c\right) \cdot c\right)} \cdot i\right)\right) + \left(x \cdot y + z \cdot t\right)\right) \]
    6. associate-*l*N/A

      \[\leadsto 2 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(a + b \cdot c\right) \cdot \left(c \cdot i\right)}\right)\right) + \left(x \cdot y + z \cdot t\right)\right) \]
    7. distribute-rgt-neg-inN/A

      \[\leadsto 2 \cdot \left(\color{blue}{\left(a + b \cdot c\right) \cdot \left(\mathsf{neg}\left(c \cdot i\right)\right)} + \left(x \cdot y + z \cdot t\right)\right) \]
    8. lower-fma.f64N/A

      \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(a + b \cdot c, \mathsf{neg}\left(c \cdot i\right), x \cdot y + z \cdot t\right)} \]
    9. lift-+.f64N/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\color{blue}{a + b \cdot c}, \mathsf{neg}\left(c \cdot i\right), x \cdot y + z \cdot t\right) \]
    10. +-commutativeN/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\color{blue}{b \cdot c + a}, \mathsf{neg}\left(c \cdot i\right), x \cdot y + z \cdot t\right) \]
    11. lift-*.f64N/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\color{blue}{b \cdot c} + a, \mathsf{neg}\left(c \cdot i\right), x \cdot y + z \cdot t\right) \]
    12. lower-fma.f64N/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(b, c, a\right)}, \mathsf{neg}\left(c \cdot i\right), x \cdot y + z \cdot t\right) \]
    13. distribute-rgt-neg-inN/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), \color{blue}{c \cdot \left(\mathsf{neg}\left(i\right)\right)}, x \cdot y + z \cdot t\right) \]
    14. lower-*.f64N/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), \color{blue}{c \cdot \left(\mathsf{neg}\left(i\right)\right)}, x \cdot y + z \cdot t\right) \]
    15. lower-neg.f6494.5

      \[\leadsto 2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), c \cdot \color{blue}{\left(-i\right)}, x \cdot y + z \cdot t\right) \]
    16. lift-+.f64N/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), c \cdot \left(\mathsf{neg}\left(i\right)\right), \color{blue}{x \cdot y + z \cdot t}\right) \]
    17. +-commutativeN/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), c \cdot \left(\mathsf{neg}\left(i\right)\right), \color{blue}{z \cdot t + x \cdot y}\right) \]
    18. lift-*.f64N/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), c \cdot \left(\mathsf{neg}\left(i\right)\right), \color{blue}{z \cdot t} + x \cdot y\right) \]
    19. lower-fma.f6494.9

      \[\leadsto 2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), c \cdot \left(-i\right), \color{blue}{\mathsf{fma}\left(z, t, x \cdot y\right)}\right) \]
  4. Applied rewrites94.9%

    \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), c \cdot \left(-i\right), \mathsf{fma}\left(z, t, x \cdot y\right)\right)} \]
  5. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot \left(\mathsf{neg}\left(i\right)\right)\right) + \mathsf{fma}\left(z, t, x \cdot y\right)\right)} \]
    2. +-commutativeN/A

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(z, t, x \cdot y\right) + \mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot \left(\mathsf{neg}\left(i\right)\right)\right)\right)} \]
    3. lift-*.f64N/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \mathsf{fma}\left(b, c, a\right) \cdot \color{blue}{\left(c \cdot \left(\mathsf{neg}\left(i\right)\right)\right)}\right) \]
    4. lift-neg.f64N/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot \color{blue}{\left(\mathsf{neg}\left(i\right)\right)}\right)\right) \]
    5. distribute-rgt-neg-outN/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \mathsf{fma}\left(b, c, a\right) \cdot \color{blue}{\left(\mathsf{neg}\left(c \cdot i\right)\right)}\right) \]
    6. distribute-rgt-neg-inN/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \color{blue}{\left(\mathsf{neg}\left(\mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot i\right)\right)\right)}\right) \]
    7. lift-fma.f64N/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \left(\mathsf{neg}\left(\color{blue}{\left(b \cdot c + a\right)} \cdot \left(c \cdot i\right)\right)\right)\right) \]
    8. lift-*.f64N/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \left(\mathsf{neg}\left(\left(\color{blue}{b \cdot c} + a\right) \cdot \left(c \cdot i\right)\right)\right)\right) \]
    9. +-commutativeN/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \left(\mathsf{neg}\left(\color{blue}{\left(a + b \cdot c\right)} \cdot \left(c \cdot i\right)\right)\right)\right) \]
    10. lift-+.f64N/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \left(\mathsf{neg}\left(\color{blue}{\left(a + b \cdot c\right)} \cdot \left(c \cdot i\right)\right)\right)\right) \]
    11. associate-*l*N/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \left(\mathsf{neg}\left(\color{blue}{\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i}\right)\right)\right) \]
    12. lift-*.f64N/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \left(\mathsf{neg}\left(\color{blue}{\left(\left(a + b \cdot c\right) \cdot c\right)} \cdot i\right)\right)\right) \]
    13. lift-*.f64N/A

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(z, t, x \cdot y\right) + \left(\mathsf{neg}\left(\color{blue}{\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i}\right)\right)\right) \]
    14. lift-fma.f64N/A

      \[\leadsto 2 \cdot \left(\color{blue}{\left(z \cdot t + x \cdot y\right)} + \left(\mathsf{neg}\left(\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right)\right) \]
    15. associate-+l+N/A

      \[\leadsto 2 \cdot \color{blue}{\left(z \cdot t + \left(x \cdot y + \left(\mathsf{neg}\left(\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right)\right)\right)} \]
    16. lower-fma.f64N/A

      \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(\mathsf{neg}\left(\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right)\right)} \]
    17. lift-*.f64N/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{x \cdot y} + \left(\mathsf{neg}\left(\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right)\right) \]
    18. lower-fma.f64N/A

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{\mathsf{fma}\left(x, y, \mathsf{neg}\left(\left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right)}\right) \]
  6. Applied rewrites97.3%

    \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot \left(-i\right)\right)\right)\right)} \]
  7. Add Preprocessing

Alternative 2: 82.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(\mathsf{fma}\left(b, c, a\right) \cdot -2\right) \cdot \left(c \cdot i\right)\\ t_2 := i \cdot \left(c \cdot \left(a + b \cdot c\right)\right)\\ \mathbf{if}\;t\_2 \leq -2 \cdot 10^{+197}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-16}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(x, y, z \cdot t\right)\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+137}:\\ \;\;\;\;2 \cdot \left(x \cdot y - a \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (* (* (fma b c a) -2.0) (* c i))) (t_2 (* i (* c (+ a (* b c))))))
   (if (<= t_2 -2e+197)
     t_1
     (if (<= t_2 2e-16)
       (* 2.0 (fma x y (* z t)))
       (if (<= t_2 2e+137) (* 2.0 (- (* x y) (* a (* c i)))) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (fma(b, c, a) * -2.0) * (c * i);
	double t_2 = i * (c * (a + (b * c)));
	double tmp;
	if (t_2 <= -2e+197) {
		tmp = t_1;
	} else if (t_2 <= 2e-16) {
		tmp = 2.0 * fma(x, y, (z * t));
	} else if (t_2 <= 2e+137) {
		tmp = 2.0 * ((x * y) - (a * (c * i)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(fma(b, c, a) * -2.0) * Float64(c * i))
	t_2 = Float64(i * Float64(c * Float64(a + Float64(b * c))))
	tmp = 0.0
	if (t_2 <= -2e+197)
		tmp = t_1;
	elseif (t_2 <= 2e-16)
		tmp = Float64(2.0 * fma(x, y, Float64(z * t)));
	elseif (t_2 <= 2e+137)
		tmp = Float64(2.0 * Float64(Float64(x * y) - Float64(a * Float64(c * i))));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(b * c + a), $MachinePrecision] * -2.0), $MachinePrecision] * N[(c * i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(i * N[(c * N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+197], t$95$1, If[LessEqual[t$95$2, 2e-16], N[(2.0 * N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+137], N[(2.0 * N[(N[(x * y), $MachinePrecision] - N[(a * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(\mathsf{fma}\left(b, c, a\right) \cdot -2\right) \cdot \left(c \cdot i\right)\\
t_2 := i \cdot \left(c \cdot \left(a + b \cdot c\right)\right)\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+197}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-16}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(x, y, z \cdot t\right)\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+137}:\\
\;\;\;\;2 \cdot \left(x \cdot y - a \cdot \left(c \cdot i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.9999999999999999e197 or 2.0000000000000001e137 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i)

    1. Initial program 79.6%

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
    2. Add Preprocessing
    3. Taylor expanded in i around inf

      \[\leadsto \color{blue}{-2 \cdot \left(c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto -2 \cdot \color{blue}{\left(\left(i \cdot \left(a + b \cdot c\right)\right) \cdot c\right)} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-2 \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right) \cdot c} \]
      3. distribute-rgt-inN/A

        \[\leadsto \left(-2 \cdot \color{blue}{\left(a \cdot i + \left(b \cdot c\right) \cdot i\right)}\right) \cdot c \]
      4. associate-*r*N/A

        \[\leadsto \left(-2 \cdot \left(a \cdot i + \color{blue}{b \cdot \left(c \cdot i\right)}\right)\right) \cdot c \]
      5. distribute-lft-outN/A

        \[\leadsto \color{blue}{\left(-2 \cdot \left(a \cdot i\right) + -2 \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)} \cdot c \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{c \cdot \left(-2 \cdot \left(a \cdot i\right) + -2 \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{c \cdot \left(-2 \cdot \left(a \cdot i\right) + -2 \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)} \]
      8. distribute-lft-outN/A

        \[\leadsto c \cdot \color{blue}{\left(-2 \cdot \left(a \cdot i + b \cdot \left(c \cdot i\right)\right)\right)} \]
      9. associate-*r*N/A

        \[\leadsto c \cdot \left(-2 \cdot \left(a \cdot i + \color{blue}{\left(b \cdot c\right) \cdot i}\right)\right) \]
      10. distribute-rgt-inN/A

        \[\leadsto c \cdot \left(-2 \cdot \color{blue}{\left(i \cdot \left(a + b \cdot c\right)\right)}\right) \]
      11. *-commutativeN/A

        \[\leadsto c \cdot \left(-2 \cdot \color{blue}{\left(\left(a + b \cdot c\right) \cdot i\right)}\right) \]
      12. associate-*r*N/A

        \[\leadsto c \cdot \color{blue}{\left(\left(-2 \cdot \left(a + b \cdot c\right)\right) \cdot i\right)} \]
      13. lower-*.f64N/A

        \[\leadsto c \cdot \color{blue}{\left(\left(-2 \cdot \left(a + b \cdot c\right)\right) \cdot i\right)} \]
      14. lower-*.f64N/A

        \[\leadsto c \cdot \left(\color{blue}{\left(-2 \cdot \left(a + b \cdot c\right)\right)} \cdot i\right) \]
      15. +-commutativeN/A

        \[\leadsto c \cdot \left(\left(-2 \cdot \color{blue}{\left(b \cdot c + a\right)}\right) \cdot i\right) \]
      16. lower-fma.f6481.0

        \[\leadsto c \cdot \left(\left(-2 \cdot \color{blue}{\mathsf{fma}\left(b, c, a\right)}\right) \cdot i\right) \]
    5. Applied rewrites81.0%

      \[\leadsto \color{blue}{c \cdot \left(\left(-2 \cdot \mathsf{fma}\left(b, c, a\right)\right) \cdot i\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites84.1%

        \[\leadsto \left(\mathsf{fma}\left(b, c, a\right) \cdot -2\right) \cdot \color{blue}{\left(c \cdot i\right)} \]

      if -1.9999999999999999e197 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 2e-16

      1. Initial program 98.5%

        \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
      2. Add Preprocessing
      3. Taylor expanded in c around 0

        \[\leadsto 2 \cdot \color{blue}{\left(t \cdot z + x \cdot y\right)} \]
      4. Step-by-step derivation
        1. lower-fma.f64N/A

          \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)} \]
        2. lower-*.f6486.4

          \[\leadsto 2 \cdot \mathsf{fma}\left(t, z, \color{blue}{x \cdot y}\right) \]
      5. Applied rewrites86.4%

        \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)} \]
      6. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(t, z, x \cdot y\right)} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right) \cdot 2} \]
        3. lower-*.f6486.4

          \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right) \cdot 2} \]
      7. Applied rewrites86.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) \cdot 2} \]

      if 2e-16 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 2.0000000000000001e137

      1. Initial program 99.3%

        \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
      2. Add Preprocessing
      3. Taylor expanded in x around inf

        \[\leadsto 2 \cdot \left(\color{blue}{x \cdot y} - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
      4. Step-by-step derivation
        1. lower-*.f6465.2

          \[\leadsto 2 \cdot \left(\color{blue}{x \cdot y} - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
      5. Applied rewrites65.2%

        \[\leadsto 2 \cdot \left(\color{blue}{x \cdot y} - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
      6. Taylor expanded in a around inf

        \[\leadsto 2 \cdot \left(x \cdot y - \color{blue}{a \cdot \left(c \cdot i\right)}\right) \]
      7. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto 2 \cdot \left(x \cdot y - \color{blue}{a \cdot \left(c \cdot i\right)}\right) \]
        2. lower-*.f6451.3

          \[\leadsto 2 \cdot \left(x \cdot y - a \cdot \color{blue}{\left(c \cdot i\right)}\right) \]
      8. Applied rewrites51.3%

        \[\leadsto 2 \cdot \left(x \cdot y - \color{blue}{a \cdot \left(c \cdot i\right)}\right) \]
    7. Recombined 3 regimes into one program.
    8. Final simplification82.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;i \cdot \left(c \cdot \left(a + b \cdot c\right)\right) \leq -2 \cdot 10^{+197}:\\ \;\;\;\;\left(\mathsf{fma}\left(b, c, a\right) \cdot -2\right) \cdot \left(c \cdot i\right)\\ \mathbf{elif}\;i \cdot \left(c \cdot \left(a + b \cdot c\right)\right) \leq 2 \cdot 10^{-16}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(x, y, z \cdot t\right)\\ \mathbf{elif}\;i \cdot \left(c \cdot \left(a + b \cdot c\right)\right) \leq 2 \cdot 10^{+137}:\\ \;\;\;\;2 \cdot \left(x \cdot y - a \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(b, c, a\right) \cdot -2\right) \cdot \left(c \cdot i\right)\\ \end{array} \]
    9. Add Preprocessing

    Developer Target 1: 93.8% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right) \end{array} \]
    (FPCore (x y z t a b c i)
     :precision binary64
     (* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i)))))
    double code(double x, double y, double z, double t, double a, double b, double c, double i) {
    	return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)));
    }
    
    real(8) function code(x, y, z, t, a, b, c, i)
        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), intent (in) :: c
        real(8), intent (in) :: i
        code = 2.0d0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)))
    end function
    
    public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
    	return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)));
    }
    
    def code(x, y, z, t, a, b, c, i):
    	return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)))
    
    function code(x, y, z, t, a, b, c, i)
    	return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(a + Float64(b * c)) * Float64(c * i))))
    end
    
    function tmp = code(x, y, z, t, a, b, c, i)
    	tmp = 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)));
    end
    
    code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2024228 
    (FPCore (x y z t a b c i)
      :name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
      :precision binary64
    
      :alt
      (! :herbie-platform default (* 2 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i)))))
    
      (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))