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

Percentage Accurate: 90.4% → 95.6%
Time: 17.0s
Alternatives: 16
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 16 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: 90.4% 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: 95.6% accurate, 1.1× speedup?

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

\\
2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), -c \cdot i, \mathsf{fma}\left(z, t, x \cdot y\right)\right)
\end{array}
Derivation
  1. Initial program 91.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. 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.f6496.1

      \[\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.f6496.5

      \[\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 rewrites96.5%

    \[\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. Final simplification96.5%

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

Alternative 2: 83.3% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+55}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, x \cdot y\right)\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+161}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, -a \cdot \left(c \cdot i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(c \cdot \left(i \cdot -2\right)\right) \cdot \mathsf{fma}\left(c, b, a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -3.99999999999999991e123

    1. Initial program 82.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.f6478.1

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

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

    if -3.99999999999999991e123 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.00000000000000004e55

    1. Initial program 99.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. 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-*.f6488.2

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

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

    if 4.00000000000000004e55 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.9999999999999997e161

    1. Initial program 99.8%

      \[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. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(c, -\mathsf{fma}\left(b, c, a\right) \cdot i, x \cdot y\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{-1 \cdot \left(a \cdot \left(c \cdot i\right)\right)}\right) \]
    6. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{a \cdot \left(\mathsf{neg}\left(c \cdot i\right)\right)}\right) \]
      3. mul-1-negN/A

        \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, a \cdot \color{blue}{\left(-1 \cdot \left(c \cdot i\right)\right)}\right) \]
      4. lower-*.f64N/A

        \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{a \cdot \left(-1 \cdot \left(c \cdot i\right)\right)}\right) \]
      5. associate-*r*N/A

        \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, a \cdot \color{blue}{\left(\left(-1 \cdot c\right) \cdot i\right)}\right) \]
      6. *-commutativeN/A

        \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, a \cdot \color{blue}{\left(i \cdot \left(-1 \cdot c\right)\right)}\right) \]
      7. lower-*.f64N/A

        \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, a \cdot \color{blue}{\left(i \cdot \left(-1 \cdot c\right)\right)}\right) \]
      8. mul-1-negN/A

        \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, a \cdot \left(i \cdot \color{blue}{\left(\mathsf{neg}\left(c\right)\right)}\right)\right) \]
      9. lower-neg.f6455.3

        \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, a \cdot \left(i \cdot \color{blue}{\left(-c\right)}\right)\right) \]
    7. Applied rewrites55.3%

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

    if 4.9999999999999997e161 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i)

    1. Initial program 80.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 x around inf

      \[\leadsto 2 \cdot \color{blue}{\left(x \cdot y\right)} \]
    4. Step-by-step derivation
      1. lower-*.f6412.8

        \[\leadsto 2 \cdot \color{blue}{\left(x \cdot y\right)} \]
    5. Applied rewrites12.8%

      \[\leadsto 2 \cdot \color{blue}{\left(x \cdot y\right)} \]
    6. 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)} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(c \cdot \left(i \cdot -2\right)\right) \cdot \left(\color{blue}{c \cdot b} + a\right) \]
      12. lower-fma.f6484.9

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

      \[\leadsto \color{blue}{\left(c \cdot \left(i \cdot -2\right)\right) \cdot \mathsf{fma}\left(c, b, a\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification83.3%

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

Developer Target 1: 94.6% 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 2024222 
(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))))