From Rump in a 1983 paper

Percentage Accurate: 18.8% → 100.0%
Time: 6.0s
Alternatives: 5
Speedup: 1.6×

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 5 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.6× speedup?

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

\\
2 \cdot \left(y \cdot y\right) + \mathsf{fma}\left(\left(-y\right) \cdot y, y \cdot y, 9 \cdot {x}^{4}\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. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\left(\color{blue}{\left(x \cdot x\right)} \cdot 9\right) \cdot x\right) \cdot x - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
  4. Applied rewrites18.8%

    \[\leadsto \left(\color{blue}{\left(\left(\left(x \cdot x\right) \cdot 9\right) \cdot x\right) \cdot x} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
  5. Applied rewrites21.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{3}, \frac{{x}^{9} \cdot 729}{\mathsf{fma}\left({\left(x \cdot y\right)}^{4}, 9, \mathsf{fma}\left({x}^{8}, 81, {y}^{8}\right)\right)}, -\frac{{y}^{12}}{\mathsf{fma}\left({\left(x \cdot y\right)}^{4}, 9, \mathsf{fma}\left({x}^{8}, 81, {y}^{8}\right)\right)}\right)} + 2 \cdot \left(y \cdot y\right) \]
  6. Applied rewrites100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(-y\right) \cdot y, y \cdot y, {x}^{4} \cdot 9\right)} + 2 \cdot \left(y \cdot y\right) \]
  7. Final simplification100.0%

    \[\leadsto 2 \cdot \left(y \cdot y\right) + \mathsf{fma}\left(\left(-y\right) \cdot y, y \cdot y, 9 \cdot {x}^{4}\right) \]
  8. Add Preprocessing

Alternative 2: 18.8% accurate, 1.6× speedup?

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

\\
\left(\left(\left(\left(x \cdot x\right) \cdot 9\right) \cdot x\right) \cdot x - {y}^{4}\right) + 2 \cdot \left(y \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. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\left(\color{blue}{\left(x \cdot x\right)} \cdot 9\right) \cdot x\right) \cdot x - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
  4. Applied rewrites18.8%

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

Alternative 3: 11.1% accurate, 1.6× speedup?

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

\\
\mathsf{fma}\left(\left(-9 \cdot x\right) \cdot x, x \cdot x, {y}^{4}\right) + 2 \cdot \left(y \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. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\left(\color{blue}{\left(x \cdot x\right)} \cdot 9\right) \cdot x\right) \cdot x - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
  4. Applied rewrites18.8%

    \[\leadsto \left(\color{blue}{\left(\left(\left(x \cdot x\right) \cdot 9\right) \cdot x\right) \cdot x} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right) \]
  5. Applied rewrites11.1%

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

Alternative 4: 9.6% accurate, 6.6× speedup?

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

