Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, A

Percentage Accurate: 87.9% → 99.7%
Time: 4.7s
Alternatives: 2
Speedup: 1.0×

Specification

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

\\
\left(\left(x \cdot 3\right) \cdot x\right) \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 2 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: 87.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.0× speedup?

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

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

    \[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

      \[\leadsto y \cdot \left(\color{blue}{\left(x \cdot 3\right)} \cdot x\right) \]
    5. associate-*l*N/A

      \[\leadsto y \cdot \color{blue}{\left(x \cdot \left(3 \cdot x\right)\right)} \]
    6. *-commutativeN/A

      \[\leadsto y \cdot \left(x \cdot \color{blue}{\left(x \cdot 3\right)}\right) \]
    7. associate-*r*N/A

      \[\leadsto y \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot 3\right)} \]
    8. sqr-neg-revN/A

      \[\leadsto y \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)\right)} \cdot 3\right) \]
    9. associate-*l*N/A

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

      \[\leadsto \color{blue}{\left(y \cdot \left(\mathsf{neg}\left(x\right)\right)\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right)} \]
    11. distribute-rgt-neg-outN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot x\right)\right)} \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    12. distribute-lft-neg-inN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) \cdot x\right)} \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    13. rem-square-sqrtN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(y\right)\right) \cdot \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)}\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    14. sqrt-prodN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(y\right)\right) \cdot \color{blue}{\sqrt{x \cdot x}}\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    15. sqr-neg-revN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(y\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}}\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    16. pow2N/A

      \[\leadsto \left(\left(\mathsf{neg}\left(y\right)\right) \cdot \sqrt{\color{blue}{{\left(\mathsf{neg}\left(x\right)\right)}^{2}}}\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    17. sqrt-pow1N/A

      \[\leadsto \left(\left(\mathsf{neg}\left(y\right)\right) \cdot \color{blue}{{\left(\mathsf{neg}\left(x\right)\right)}^{\left(\frac{2}{2}\right)}}\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    18. metadata-evalN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(y\right)\right) \cdot {\left(\mathsf{neg}\left(x\right)\right)}^{\color{blue}{1}}\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    19. unpow1N/A

      \[\leadsto \left(\left(\mathsf{neg}\left(y\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    20. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right) \cdot x\right)\right)} \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    21. distribute-lft-neg-inN/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(y \cdot x\right)\right)}\right)\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    22. *-commutativeN/A

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

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

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x \cdot y\right)\right)}\right)\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    25. remove-double-negN/A

      \[\leadsto \color{blue}{\left(x \cdot y\right)} \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot 3\right) \]
    26. rem-square-sqrtN/A

      \[\leadsto \left(x \cdot y\right) \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right) \cdot 3\right) \]
    27. sqrt-prodN/A

      \[\leadsto \left(x \cdot y\right) \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\sqrt{x \cdot x}}\right)\right) \cdot 3\right) \]
    28. rem-sqrt-square-revN/A

      \[\leadsto \left(x \cdot y\right) \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left|x\right|}\right)\right) \cdot 3\right) \]
  4. Applied rewrites44.2%

    \[\leadsto \color{blue}{\left({x}^{1.5} \cdot y\right) \cdot \left(\sqrt{x} \cdot 3\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

      \[\leadsto \color{blue}{\left({x}^{\left(\frac{\frac{3}{2}}{2}\right)} \cdot \left(y \cdot {x}^{\left(\frac{\frac{3}{2}}{2}\right)}\right)\right)} \cdot \left(\sqrt{x} \cdot 3\right) \]
    7. lower-*.f64N/A

      \[\leadsto \color{blue}{\left({x}^{\left(\frac{\frac{3}{2}}{2}\right)} \cdot \left(y \cdot {x}^{\left(\frac{\frac{3}{2}}{2}\right)}\right)\right)} \cdot \left(\sqrt{x} \cdot 3\right) \]
    8. lower-pow.f64N/A

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

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

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

      \[\leadsto \left({x}^{\frac{3}{4}} \cdot \color{blue}{\left({x}^{\left(\frac{\frac{3}{2}}{2}\right)} \cdot y\right)}\right) \cdot \left(\sqrt{x} \cdot 3\right) \]
    12. lower-pow.f64N/A

      \[\leadsto \left({x}^{\frac{3}{4}} \cdot \left(\color{blue}{{x}^{\left(\frac{\frac{3}{2}}{2}\right)}} \cdot y\right)\right) \cdot \left(\sqrt{x} \cdot 3\right) \]
    13. metadata-eval46.3

      \[\leadsto \left({x}^{0.75} \cdot \left({x}^{\color{blue}{0.75}} \cdot y\right)\right) \cdot \left(\sqrt{x} \cdot 3\right) \]
  6. Applied rewrites46.3%

    \[\leadsto \color{blue}{\left({x}^{0.75} \cdot \left({x}^{0.75} \cdot y\right)\right)} \cdot \left(\sqrt{x} \cdot 3\right) \]
  7. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left({x}^{\frac{3}{4}} \cdot \left({x}^{\frac{3}{4}} \cdot y\right)\right) \cdot \left(\sqrt{x} \cdot 3\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \color{blue}{\left({x}^{\frac{3}{4}} \cdot \left({x}^{\frac{3}{4}} \cdot y\right)\right)} \cdot \left(\sqrt{x} \cdot 3\right) \]
    3. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\left(\left({x}^{\frac{3}{4}} \cdot {x}^{\frac{3}{4}}\right) \cdot y\right)} \cdot \left(\sqrt{x} \cdot 3\right) \]
    5. lift-pow.f64N/A

      \[\leadsto \left(\left(\color{blue}{{x}^{\frac{3}{4}}} \cdot {x}^{\frac{3}{4}}\right) \cdot y\right) \cdot \left(\sqrt{x} \cdot 3\right) \]
    6. lift-pow.f64N/A

      \[\leadsto \left(\left({x}^{\frac{3}{4}} \cdot \color{blue}{{x}^{\frac{3}{4}}}\right) \cdot y\right) \cdot \left(\sqrt{x} \cdot 3\right) \]
    7. pow-prod-upN/A

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

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

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

      \[\leadsto \left(\color{blue}{\left({x}^{\frac{1}{2}} \cdot x\right)} \cdot y\right) \cdot \left(\sqrt{x} \cdot 3\right) \]
    11. pow1/2N/A

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

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

      \[\leadsto \left(\color{blue}{\left(\sqrt{x} \cdot x\right)} \cdot y\right) \cdot \left(\sqrt{x} \cdot 3\right) \]
    14. *-commutativeN/A

      \[\leadsto \color{blue}{\left(y \cdot \left(\sqrt{x} \cdot x\right)\right)} \cdot \left(\sqrt{x} \cdot 3\right) \]
    15. associate-*l*N/A

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

      \[\leadsto y \cdot \left(\color{blue}{\left(\sqrt{x} \cdot x\right)} \cdot \left(\sqrt{x} \cdot 3\right)\right) \]
    17. *-commutativeN/A

      \[\leadsto y \cdot \left(\color{blue}{\left(x \cdot \sqrt{x}\right)} \cdot \left(\sqrt{x} \cdot 3\right)\right) \]
    18. associate-*l*N/A

      \[\leadsto y \cdot \color{blue}{\left(x \cdot \left(\sqrt{x} \cdot \left(\sqrt{x} \cdot 3\right)\right)\right)} \]
    19. associate-*r*N/A

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot \left(\sqrt{x} \cdot \left(\sqrt{x} \cdot 3\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \color{blue}{\left(x \cdot y\right)} \cdot \left(\sqrt{x} \cdot \left(\sqrt{x} \cdot 3\right)\right) \]
    21. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \left(\sqrt{x} \cdot \left(\sqrt{x} \cdot 3\right)\right)} \]
  8. Applied rewrites99.7%

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

