From Rump in a 1983 paper

Percentage Accurate: 18.8% → 100.0%
Time: 7.4s
Alternatives: 4
Speedup: 9.3×

Specification

?
\[x = 10864 \land y = 18817\]
\[\begin{array}{l} \\ \left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \end{array} \]
(FPCore (x y)
 :precision binary64
 (+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (* y y))))
double code(double x, double y) {
	return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) + (2.0 * (y * y));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0)) + (2.0d0 * (y * y))
end function
public static double code(double x, double y) {
	return ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)) + (2.0 * (y * y));
}
def code(x, y):
	return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) + (2.0 * (y * y))
function code(x, y)
	return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) + Float64(2.0 * Float64(y * y)))
end
function tmp = code(x, y)
	tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (2.0 * (y * y));
end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\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 4 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: 18.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \end{array} \]
(FPCore (x y)
 :precision binary64
 (+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (* y y))))
double code(double x, double y) {
	return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) + (2.0 * (y * y));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0)) + (2.0d0 * (y * y))
end function
public static double code(double x, double y) {
	return ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)) + (2.0 * (y * y));
}
def code(x, y):
	return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) + (2.0 * (y * y))
function code(x, y)
	return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) + Float64(2.0 * Float64(y * y)))
end
function tmp = code(x, y)
	tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (2.0 * (y * y));
end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right)
\end{array}

Alternative 1: 100.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(2 - y \cdot y, y \cdot y, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot 9\right) \end{array} \]
(FPCore (x y)
 :precision binary64
 (fma (- 2.0 (* y y)) (* y y) (* (* (* x x) (* x x)) 9.0)))
double code(double x, double y) {
	return fma((2.0 - (y * y)), (y * y), (((x * x) * (x * x)) * 9.0));
}
function code(x, y)
	return fma(Float64(2.0 - Float64(y * y)), Float64(y * y), Float64(Float64(Float64(x * x) * Float64(x * x)) * 9.0))