\\
\left(\left(x \cdot x\right) \cdot 9\right) \cdot \left(x \cdot x\right) - 2 \cdot \left(y \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}{-1 \cdot {y}^{4}} + 2 \cdot \left(y \cdot y\right) \]
  4. Step-by-step derivation
    1. mul-1-negN/A

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

      \[\leadsto \color{blue}{\left(-{y}^{4}\right)} + 2 \cdot \left(y \cdot y\right) \]
    3. lower-pow.f641.5

      \[\leadsto \left(-\color{blue}{{y}^{4}}\right) + 2 \cdot \left(y \cdot y\right) \]
  5. Applied rewrites1.5%

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

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

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

      \[\leadsto \color{blue}{{x}^{4} \cdot 9} + 2 \cdot \left(y \cdot y\right) \]
    3. lower-pow.f649.6

      \[\leadsto \color{blue}{{x}^{4}} \cdot 9 + 2 \cdot \left(y \cdot y\right) \]
  8. Applied rewrites9.6%

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

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

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left(y \cdot y\right)} \]
      2. fabs-sqr-revN/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left|y \cdot y\right|} \]
      3. lift-*.f64N/A

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

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left|\mathsf{neg}\left(y \cdot y\right)\right|} \]
      5. lift-*.f64N/A

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

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \left|\color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot y}\right| \]
      7. lift-neg.f64N/A

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

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \left|\color{blue}{\left(-y\right) \cdot y}\right| \]
      9. unpow1N/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \left|\color{blue}{{\left(\left(-y\right) \cdot y\right)}^{1}}\right| \]
      10. sqr-powN/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \left|\color{blue}{{\left(\left(-y\right) \cdot y\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\left(-y\right) \cdot y\right)}^{\left(\frac{1}{2}\right)}}\right| \]
      11. fabs-sqr-revN/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left({\left(\left(-y\right) \cdot y\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\left(-y\right) \cdot y\right)}^{\left(\frac{1}{2}\right)}\right)} \]
      12. sqr-powN/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{{\left(\left(-y\right) \cdot y\right)}^{1}} \]
      13. unpow19.6

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left(\left(-y\right) \cdot y\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left(\left(-y\right) \cdot y\right)} \]
      15. lift-neg.f64N/A

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

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left(\mathsf{neg}\left(y \cdot y\right)\right)} \]
      17. lift-*.f64N/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \left(\mathsf{neg}\left(\color{blue}{y \cdot y}\right)\right) \]
      18. lower-neg.f649.6

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left(-y \cdot y\right)} \]
    3. Applied rewrites9.6%

      \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + 2 \cdot \color{blue}{\left(-y \cdot y\right)} \]
    4. Final simplification9.6%

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

    Alternative 5: 9.6% accurate, 10.7× speedup?

    \[\begin{array}{l} \\ \left(\left(x \cdot x\right) \cdot 9\right) \cdot \left(x \cdot x\right) \end{array} \]
    (FPCore (x y) :precision binary64 (* (* (* x x) 9.0) (* x x)))
    double code(double x, double y) {
    	return ((x * x) * 9.0) * (x * x);
    }
    
    real(8) function code(x, y)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        code = ((x * x) * 9.0d0) * (x * x)
    end function
    
    public static double code(double x, double y) {
    	return ((x * x) * 9.0) * (x * x);
    }
    
    def code(x, y):
    	return ((x * x) * 9.0) * (x * x)
    
    function code(x, y)
    	return Float64(Float64(Float64(x * x) * 9.0) * Float64(x * x))
    end
    
    function tmp = code(x, y)
    	tmp = ((x * x) * 9.0) * (x * x);
    end
    
    code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] * 9.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \left(\left(x \cdot x\right) \cdot 9\right) \cdot \left(x \cdot x\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}{-1 \cdot {y}^{4}} + 2 \cdot \left(y \cdot y\right) \]
    4. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto \color{blue}{\left(-{y}^{4}\right)} + 2 \cdot \left(y \cdot y\right) \]
      3. lower-pow.f641.5

        \[\leadsto \left(-\color{blue}{{y}^{4}}\right) + 2 \cdot \left(y \cdot y\right) \]
    5. Applied rewrites1.5%

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

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

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

        \[\leadsto \color{blue}{{x}^{4} \cdot 9} + 2 \cdot \left(y \cdot y\right) \]
      3. lower-pow.f649.6

        \[\leadsto \color{blue}{{x}^{4}} \cdot 9 + 2 \cdot \left(y \cdot y\right) \]
    8. Applied rewrites9.6%

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

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

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \color{blue}{2 \cdot \left(y \cdot y\right)} \]
        2. count-2-revN/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \color{blue}{\left(y \cdot y + y \cdot y\right)} \]
        3. lift-*.f64N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y + \color{blue}{y \cdot y}\right) \]
        4. cancel-sign-sub-invN/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \color{blue}{\left(y \cdot y - \left(\mathsf{neg}\left(y\right)\right) \cdot y\right)} \]
        5. lift-neg.f64N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \color{blue}{\left(-y\right)} \cdot y\right) \]
        6. lift-*.f64N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \color{blue}{\left(-y\right) \cdot y}\right) \]
        7. unpow1N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \color{blue}{{\left(\left(-y\right) \cdot y\right)}^{1}}\right) \]
        8. sqr-powN/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \color{blue}{{\left(\left(-y\right) \cdot y\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\left(-y\right) \cdot y\right)}^{\left(\frac{1}{2}\right)}}\right) \]
        9. fabs-sqr-revN/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \color{blue}{\left|{\left(\left(-y\right) \cdot y\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\left(-y\right) \cdot y\right)}^{\left(\frac{1}{2}\right)}\right|}\right) \]
        10. sqr-powN/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \left|\color{blue}{{\left(\left(-y\right) \cdot y\right)}^{1}}\right|\right) \]
        11. unpow1N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \left|\color{blue}{\left(-y\right) \cdot y}\right|\right) \]
        12. lift-*.f64N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \left|\color{blue}{\left(-y\right) \cdot y}\right|\right) \]
        13. lift-neg.f64N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \left|\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot y\right|\right) \]
        14. distribute-lft-neg-outN/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \left|\color{blue}{\mathsf{neg}\left(y \cdot y\right)}\right|\right) \]
        15. lift-*.f64N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \left|\mathsf{neg}\left(\color{blue}{y \cdot y}\right)\right|\right) \]
        16. neg-fabsN/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \color{blue}{\left|y \cdot y\right|}\right) \]
        17. lift-*.f64N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \left|\color{blue}{y \cdot y}\right|\right) \]
        18. fabs-sqr-revN/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \color{blue}{y \cdot y}\right) \]
        19. lift-*.f64N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \left(y \cdot y - \color{blue}{y \cdot y}\right) \]
        20. +-inverses9.6

          \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \color{blue}{0} \]
      3. Applied rewrites9.6%

        \[\leadsto \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) + \color{blue}{0} \]
      4. Final simplification9.6%

        \[\leadsto \left(\left(x \cdot x\right) \cdot 9\right) \cdot \left(x \cdot x\right) \]
      5. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2024312 
      (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))))