Linear.Quaternion:$c/ from linear-1.19.1.3, E

Percentage Accurate: 99.9% → 99.9%
Time: 9.0s
Alternatives: 8
Speedup: 1.0×

Specification

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

\\
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\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 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.9% accurate, 1.0× speedup?

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

\\
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\end{array}

Alternative 1: 99.9% accurate, 0.1× speedup?

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

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

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y \]
  2. Step-by-step derivation
    1. +-commutative99.9%

      \[\leadsto \color{blue}{\left(y \cdot y + \left(x \cdot x + y \cdot y\right)\right)} + y \cdot y \]
    2. sqr-neg99.9%

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

      \[\leadsto \color{blue}{\left(\left(x \cdot x + \left(-y\right) \cdot \left(-y\right)\right) + y \cdot y\right)} + y \cdot y \]
    4. sqr-neg99.9%

      \[\leadsto \left(\left(x \cdot x + \left(-y\right) \cdot \left(-y\right)\right) + \color{blue}{\left(-y\right) \cdot \left(-y\right)}\right) + y \cdot y \]
    5. +-commutative99.9%

      \[\leadsto \color{blue}{y \cdot y + \left(\left(x \cdot x + \left(-y\right) \cdot \left(-y\right)\right) + \left(-y\right) \cdot \left(-y\right)\right)} \]
    6. fma-define100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, \left(x \cdot x + \left(-y\right) \cdot \left(-y\right)\right) + \left(-y\right) \cdot \left(-y\right)\right)} \]
    7. sqr-neg100.0%

      \[\leadsto \mathsf{fma}\left(y, y, \left(x \cdot x + \left(-y\right) \cdot \left(-y\right)\right) + \color{blue}{y \cdot y}\right) \]
    8. sqr-neg100.0%

      \[\leadsto \mathsf{fma}\left(y, y, \left(x \cdot x + \color{blue}{y \cdot y}\right) + y \cdot y\right) \]
    9. associate-+l+100.0%

      \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x + \left(y \cdot y + y \cdot y\right)}\right) \]
    10. fma-define100.0%

      \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{\mathsf{fma}\left(x, x, y \cdot y + y \cdot y\right)}\right) \]
    11. count-2100.0%

      \[\leadsto \mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, \color{blue}{2 \cdot \left(y \cdot y\right)}\right)\right) \]
  3. Simplified100.0%

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

Alternative 2: 99.9% accurate, 0.1× speedup?

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

\\
\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 3\right)\right)
\end{array}
Derivation
  1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) + \left(y \cdot y + y \cdot y\right)} \]
    2. associate-+l+99.9%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y + \left(y \cdot y + y \cdot y\right)\right)} \]
    4. count-299.9%

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y + \color{blue}{2 \cdot \left(y \cdot y\right)}\right) \]
    5. distribute-rgt1-in99.9%

      \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(2 + 1\right) \cdot \left(y \cdot y\right)}\right) \]
    6. metadata-eval99.9%

      \[\leadsto \mathsf{fma}\left(x, x, \left(2 + \color{blue}{-1 \cdot -1}\right) \cdot \left(y \cdot y\right)\right) \]
    7. *-commutative99.9%

      \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(y \cdot y\right) \cdot \left(2 + -1 \cdot -1\right)}\right) \]
    8. associate-*l*99.9%

      \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot \left(2 + -1 \cdot -1\right)\right)}\right) \]
    9. metadata-eval99.9%

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(y \cdot \left(2 + \color{blue}{1}\right)\right)\right) \]
    10. metadata-eval99.9%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 3\right)\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 3: 99.9% accurate, 1.0× speedup?

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

\\
y \cdot y + \left(y \cdot y + \left(y \cdot y + x \cdot x\right)\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y \]
  2. Add Preprocessing
  3. Final simplification99.9%

    \[\leadsto y \cdot y + \left(y \cdot y + \left(y \cdot y + x \cdot x\right)\right) \]
  4. Add Preprocessing

Alternative 4: 58.1% accurate, 3.0× speedup?

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