end
code[x_, y_] := N[(N[(2.0 - N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision] + N[(N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * 9.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(2 - y \cdot y, y \cdot y, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot 9\right)
\end{array}
Derivation
  1. Initial program 18.8%

    \[\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(9 \cdot {x}^{4} - {y}^{4}\right)}, \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
  4. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\left(9 \cdot {x}^{4}\right), \left({y}^{4}\right)\right), \mathsf{*.f64}\left(\color{blue}{2}, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \left({x}^{4}\right)\right), \left({y}^{4}\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    3. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left({y}^{4}\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left({y}^{\left(3 + 1\right)}\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left({y}^{\left(\left(2 + 1\right) + 1\right)}\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    6. pow-plusN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left({y}^{\left(2 + 1\right)} \cdot y\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    7. pow-plusN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left(\left({y}^{2} \cdot y\right) \cdot y\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left(y \cdot \left({y}^{2} \cdot y\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \left({y}^{2} \cdot y\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    10. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \left(y \cdot {y}^{2}\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left({y}^{2}\right)\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    12. unpow2N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left(y \cdot y\right)\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    13. *-lowering-*.f6418.8%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, y\right)\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
  5. Simplified18.8%

    \[\leadsto \color{blue}{\left(9 \cdot {x}^{4} - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)} + 2 \cdot \left(y \cdot y\right) \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto 2 \cdot \left(y \cdot y\right) + \color{blue}{\left(9 \cdot {x}^{4} - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)} \]
    2. sub-negN/A

      \[\leadsto 2 \cdot \left(y \cdot y\right) + \left(9 \cdot {x}^{4} + \color{blue}{\left(\mathsf{neg}\left(y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)\right)}\right) \]
    3. +-commutativeN/A

      \[\leadsto 2 \cdot \left(y \cdot y\right) + \left(\left(\mathsf{neg}\left(y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)\right) + \color{blue}{9 \cdot {x}^{4}}\right) \]
    4. associate-+r+N/A

      \[\leadsto \left(2 \cdot \left(y \cdot y\right) + \left(\mathsf{neg}\left(y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)\right)\right) + \color{blue}{9 \cdot {x}^{4}} \]
    5. unsub-negN/A

      \[\leadsto \left(2 \cdot \left(y \cdot y\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) + \color{blue}{9} \cdot {x}^{4} \]
    6. associate-*r*N/A

      \[\leadsto \left(2 \cdot \left(y \cdot y\right) - \left(y \cdot y\right) \cdot \left(y \cdot y\right)\right) + 9 \cdot {x}^{4} \]
    7. distribute-rgt-out--N/A

      \[\leadsto \left(y \cdot y\right) \cdot \left(2 - y \cdot y\right) + \color{blue}{9} \cdot {x}^{4} \]
    8. *-commutativeN/A

      \[\leadsto \left(2 - y \cdot y\right) \cdot \left(y \cdot y\right) + \color{blue}{9} \cdot {x}^{4} \]
    9. fma-defineN/A

      \[\leadsto \mathsf{fma}\left(2 - y \cdot y, \color{blue}{y \cdot y}, 9 \cdot {x}^{4}\right) \]
    10. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\left(2 - y \cdot y\right), \color{blue}{\left(y \cdot y\right)}, \left(9 \cdot {x}^{4}\right)\right) \]
    11. --lowering--.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \left(y \cdot y\right)\right), \left(\color{blue}{y} \cdot y\right), \left(9 \cdot {x}^{4}\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \left(y \cdot y\right), \left(9 \cdot {x}^{4}\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, \color{blue}{y}\right), \left(9 \cdot {x}^{4}\right)\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(9, \left({x}^{4}\right)\right)\right) \]
    15. rem-exp-logN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(9, \left({\left(e^{\log x}\right)}^{4}\right)\right)\right) \]
    16. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(\left(e^{\log x}\right), 4\right)\right)\right) \]
    17. rem-exp-log100.0%

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right)\right) \]
  7. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2 - y \cdot y, y \cdot y, 9 \cdot {x}^{4}\right)} \]
  8. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \left({x}^{4} \cdot 9\right)\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\left({x}^{4}\right), 9\right)\right) \]
    3. pow-to-expN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\left(e^{\log x \cdot 4}\right), 9\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\left(e^{4 \cdot \log x}\right), 9\right)\right) \]
    5. exp-prodN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\left({\left(e^{4}\right)}^{\log x}\right), 9\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\left({\left(e^{2 + 2}\right)}^{\log x}\right), 9\right)\right) \]
    7. prod-expN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\left({\left(e^{2} \cdot e^{2}\right)}^{\log x}\right), 9\right)\right) \]
    8. unpow-prod-downN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\left({\left(e^{2}\right)}^{\log x} \cdot {\left(e^{2}\right)}^{\log x}\right), 9\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({\left(e^{2}\right)}^{\log x}\right), \left({\left(e^{2}\right)}^{\log x}\right)\right), 9\right)\right) \]
    10. pow-expN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(e^{2 \cdot \log x}\right), \left({\left(e^{2}\right)}^{\log x}\right)\right), 9\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(e^{\log x \cdot 2}\right), \left({\left(e^{2}\right)}^{\log x}\right)\right), 9\right)\right) \]
    12. exp-lft-sqrN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(e^{\log x} \cdot e^{\log x}\right), \left({\left(e^{2}\right)}^{\log x}\right)\right), 9\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(e^{\log x}\right), \left(e^{\log x}\right)\right), \left({\left(e^{2}\right)}^{\log x}\right)\right), 9\right)\right) \]
    14. rem-exp-logN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \left(e^{\log x}\right)\right), \left({\left(e^{2}\right)}^{\log x}\right)\right), 9\right)\right) \]
    15. rem-exp-logN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \left({\left(e^{2}\right)}^{\log x}\right)\right), 9\right)\right) \]
    16. pow-expN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \left(e^{2 \cdot \log x}\right)\right), 9\right)\right) \]
    17. *-commutativeN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \left(e^{\log x \cdot 2}\right)\right), 9\right)\right) \]
    18. exp-lft-sqrN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \left(e^{\log x} \cdot e^{\log x}\right)\right), 9\right)\right) \]
    19. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(\left(e^{\log x}\right), \left(e^{\log x}\right)\right)\right), 9\right)\right) \]
    20. rem-exp-logN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(x, \left(e^{\log x}\right)\right)\right), 9\right)\right) \]
    21. rem-exp-log100.0%

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(x, x\right)\right), 9\right)\right) \]
  9. Applied egg-rr100.0%

    \[\leadsto \mathsf{fma}\left(2 - y \cdot y, y \cdot y, \color{blue}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot 9}\right) \]
  10. Add Preprocessing