Alternative 2: 87.8% accurate, 1.0× speedup?

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

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

    \[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto y \cdot \color{blue}{\left(\left(x \cdot 3\right) \cdot x\right)} \]
    4. *-commutativeN/A

      \[\leadsto y \cdot \color{blue}{\left(x \cdot \left(x \cdot 3\right)\right)} \]
    5. associate-*r*N/A

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot \left(x \cdot 3\right)} \]
    6. *-commutativeN/A

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

      \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{\left(x \cdot 3\right)} \]
    8. associate-*r*N/A

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

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot y\right)\right)} \cdot 3 \]
    10. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot y\right)} \cdot 3 \]
    11. associate-*l*N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(y \cdot 3\right)} \]
    12. fabs-sqrN/A

      \[\leadsto \color{blue}{\left|x \cdot x\right|} \cdot \left(y \cdot 3\right) \]
    13. sqr-neg-revN/A

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

      \[\leadsto \left|\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right)}\right| \cdot \left(y \cdot 3\right) \]
    15. fabs-negN/A

      \[\leadsto \color{blue}{\left|\left(\mathsf{neg}\left(x\right)\right) \cdot x\right|} \cdot \left(y \cdot 3\right) \]
    16. rem-sqrt-squareN/A

      \[\leadsto \color{blue}{\sqrt{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right)}} \cdot \left(y \cdot 3\right) \]
    17. sqrt-prodN/A

      \[\leadsto \color{blue}{\left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot x} \cdot \sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot x}\right)} \cdot \left(y \cdot 3\right) \]
    18. rem-square-sqrtN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right)} \cdot \left(y \cdot 3\right) \]
    19. *-commutativeN/A

      \[\leadsto \color{blue}{\left(x \cdot \left(\mathsf{neg}\left(x\right)\right)\right)} \cdot \left(y \cdot 3\right) \]
    20. *-commutativeN/A

      \[\leadsto \left(x \cdot \left(\mathsf{neg}\left(x\right)\right)\right) \cdot \color{blue}{\left(3 \cdot y\right)} \]
    21. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right)} \cdot \left(3 \cdot y\right) \]
    22. *-commutativeN/A

      \[\leadsto \color{blue}{\left(3 \cdot y\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right)} \]
    23. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(3 \cdot y\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right)} \]
    24. *-commutativeN/A

      \[\leadsto \color{blue}{\left(y \cdot 3\right)} \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right) \]
    25. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(y \cdot 3\right)} \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right) \]
    26. rem-square-sqrtN/A

      \[\leadsto \left(y \cdot 3\right) \cdot \color{blue}{\left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot x} \cdot \sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot x}\right)} \]
    27. sqrt-prodN/A

      \[\leadsto \left(y \cdot 3\right) \cdot \color{blue}{\sqrt{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right)}} \]
    28. rem-sqrt-squareN/A

      \[\leadsto \left(y \cdot 3\right) \cdot \color{blue}{\left|\left(\mathsf{neg}\left(x\right)\right) \cdot x\right|} \]
    29. fabs-negN/A

      \[\leadsto \left(y \cdot 3\right) \cdot \color{blue}{\left|\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot x\right)\right|} \]
    30. distribute-rgt-neg-outN/A

      \[\leadsto \left(y \cdot 3\right) \cdot \left|\color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}\right| \]
    31. sqr-neg-revN/A

      \[\leadsto \left(y \cdot 3\right) \cdot \left|\color{blue}{x \cdot x}\right| \]
  4. Applied rewrites90.0%

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

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

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

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

Reproduce

?
herbie shell --seed 2024343 
(FPCore (x y)
  :name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, A"
  :precision binary64

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

  (* (* (* x 3.0) x) y))