\\
y \cdot \left(y \cdot 3\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cube-cbrt99.2%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{x \cdot x + y \cdot y} \cdot \sqrt[3]{x \cdot x + y \cdot y}\right) \cdot \sqrt[3]{x \cdot x + y \cdot y}} + y \cdot y\right) + y \cdot y \]
    2. pow399.2%

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{x \cdot x + y \cdot y}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
    3. add-sqr-sqrt99.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    4. pow299.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{{\left(\sqrt{x \cdot x + y \cdot y}\right)}^{2}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    5. hypot-define99.2%

      \[\leadsto \left({\left(\sqrt[3]{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
  4. Applied egg-rr99.2%

    \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
  5. Taylor expanded in x around 0 52.8%

    \[\leadsto \left({\color{blue}{\left(\sqrt[3]{{y}^{2}}\right)}}^{3} + y \cdot y\right) + y \cdot y \]
  6. Step-by-step derivation
    1. pow252.8%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{y \cdot y}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    2. rem-cube-cbrt52.9%

      \[\leadsto \left(\color{blue}{y \cdot y} + y \cdot y\right) + y \cdot y \]
    3. flip-+0.0%

      \[\leadsto \color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \left(y \cdot y\right) \cdot \left(y \cdot y\right)}{y \cdot y - y \cdot y}} + y \cdot y \]
    4. distribute-lft-out--0.0%

      \[\leadsto \frac{\color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y - y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    5. +-inverses0.0%

      \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{0}}{y \cdot y - y \cdot y} + y \cdot y \]
    6. metadata-eval0.0%

      \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{\left(1 - 1\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    7. distribute-rgt-out--0.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(y \cdot y\right) - 1 \cdot \left(y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    8. distribute-lft-out--0.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(y \cdot y - y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    9. +-inverses0.0%

      \[\leadsto \frac{1 \cdot \color{blue}{0}}{y \cdot y - y \cdot y} + y \cdot y \]
    10. +-inverses0.0%

      \[\leadsto \frac{1 \cdot \color{blue}{\left({\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    11. *-un-lft-identity0.0%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}}{y \cdot y - y \cdot y} + y \cdot y \]
    12. fmm-def3.5%

      \[\leadsto \frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\color{blue}{\mathsf{fma}\left(y, y, -y \cdot y\right)}} + y \cdot y \]
    13. div-sub3.5%

      \[\leadsto \color{blue}{\left(\frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\mathsf{fma}\left(y, y, -y \cdot y\right)} - \frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\mathsf{fma}\left(y, y, -y \cdot y\right)}\right)} + y \cdot y \]
  7. Applied egg-rr0.0%

    \[\leadsto \color{blue}{\left(\frac{{y}^{4}}{0} - \frac{{y}^{4}}{0}\right)} + y \cdot y \]
  8. Simplified34.4%

    \[\leadsto \color{blue}{0} + y \cdot y \]
  9. Applied egg-rr52.9%

    \[\leadsto \color{blue}{\left(y \cdot 3\right) \cdot y} \]
  10. Final simplification52.9%

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

Alternative 5: 37.7% accurate, 5.0× speedup?

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

\\
y \cdot y
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cube-cbrt99.2%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{x \cdot x + y \cdot y} \cdot \sqrt[3]{x \cdot x + y \cdot y}\right) \cdot \sqrt[3]{x \cdot x + y \cdot y}} + y \cdot y\right) + y \cdot y \]
    2. pow399.2%

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{x \cdot x + y \cdot y}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
    3. add-sqr-sqrt99.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    4. pow299.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{{\left(\sqrt{x \cdot x + y \cdot y}\right)}^{2}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    5. hypot-define99.2%

      \[\leadsto \left({\left(\sqrt[3]{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
  4. Applied egg-rr99.2%

    \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
  5. Taylor expanded in x around 0 52.8%

    \[\leadsto \left({\color{blue}{\left(\sqrt[3]{{y}^{2}}\right)}}^{3} + y \cdot y\right) + y \cdot y \]
  6. Step-by-step derivation
    1. pow252.8%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{y \cdot y}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    2. rem-cube-cbrt52.9%

      \[\leadsto \left(\color{blue}{y \cdot y} + y \cdot y\right) + y \cdot y \]
    3. flip-+0.0%

      \[\leadsto \color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \left(y \cdot y\right) \cdot \left(y \cdot y\right)}{y \cdot y - y \cdot y}} + y \cdot y \]
    4. distribute-lft-out--0.0%

      \[\leadsto \frac{\color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y - y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    5. +-inverses0.0%

      \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{0}}{y \cdot y - y \cdot y} + y \cdot y \]
    6. metadata-eval0.0%

      \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{\left(1 - 1\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    7. distribute-rgt-out--0.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(y \cdot y\right) - 1 \cdot \left(y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    8. distribute-lft-out--0.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(y \cdot y - y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    9. +-inverses0.0%

      \[\leadsto \frac{1 \cdot \color{blue}{0}}{y \cdot y - y \cdot y} + y \cdot y \]
    10. +-inverses0.0%

      \[\leadsto \frac{1 \cdot \color{blue}{\left({\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    11. *-un-lft-identity0.0%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}}{y \cdot y - y \cdot y} + y \cdot y \]
    12. fmm-def3.5%

      \[\leadsto \frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\color{blue}{\mathsf{fma}\left(y, y, -y \cdot y\right)}} + y \cdot y \]
    13. div-sub3.5%

      \[\leadsto \color{blue}{\left(\frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\mathsf{fma}\left(y, y, -y \cdot y\right)} - \frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\mathsf{fma}\left(y, y, -y \cdot y\right)}\right)} + y \cdot y \]
  7. Applied egg-rr0.0%

    \[\leadsto \color{blue}{\left(\frac{{y}^{4}}{0} - \frac{{y}^{4}}{0}\right)} + y \cdot y \]
  8. Simplified34.4%

    \[\leadsto \color{blue}{0} + y \cdot y \]
  9. Step-by-step derivation
    1. +-lft-identity34.4%

      \[\leadsto \color{blue}{y \cdot y} \]
  10. Applied egg-rr34.4%

    \[\leadsto \color{blue}{y \cdot y} \]
  11. Add Preprocessing

Alternative 6: 3.7% accurate, 5.0× speedup?

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

\\
y \cdot 3
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cube-cbrt99.2%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{x \cdot x + y \cdot y} \cdot \sqrt[3]{x \cdot x + y \cdot y}\right) \cdot \sqrt[3]{x \cdot x + y \cdot y}} + y \cdot y\right) + y \cdot y \]
    2. pow399.2%

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{x \cdot x + y \cdot y}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
    3. add-sqr-sqrt99.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    4. pow299.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{{\left(\sqrt{x \cdot x + y \cdot y}\right)}^{2}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    5. hypot-define99.2%

      \[\leadsto \left({\left(\sqrt[3]{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
  4. Applied egg-rr99.2%

    \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
  5. Taylor expanded in x around 0 52.8%

    \[\leadsto \left({\color{blue}{\left(\sqrt[3]{{y}^{2}}\right)}}^{3} + y \cdot y\right) + y \cdot y \]
  6. Step-by-step derivation
    1. pow252.8%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{y \cdot y}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    2. rem-cube-cbrt52.9%

      \[\leadsto \left(\color{blue}{y \cdot y} + y \cdot y\right) + y \cdot y \]
    3. flip-+0.0%

      \[\leadsto \color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \left(y \cdot y\right) \cdot \left(y \cdot y\right)}{y \cdot y - y \cdot y}} + y \cdot y \]
    4. distribute-lft-out--0.0%

      \[\leadsto \frac{\color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y - y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    5. +-inverses0.0%

      \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{0}}{y \cdot y - y \cdot y} + y \cdot y \]
    6. metadata-eval0.0%

      \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{\left(1 - 1\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    7. distribute-rgt-out--0.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(y \cdot y\right) - 1 \cdot \left(y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    8. distribute-lft-out--0.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(y \cdot y - y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    9. +-inverses0.0%

      \[\leadsto \frac{1 \cdot \color{blue}{0}}{y \cdot y - y \cdot y} + y \cdot y \]
    10. +-inverses0.0%

      \[\leadsto \frac{1 \cdot \color{blue}{\left({\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    11. *-un-lft-identity0.0%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}}{y \cdot y - y \cdot y} + y \cdot y \]
    12. fmm-def3.5%

      \[\leadsto \frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\color{blue}{\mathsf{fma}\left(y, y, -y \cdot y\right)}} + y \cdot y \]
    13. div-sub3.5%

      \[\leadsto \color{blue}{\left(\frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\mathsf{fma}\left(y, y, -y \cdot y\right)} - \frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\mathsf{fma}\left(y, y, -y \cdot y\right)}\right)} + y \cdot y \]
  7. Applied egg-rr0.0%

    \[\leadsto \color{blue}{\left(\frac{{y}^{4}}{0} - \frac{{y}^{4}}{0}\right)} + y \cdot y \]
  8. Simplified34.4%

    \[\leadsto \color{blue}{0} + y \cdot y \]
  9. Step-by-step derivation
    1. +-inverses11.3%

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

      \[\leadsto \color{blue}{y \cdot y + \left(y \cdot y - y \cdot y\right)} \]
    3. associate-+r-11.3%

      \[\leadsto \color{blue}{\left(y \cdot y + y \cdot y\right) - y \cdot y} \]
    4. distribute-lft-in11.3%

      \[\leadsto \color{blue}{y \cdot \left(y + y\right)} - y \cdot y \]
    5. add-sqr-sqrt11.3%

      \[\leadsto \color{blue}{\sqrt{y \cdot \left(y + y\right)} \cdot \sqrt{y \cdot \left(y + y\right)}} - y \cdot y \]
    6. difference-of-squares34.4%

      \[\leadsto \color{blue}{\left(\sqrt{y \cdot \left(y + y\right)} + y\right) \cdot \left(\sqrt{y \cdot \left(y + y\right)} - y\right)} \]
  10. Applied egg-rr0.0%

    \[\leadsto \color{blue}{\left(y \cdot 3\right) \cdot \left(\frac{0}{0} - y\right)} \]
  11. Simplified3.8%

    \[\leadsto \color{blue}{y \cdot 3} \]
  12. Add Preprocessing

Alternative 7: 4.3% accurate, 15.0× speedup?

\[\begin{array}{l} \\ 3 \end{array} \]
(FPCore (x y) :precision binary64 3.0)
double code(double x, double y) {
	return 3.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 3.0d0
end function
public static double code(double x, double y) {
	return 3.0;
}
def code(x, y):
	return 3.0
function code(x, y)
	return 3.0
end
function tmp = code(x, y)
	tmp = 3.0;
end
code[x_, y_] := 3.0
\begin{array}{l}

\\
3
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cube-cbrt99.2%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{x \cdot x + y \cdot y} \cdot \sqrt[3]{x \cdot x + y \cdot y}\right) \cdot \sqrt[3]{x \cdot x + y \cdot y}} + y \cdot y\right) + y \cdot y \]
    2. pow399.2%

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{x \cdot x + y \cdot y}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
    3. add-sqr-sqrt99.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    4. pow299.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{{\left(\sqrt{x \cdot x + y \cdot y}\right)}^{2}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    5. hypot-define99.2%

      \[\leadsto \left({\left(\sqrt[3]{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
  4. Applied egg-rr99.2%

    \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
  5. Taylor expanded in x around 0 52.8%

    \[\leadsto \left({\color{blue}{\left(\sqrt[3]{{y}^{2}}\right)}}^{3} + y \cdot y\right) + y \cdot y \]
  6. Step-by-step derivation
    1. sqr-pow52.8%

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}} + y \cdot y\right) + y \cdot y \]
    2. rem-cube-cbrt52.6%

      \[\leadsto \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + \color{blue}{{\left(\sqrt[3]{y \cdot y}\right)}^{3}}\right) + y \cdot y \]
    3. pow252.6%

      \[\leadsto \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{\color{blue}{{y}^{2}}}\right)}^{3}\right) + y \cdot y \]
    4. sqr-pow52.6%

      \[\leadsto \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + \color{blue}{{\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}}\right) + y \cdot y \]
    5. distribute-lft-out52.6%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}\right)} + y \cdot y \]
    6. pow252.6%

      \[\leadsto {\left(\sqrt[3]{\color{blue}{y \cdot y}}\right)}^{\left(\frac{3}{2}\right)} \cdot \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}\right) + y \cdot y \]
    7. sqrt-pow152.6%

      \[\leadsto \color{blue}{\sqrt{{\left(\sqrt[3]{y \cdot y}\right)}^{3}}} \cdot \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}\right) + y \cdot y \]
    8. rem-cube-cbrt52.8%

      \[\leadsto \sqrt{\color{blue}{y \cdot y}} \cdot \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}\right) + y \cdot y \]
    9. pow252.8%

      \[\leadsto \sqrt{\color{blue}{{y}^{2}}} \cdot \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}\right) + y \cdot y \]
    10. sqrt-pow134.0%

      \[\leadsto \color{blue}{{y}^{\left(\frac{2}{2}\right)}} \cdot \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}\right) + y \cdot y \]
    11. metadata-eval34.0%

      \[\leadsto {y}^{\color{blue}{1}} \cdot \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}\right) + y \cdot y \]
    12. pow134.0%

      \[\leadsto \color{blue}{y} \cdot \left({\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt[3]{{y}^{2}}\right)}^{\left(\frac{3}{2}\right)}\right) + y \cdot y \]
  7. Applied egg-rr52.9%

    \[\leadsto \color{blue}{y \cdot \left(y + y\right)} + y \cdot y \]
  8. Taylor expanded in y around 0 52.9%

    \[\leadsto \color{blue}{3 \cdot {y}^{2}} \]
  9. Simplified4.2%

    \[\leadsto \color{blue}{3} \]
  10. Add Preprocessing