Alternative 2: 18.8% accurate, 9.3× speedup?

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

\\
\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) - y \cdot \left(y \cdot -2\right)
\end{array}
Derivation
  1. Initial program 18.8%

    \[\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(9 \cdot {x}^{4} - {y}^{4}\right)}, \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
  4. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\left(9 \cdot {x}^{4}\right), \left({y}^{4}\right)\right), \mathsf{*.f64}\left(\color{blue}{2}, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \left({x}^{4}\right)\right), \left({y}^{4}\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    3. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left({y}^{4}\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left({y}^{\left(3 + 1\right)}\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left({y}^{\left(\left(2 + 1\right) + 1\right)}\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    6. pow-plusN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left({y}^{\left(2 + 1\right)} \cdot y\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    7. pow-plusN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left(\left({y}^{2} \cdot y\right) \cdot y\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \left(y \cdot \left({y}^{2} \cdot y\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \left({y}^{2} \cdot y\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    10. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \left(y \cdot {y}^{2}\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left({y}^{2}\right)\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    12. unpow2N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left(y \cdot y\right)\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
    13. *-lowering-*.f6418.8%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right), \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, y\right)\right)\right)\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right)\right) \]
  5. Simplified18.8%

    \[\leadsto \color{blue}{\left(9 \cdot {x}^{4} - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)} + 2 \cdot \left(y \cdot y\right) \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto 2 \cdot \left(y \cdot y\right) + \color{blue}{\left(9 \cdot {x}^{4} - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)} \]
    2. sub-negN/A

      \[\leadsto 2 \cdot \left(y \cdot y\right) + \left(9 \cdot {x}^{4} + \color{blue}{\left(\mathsf{neg}\left(y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)\right)}\right) \]
    3. +-commutativeN/A

      \[\leadsto 2 \cdot \left(y \cdot y\right) + \left(\left(\mathsf{neg}\left(y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)\right) + \color{blue}{9 \cdot {x}^{4}}\right) \]
    4. associate-+r+N/A

      \[\leadsto \left(2 \cdot \left(y \cdot y\right) + \left(\mathsf{neg}\left(y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right)\right)\right) + \color{blue}{9 \cdot {x}^{4}} \]
    5. unsub-negN/A

      \[\leadsto \left(2 \cdot \left(y \cdot y\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) + \color{blue}{9} \cdot {x}^{4} \]
    6. associate-*r*N/A

      \[\leadsto \left(2 \cdot \left(y \cdot y\right) - \left(y \cdot y\right) \cdot \left(y \cdot y\right)\right) + 9 \cdot {x}^{4} \]
    7. distribute-rgt-out--N/A

      \[\leadsto \left(y \cdot y\right) \cdot \left(2 - y \cdot y\right) + \color{blue}{9} \cdot {x}^{4} \]
    8. *-commutativeN/A

      \[\leadsto \left(2 - y \cdot y\right) \cdot \left(y \cdot y\right) + \color{blue}{9} \cdot {x}^{4} \]
    9. fma-defineN/A

      \[\leadsto \mathsf{fma}\left(2 - y \cdot y, \color{blue}{y \cdot y}, 9 \cdot {x}^{4}\right) \]
    10. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\left(2 - y \cdot y\right), \color{blue}{\left(y \cdot y\right)}, \left(9 \cdot {x}^{4}\right)\right) \]
    11. --lowering--.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \left(y \cdot y\right)\right), \left(\color{blue}{y} \cdot y\right), \left(9 \cdot {x}^{4}\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \left(y \cdot y\right), \left(9 \cdot {x}^{4}\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, \color{blue}{y}\right), \left(9 \cdot {x}^{4}\right)\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(9, \left({x}^{4}\right)\right)\right) \]
    15. rem-exp-logN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(9, \left({\left(e^{\log x}\right)}^{4}\right)\right)\right) \]
    16. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(\left(e^{\log x}\right), 4\right)\right)\right) \]
    17. rem-exp-log100.0%

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(9, \mathsf{pow.f64}\left(x, 4\right)\right)\right) \]
  7. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2 - y \cdot y, y \cdot y, 9 \cdot {x}^{4}\right)} \]
  8. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left(y \cdot y\right) \cdot \left(2 - y \cdot y\right) + \color{blue}{9} \cdot {x}^{4} \]
    2. sub-negN/A

      \[\leadsto \left(y \cdot y\right) \cdot \left(2 + \left(\mathsf{neg}\left(y \cdot y\right)\right)\right) + 9 \cdot {x}^{4} \]
    3. distribute-lft-inN/A

      \[\leadsto \left(\left(y \cdot y\right) \cdot 2 + \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right)\right) + \color{blue}{9} \cdot {x}^{4} \]
    4. associate-*r*N/A

      \[\leadsto \left(y \cdot \left(y \cdot 2\right) + \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right)\right) + 9 \cdot {x}^{4} \]
    5. associate-+l+N/A

      \[\leadsto y \cdot \left(y \cdot 2\right) + \color{blue}{\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right) + 9 \cdot {x}^{4}\right)} \]
    6. +-commutativeN/A

      \[\leadsto \left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right) + 9 \cdot {x}^{4}\right) + \color{blue}{y \cdot \left(y \cdot 2\right)} \]
    7. cancel-sign-subN/A

      \[\leadsto \left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right) + 9 \cdot {x}^{4}\right) - \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \left(y \cdot 2\right)} \]
    8. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right) + 9 \cdot {x}^{4}\right), \color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) \cdot \left(y \cdot 2\right)\right)}\right) \]
  9. Applied egg-rr18.8%

    \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) - y \cdot \left(y \cdot -2\right)} \]
  10. Add Preprocessing