Alternative 8: 1.2% accurate, 15.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
	return -1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = -1.0d0
end function
public static double code(double x, double y) {
	return -1.0;
}
def code(x, y):
	return -1.0
function code(x, y)
	return -1.0
end
function tmp = code(x, y)
	tmp = -1.0;
end
code[x_, y_] := -1.0
\begin{array}{l}

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

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cube-cbrt99.2%

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{x \cdot x + y \cdot y} \cdot \sqrt[3]{x \cdot x + y \cdot y}\right) \cdot \sqrt[3]{x \cdot x + y \cdot y}} + y \cdot y\right) + y \cdot y \]
    2. pow399.2%

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{x \cdot x + y \cdot y}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
    3. add-sqr-sqrt99.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    4. pow299.2%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{{\left(\sqrt{x \cdot x + y \cdot y}\right)}^{2}}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    5. hypot-define99.2%

      \[\leadsto \left({\left(\sqrt[3]{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
  4. Applied egg-rr99.2%

    \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}\right)}^{3}} + y \cdot y\right) + y \cdot y \]
  5. Taylor expanded in x around 0 52.8%

    \[\leadsto \left({\color{blue}{\left(\sqrt[3]{{y}^{2}}\right)}}^{3} + y \cdot y\right) + y \cdot y \]
  6. Step-by-step derivation
    1. pow252.8%

      \[\leadsto \left({\left(\sqrt[3]{\color{blue}{y \cdot y}}\right)}^{3} + y \cdot y\right) + y \cdot y \]
    2. rem-cube-cbrt52.9%

      \[\leadsto \left(\color{blue}{y \cdot y} + y \cdot y\right) + y \cdot y \]
    3. flip-+0.0%

      \[\leadsto \color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \left(y \cdot y\right) \cdot \left(y \cdot y\right)}{y \cdot y - y \cdot y}} + y \cdot y \]
    4. distribute-lft-out--0.0%

      \[\leadsto \frac{\color{blue}{\left(y \cdot y\right) \cdot \left(y \cdot y - y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    5. +-inverses0.0%

      \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{0}}{y \cdot y - y \cdot y} + y \cdot y \]
    6. metadata-eval0.0%

      \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{\left(1 - 1\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    7. distribute-rgt-out--0.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(y \cdot y\right) - 1 \cdot \left(y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    8. distribute-lft-out--0.0%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(y \cdot y - y \cdot y\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    9. +-inverses0.0%

      \[\leadsto \frac{1 \cdot \color{blue}{0}}{y \cdot y - y \cdot y} + y \cdot y \]
    10. +-inverses0.0%

      \[\leadsto \frac{1 \cdot \color{blue}{\left({\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}\right)}}{y \cdot y - y \cdot y} + y \cdot y \]
    11. *-un-lft-identity0.0%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}}{y \cdot y - y \cdot y} + y \cdot y \]
    12. fmm-def3.5%

      \[\leadsto \frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3} - {\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\color{blue}{\mathsf{fma}\left(y, y, -y \cdot y\right)}} + y \cdot y \]
    13. div-sub3.5%

      \[\leadsto \color{blue}{\left(\frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\mathsf{fma}\left(y, y, -y \cdot y\right)} - \frac{{\left(\sqrt[3]{{y}^{2}}\right)}^{3} \cdot {\left(\sqrt[3]{{y}^{2}}\right)}^{3}}{\mathsf{fma}\left(y, y, -y \cdot y\right)}\right)} + y \cdot y \]
  7. Applied egg-rr0.0%

    \[\leadsto \color{blue}{\left(\frac{{y}^{4}}{0} - \frac{{y}^{4}}{0}\right)} + y \cdot y \]
  8. Simplified34.4%

    \[\leadsto \color{blue}{0} + y \cdot y \]
  9. Taylor expanded in y around 0 34.4%

    \[\leadsto \color{blue}{{y}^{2}} \]
  10. Simplified1.2%

    \[\leadsto \color{blue}{-1} \]
  11. Add Preprocessing

Developer Target 1: 99.9% accurate, 1.4× speedup?

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

\\
x \cdot x + y \cdot \left(y + \left(y + y\right)\right)
\end{array}

Reproduce

?
herbie shell --seed 2024185 
(FPCore (x y)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, E"
  :precision binary64

  :alt
  (! :herbie-platform default (+ (* x x) (* y (+ y (+ y y)))))

  (+ (+ (+ (* x x) (* y y)) (* y y)) (* y y)))