Alternative 3: 11.1% accurate, 12.5× speedup?

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

\\
\left(y \cdot y\right) \cdot \left(2 + y \cdot y\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)
\end{array}
Derivation
  1. Initial program 18.8%

    \[\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{2 \cdot {y}^{2} - {y}^{4}} \]
  4. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto 2 \cdot {y}^{2} - {y}^{\left(3 + \color{blue}{1}\right)} \]
    2. metadata-evalN/A

      \[\leadsto 2 \cdot {y}^{2} - {y}^{\left(\left(2 + 1\right) + 1\right)} \]
    3. pow-plusN/A

      \[\leadsto 2 \cdot {y}^{2} - {y}^{\left(2 + 1\right)} \cdot \color{blue}{y} \]
    4. pow-plusN/A

      \[\leadsto 2 \cdot {y}^{2} - \left({y}^{2} \cdot y\right) \cdot y \]
    5. cancel-sign-sub-invN/A

      \[\leadsto 2 \cdot {y}^{2} + \color{blue}{\left(\mathsf{neg}\left({y}^{2} \cdot y\right)\right) \cdot y} \]
    6. unpow2N/A

      \[\leadsto 2 \cdot \left(y \cdot y\right) + \left(\mathsf{neg}\left({y}^{2} \cdot y\right)\right) \cdot y \]
    7. associate-*r*N/A

      \[\leadsto \left(2 \cdot y\right) \cdot y + \color{blue}{\left(\mathsf{neg}\left({y}^{2} \cdot y\right)\right)} \cdot y \]
    8. distribute-lft-neg-outN/A

      \[\leadsto \left(2 \cdot y\right) \cdot y + \left(\left(\mathsf{neg}\left({y}^{2}\right)\right) \cdot y\right) \cdot y \]
    9. mul-1-negN/A

      \[\leadsto \left(2 \cdot y\right) \cdot y + \left(\left(-1 \cdot {y}^{2}\right) \cdot y\right) \cdot y \]
    10. distribute-rgt-outN/A

      \[\leadsto y \cdot \color{blue}{\left(2 \cdot y + \left(-1 \cdot {y}^{2}\right) \cdot y\right)} \]
    11. distribute-rgt-inN/A

      \[\leadsto y \cdot \left(y \cdot \color{blue}{\left(2 + -1 \cdot {y}^{2}\right)}\right) \]
    12. *-commutativeN/A

      \[\leadsto y \cdot \left(\left(2 + -1 \cdot {y}^{2}\right) \cdot \color{blue}{y}\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(\left(2 + -1 \cdot {y}^{2}\right) \cdot y\right)}\right) \]
    14. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(y, \left(y \cdot \color{blue}{\left(2 + -1 \cdot {y}^{2}\right)}\right)\right) \]
    15. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \color{blue}{\left(2 + -1 \cdot {y}^{2}\right)}\right)\right) \]
    16. mul-1-negN/A

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left(2 + \left(\mathsf{neg}\left({y}^{2}\right)\right)\right)\right)\right) \]
    17. unsub-negN/A

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left(2 - \color{blue}{{y}^{2}}\right)\right)\right) \]
    18. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(2, \color{blue}{\left({y}^{2}\right)}\right)\right)\right) \]
    19. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(2, \left(y \cdot \color{blue}{y}\right)\right)\right)\right) \]
    20. *-lowering-*.f641.5%

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, \color{blue}{y}\right)\right)\right)\right) \]
  5. Simplified1.5%

    \[\leadsto \color{blue}{y \cdot \left(y \cdot \left(2 - y \cdot y\right)\right)} \]
  6. Taylor expanded in y around 0

    \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \color{blue}{2}\right)\right) \]
  7. Step-by-step derivation
    1. Simplified11.1%

      \[\leadsto y \cdot \left(y \cdot \color{blue}{2}\right) \]
    2. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto y \cdot \left(y \cdot 2\right) + \color{blue}{0} \]
      2. +-inversesN/A

        \[\leadsto y \cdot \left(y \cdot 2\right) + \left(\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y\right)}\right) \]
      3. sub-negN/A

        \[\leadsto y \cdot \left(y \cdot 2\right) + \left(\left(y \cdot y\right) \cdot \left(y \cdot y\right) + \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(y \cdot y\right)\right)\right)}\right) \]
      4. distribute-rgt-neg-outN/A

        \[\leadsto y \cdot \left(y \cdot 2\right) + \left(\left(y \cdot y\right) \cdot \left(y \cdot y\right) + \left(y \cdot y\right) \cdot \color{blue}{\left(\mathsf{neg}\left(y \cdot y\right)\right)}\right) \]
      5. +-commutativeN/A

        \[\leadsto y \cdot \left(y \cdot 2\right) + \left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right) + \color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y\right)}\right) \]
      6. associate-+r+N/A

        \[\leadsto \left(y \cdot \left(y \cdot 2\right) + \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right)\right) + \color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y\right)} \]
      7. associate-*r*N/A

        \[\leadsto \left(\left(y \cdot y\right) \cdot 2 + \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(y \cdot y\right)\right)\right) + \left(\color{blue}{y} \cdot y\right) \cdot \left(y \cdot y\right) \]
      8. distribute-lft-inN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(2 + \left(\mathsf{neg}\left(y \cdot y\right)\right)\right) + \color{blue}{\left(y \cdot y\right)} \cdot \left(y \cdot y\right) \]
      9. sub-negN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(2 - y \cdot y\right) + \left(y \cdot \color{blue}{y}\right) \cdot \left(y \cdot y\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(2 - y \cdot y\right) \cdot \left(y \cdot y\right) + \color{blue}{\left(y \cdot y\right)} \cdot \left(y \cdot y\right) \]
      11. +-commutativeN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(y \cdot y\right) + \color{blue}{\left(2 - y \cdot y\right) \cdot \left(y \cdot y\right)} \]
      12. *-commutativeN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(y \cdot y\right) + \left(y \cdot y\right) \cdot \color{blue}{\left(2 - y \cdot y\right)} \]
      13. distribute-lft-out--N/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(y \cdot y\right) + \left(\left(y \cdot y\right) \cdot 2 - \color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y\right)}\right) \]
      14. associate-*r*N/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(y \cdot y\right) + \left(y \cdot \left(y \cdot 2\right) - \color{blue}{\left(y \cdot y\right)} \cdot \left(y \cdot y\right)\right) \]
    3. Applied egg-rr11.1%

      \[\leadsto \color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y + 2\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)} \]
    4. Final simplification11.1%

      \[\leadsto \left(y \cdot y\right) \cdot \left(2 + y \cdot y\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right) \]
    5. Add Preprocessing

    Alternative 4: 11.1% accurate, 42.6× speedup?

    \[\begin{array}{l} \\ y \cdot \left(2 \cdot y\right) \end{array} \]
    (FPCore (x y) :precision binary64 (* y (* 2.0 y)))
    double code(double x, double y) {
    	return y * (2.0 * y);
    }
    
    real(8) function code(x, y)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        code = y * (2.0d0 * y)
    end function
    
    public static double code(double x, double y) {
    	return y * (2.0 * y);
    }
    
    def code(x, y):
    	return y * (2.0 * y)
    
    function code(x, y)
    	return Float64(y * Float64(2.0 * y))
    end
    
    function tmp = code(x, y)
    	tmp = y * (2.0 * y);
    end
    
    code[x_, y_] := N[(y * N[(2.0 * y), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    y \cdot \left(2 \cdot y\right)
    \end{array}
    
    Derivation
    1. Initial program 18.8%

      \[\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{2 \cdot {y}^{2} - {y}^{4}} \]
    4. Step-by-step derivation
      1. metadata-evalN/A

        \[\leadsto 2 \cdot {y}^{2} - {y}^{\left(3 + \color{blue}{1}\right)} \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot {y}^{2} - {y}^{\left(\left(2 + 1\right) + 1\right)} \]
      3. pow-plusN/A

        \[\leadsto 2 \cdot {y}^{2} - {y}^{\left(2 + 1\right)} \cdot \color{blue}{y} \]
      4. pow-plusN/A

        \[\leadsto 2 \cdot {y}^{2} - \left({y}^{2} \cdot y\right) \cdot y \]
      5. cancel-sign-sub-invN/A

        \[\leadsto 2 \cdot {y}^{2} + \color{blue}{\left(\mathsf{neg}\left({y}^{2} \cdot y\right)\right) \cdot y} \]
      6. unpow2N/A

        \[\leadsto 2 \cdot \left(y \cdot y\right) + \left(\mathsf{neg}\left({y}^{2} \cdot y\right)\right) \cdot y \]
      7. associate-*r*N/A

        \[\leadsto \left(2 \cdot y\right) \cdot y + \color{blue}{\left(\mathsf{neg}\left({y}^{2} \cdot y\right)\right)} \cdot y \]
      8. distribute-lft-neg-outN/A

        \[\leadsto \left(2 \cdot y\right) \cdot y + \left(\left(\mathsf{neg}\left({y}^{2}\right)\right) \cdot y\right) \cdot y \]
      9. mul-1-negN/A

        \[\leadsto \left(2 \cdot y\right) \cdot y + \left(\left(-1 \cdot {y}^{2}\right) \cdot y\right) \cdot y \]
      10. distribute-rgt-outN/A

        \[\leadsto y \cdot \color{blue}{\left(2 \cdot y + \left(-1 \cdot {y}^{2}\right) \cdot y\right)} \]
      11. distribute-rgt-inN/A

        \[\leadsto y \cdot \left(y \cdot \color{blue}{\left(2 + -1 \cdot {y}^{2}\right)}\right) \]
      12. *-commutativeN/A

        \[\leadsto y \cdot \left(\left(2 + -1 \cdot {y}^{2}\right) \cdot \color{blue}{y}\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(\left(2 + -1 \cdot {y}^{2}\right) \cdot y\right)}\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(y \cdot \color{blue}{\left(2 + -1 \cdot {y}^{2}\right)}\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \color{blue}{\left(2 + -1 \cdot {y}^{2}\right)}\right)\right) \]
      16. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left(2 + \left(\mathsf{neg}\left({y}^{2}\right)\right)\right)\right)\right) \]
      17. unsub-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left(2 - \color{blue}{{y}^{2}}\right)\right)\right) \]
      18. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(2, \color{blue}{\left({y}^{2}\right)}\right)\right)\right) \]
      19. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(2, \left(y \cdot \color{blue}{y}\right)\right)\right)\right) \]
      20. *-lowering-*.f641.5%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(y, \color{blue}{y}\right)\right)\right)\right) \]
    5. Simplified1.5%

      \[\leadsto \color{blue}{y \cdot \left(y \cdot \left(2 - y \cdot y\right)\right)} \]
    6. Taylor expanded in y around 0

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \color{blue}{2}\right)\right) \]
    7. Step-by-step derivation
      1. Simplified11.1%

        \[\leadsto y \cdot \left(y \cdot \color{blue}{2}\right) \]
      2. Final simplification11.1%

        \[\leadsto y \cdot \left(2 \cdot y\right) \]
      3. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2024164 
      (FPCore (x y)
        :name "From Rump in a 1983 paper"
        :precision binary64
        :pre (and (== x 10864.0) (== y 18817.0))
        (+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (* y y))))