math.cube on complex, real part

Percentage Accurate: 82.5% → 96.4%
Time: 6.5s
Alternatives: 7
Speedup: 1.5×

Specification

?
\[\begin{array}{l} \\ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (-
  (* (- (* x.re x.re) (* x.im x.im)) x.re)
  (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im):
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im)
	return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im))
end
function tmp = code(x_46_re, x_46_im)
	tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\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 7 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: 82.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (-
  (* (- (* x.re x.re) (* x.im x.im)) x.re)
  (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im):
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im)
	return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im))
end
function tmp = code(x_46_re, x_46_im)
	tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\end{array}

Alternative 1: 96.4% accurate, 0.2× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq 6.5 \cdot 10^{+153}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 6.5e+153)
   (* x.re (fma x.re x.re (* x.im (* x.im -3.0))))
   (* x.im (* x.im (* x.re -3.0)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 6.5e+153) {
		tmp = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= 6.5e+153)
		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0))));
	else
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0)));
	end
	return tmp
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 6.5e+153], N[(x$46$re * N[(x$46$re * x$46$re + N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 6.5 \cdot 10^{+153}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 6.49999999999999972e153

    1. Initial program 85.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--92.1%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-92.1%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-92.1%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg92.1%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+92.1%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef94.8%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-194.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-294.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*94.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--94.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*94.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval94.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified94.7%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]

    if 6.49999999999999972e153 < x.im

    1. Initial program 60.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative60.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out60.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*60.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative60.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--60.0%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-60.0%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-60.0%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg60.0%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+60.0%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef70.3%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-170.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-270.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*70.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--70.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*70.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval70.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified70.3%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around 0 70.3%

      \[\leadsto \color{blue}{-3 \cdot \left(x.re \cdot {x.im}^{2}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*70.3%

        \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot {x.im}^{2}} \]
      2. unpow270.3%

        \[\leadsto \left(-3 \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot x.im\right)} \]
    6. Simplified70.3%

      \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt21.4%

        \[\leadsto \color{blue}{\sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)} \cdot \sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)}} \]
      2. pow221.4%

        \[\leadsto \color{blue}{{\left(\sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)}\right)}^{2}} \]
      3. *-commutative21.4%

        \[\leadsto {\left(\sqrt{\color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-3 \cdot x.re\right)}}\right)}^{2} \]
      4. sqrt-prod21.4%

        \[\leadsto {\color{blue}{\left(\sqrt{x.im \cdot x.im} \cdot \sqrt{-3 \cdot x.re}\right)}}^{2} \]
      5. sqrt-prod34.3%

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-3 \cdot x.re}\right)}^{2} \]
      6. add-sqr-sqrt34.3%

        \[\leadsto {\left(\color{blue}{x.im} \cdot \sqrt{-3 \cdot x.re}\right)}^{2} \]
      7. *-commutative34.3%

        \[\leadsto {\left(x.im \cdot \sqrt{\color{blue}{x.re \cdot -3}}\right)}^{2} \]
    8. Applied egg-rr34.3%

      \[\leadsto \color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2}} \]
    9. Step-by-step derivation
      1. add-cbrt-cube27.9%

        \[\leadsto {\color{blue}{\left(\sqrt[3]{\left(\left(x.im \cdot \sqrt{x.re \cdot -3}\right) \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)\right) \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)}\right)}}^{2} \]
      2. unpow227.9%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2}} \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)}\right)}^{2} \]
      3. pow127.9%

        \[\leadsto {\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2} \cdot \color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{1}}}\right)}^{2} \]
      4. pow-prod-up27.9%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{\left(2 + 1\right)}}}\right)}^{2} \]
      5. metadata-eval27.9%

        \[\leadsto {\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{\color{blue}{3}}}\right)}^{2} \]
    10. Applied egg-rr27.9%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{3}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. rem-cbrt-cube34.3%

        \[\leadsto {\color{blue}{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}}^{2} \]
      2. unpow-prod-down21.4%

        \[\leadsto \color{blue}{{x.im}^{2} \cdot {\left(\sqrt{x.re \cdot -3}\right)}^{2}} \]
      3. pow221.4%

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot {\left(\sqrt{x.re \cdot -3}\right)}^{2} \]
      4. pow221.4%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(\sqrt{x.re \cdot -3} \cdot \sqrt{x.re \cdot -3}\right)} \]
      5. add-sqr-sqrt70.3%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(x.re \cdot -3\right)} \]
      6. *-commutative70.3%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-3 \cdot x.re\right)} \]
      7. associate-*l*96.5%

        \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-3 \cdot x.re\right)\right)} \]
    12. Applied egg-rr96.5%

      \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-3 \cdot x.re\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification94.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 6.5 \cdot 10^{+153}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \]

Alternative 2: 75.1% accurate, 1.4× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq 3.6 \cdot 10^{-34} \lor \neg \left(x.im \leq 4.4 \cdot 10^{+100}\right) \land x.im \leq 2.4 \cdot 10^{+126}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im 3.6e-34) (and (not (<= x.im 4.4e+100)) (<= x.im 2.4e+126)))
   (* x.re (* x.re x.re))
   (* -3.0 (* x.re (* x.im x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= 3.6e-34) || (!(x_46_im <= 4.4e+100) && (x_46_im <= 2.4e+126))) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46im <= 3.6d-34) .or. (.not. (x_46im <= 4.4d+100)) .and. (x_46im <= 2.4d+126)) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= 3.6e-34) || (!(x_46_im <= 4.4e+100) && (x_46_im <= 2.4e+126))) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= 3.6e-34) or (not (x_46_im <= 4.4e+100) and (x_46_im <= 2.4e+126)):
		tmp = x_46_re * (x_46_re * x_46_re)
	else:
		tmp = -3.0 * (x_46_re * (x_46_im * x_46_im))
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= 3.6e-34) || (!(x_46_im <= 4.4e+100) && (x_46_im <= 2.4e+126)))
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	else
		tmp = Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im)));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_im <= 3.6e-34) || (~((x_46_im <= 4.4e+100)) && (x_46_im <= 2.4e+126)))
		tmp = x_46_re * (x_46_re * x_46_re);
	else
		tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, 3.6e-34], And[N[Not[LessEqual[x$46$im, 4.4e+100]], $MachinePrecision], LessEqual[x$46$im, 2.4e+126]]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 3.6 \cdot 10^{-34} \lor \neg \left(x.im \leq 4.4 \cdot 10^{+100}\right) \land x.im \leq 2.4 \cdot 10^{+126}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 3.60000000000000008e-34 or 4.4000000000000001e100 < x.im < 2.40000000000000012e126

    1. Initial program 85.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--90.6%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg90.6%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef93.8%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-193.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-293.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*93.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--93.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*93.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval93.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified93.7%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around inf 65.9%

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    5. Step-by-step derivation
      1. unpow265.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified65.9%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]

    if 3.60000000000000008e-34 < x.im < 4.4000000000000001e100 or 2.40000000000000012e126 < x.im

    1. Initial program 76.8%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative76.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out76.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*76.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative76.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--82.7%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-82.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-82.7%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg82.7%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+82.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef87.1%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-187.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-287.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*87.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--87.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*87.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval87.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified87.1%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef82.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    5. Applied egg-rr82.7%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    6. Taylor expanded in x.re around 0 69.5%

      \[\leadsto \color{blue}{-3 \cdot \left(x.re \cdot {x.im}^{2}\right)} \]
    7. Step-by-step derivation
      1. unpow269.5%

        \[\leadsto -3 \cdot \left(x.re \cdot \color{blue}{\left(x.im \cdot x.im\right)}\right) \]
    8. Simplified69.5%

      \[\leadsto \color{blue}{-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 3.6 \cdot 10^{-34} \lor \neg \left(x.im \leq 4.4 \cdot 10^{+100}\right) \land x.im \leq 2.4 \cdot 10^{+126}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\ \end{array} \]

Alternative 3: 80.9% accurate, 1.4× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq 9 \cdot 10^{-34} \lor \neg \left(x.im \leq 4.4 \cdot 10^{+100}\right) \land x.im \leq 1.3 \cdot 10^{+126}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im 9e-34) (and (not (<= x.im 4.4e+100)) (<= x.im 1.3e+126)))
   (* x.re (* x.re x.re))
   (* x.im (* x.im (* x.re -3.0)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= 9e-34) || (!(x_46_im <= 4.4e+100) && (x_46_im <= 1.3e+126))) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46im <= 9d-34) .or. (.not. (x_46im <= 4.4d+100)) .and. (x_46im <= 1.3d+126)) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = x_46im * (x_46im * (x_46re * (-3.0d0)))
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= 9e-34) || (!(x_46_im <= 4.4e+100) && (x_46_im <= 1.3e+126))) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= 9e-34) or (not (x_46_im <= 4.4e+100) and (x_46_im <= 1.3e+126)):
		tmp = x_46_re * (x_46_re * x_46_re)
	else:
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0))
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= 9e-34) || (!(x_46_im <= 4.4e+100) && (x_46_im <= 1.3e+126)))
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	else
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0)));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_im <= 9e-34) || (~((x_46_im <= 4.4e+100)) && (x_46_im <= 1.3e+126)))
		tmp = x_46_re * (x_46_re * x_46_re);
	else
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, 9e-34], And[N[Not[LessEqual[x$46$im, 4.4e+100]], $MachinePrecision], LessEqual[x$46$im, 1.3e+126]]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 9 \cdot 10^{-34} \lor \neg \left(x.im \leq 4.4 \cdot 10^{+100}\right) \land x.im \leq 1.3 \cdot 10^{+126}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 9.00000000000000085e-34 or 4.4000000000000001e100 < x.im < 1.3e126

    1. Initial program 85.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--90.6%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg90.6%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef93.8%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-193.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-293.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*93.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--93.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*93.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval93.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified93.7%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around inf 65.9%

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    5. Step-by-step derivation
      1. unpow265.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified65.9%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]

    if 9.00000000000000085e-34 < x.im < 4.4000000000000001e100 or 1.3e126 < x.im

    1. Initial program 76.8%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative76.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out76.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*76.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative76.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--82.7%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-82.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-82.7%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg82.7%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+82.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef87.1%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-187.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-287.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*87.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--87.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*87.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval87.1%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified87.1%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around 0 69.5%

      \[\leadsto \color{blue}{-3 \cdot \left(x.re \cdot {x.im}^{2}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*69.6%

        \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot {x.im}^{2}} \]
      2. unpow269.6%

        \[\leadsto \left(-3 \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot x.im\right)} \]
    6. Simplified69.6%

      \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt26.7%

        \[\leadsto \color{blue}{\sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)} \cdot \sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)}} \]
      2. pow226.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)}\right)}^{2}} \]
      3. *-commutative26.7%

        \[\leadsto {\left(\sqrt{\color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-3 \cdot x.re\right)}}\right)}^{2} \]
      4. sqrt-prod26.7%

        \[\leadsto {\color{blue}{\left(\sqrt{x.im \cdot x.im} \cdot \sqrt{-3 \cdot x.re}\right)}}^{2} \]
      5. sqrt-prod32.1%

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-3 \cdot x.re}\right)}^{2} \]
      6. add-sqr-sqrt32.2%

        \[\leadsto {\left(\color{blue}{x.im} \cdot \sqrt{-3 \cdot x.re}\right)}^{2} \]
      7. *-commutative32.2%

        \[\leadsto {\left(x.im \cdot \sqrt{\color{blue}{x.re \cdot -3}}\right)}^{2} \]
    8. Applied egg-rr32.2%

      \[\leadsto \color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2}} \]
    9. Step-by-step derivation
      1. add-cbrt-cube26.7%

        \[\leadsto {\color{blue}{\left(\sqrt[3]{\left(\left(x.im \cdot \sqrt{x.re \cdot -3}\right) \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)\right) \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)}\right)}}^{2} \]
      2. unpow226.7%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2}} \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)}\right)}^{2} \]
      3. pow126.7%

        \[\leadsto {\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2} \cdot \color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{1}}}\right)}^{2} \]
      4. pow-prod-up26.8%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{\left(2 + 1\right)}}}\right)}^{2} \]
      5. metadata-eval26.8%

        \[\leadsto {\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{\color{blue}{3}}}\right)}^{2} \]
    10. Applied egg-rr26.8%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{3}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. rem-cbrt-cube32.2%

        \[\leadsto {\color{blue}{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}}^{2} \]
      2. unpow-prod-down26.6%

        \[\leadsto \color{blue}{{x.im}^{2} \cdot {\left(\sqrt{x.re \cdot -3}\right)}^{2}} \]
      3. pow226.6%

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot {\left(\sqrt{x.re \cdot -3}\right)}^{2} \]
      4. pow226.6%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(\sqrt{x.re \cdot -3} \cdot \sqrt{x.re \cdot -3}\right)} \]
      5. add-sqr-sqrt69.6%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(x.re \cdot -3\right)} \]
      6. *-commutative69.6%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-3 \cdot x.re\right)} \]
      7. associate-*l*80.7%

        \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-3 \cdot x.re\right)\right)} \]
    12. Applied egg-rr80.7%

      \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-3 \cdot x.re\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 9 \cdot 10^{-34} \lor \neg \left(x.im \leq 4.4 \cdot 10^{+100}\right) \land x.im \leq 1.3 \cdot 10^{+126}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \]

Alternative 4: 80.9% accurate, 1.4× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{if}\;x.im \leq 7.6 \cdot 10^{-34}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq 4.4 \cdot 10^{+100}:\\ \;\;\;\;x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\\ \mathbf{elif}\;x.im \leq 1.3 \cdot 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.re (* x.re x.re))))
   (if (<= x.im 7.6e-34)
     t_0
     (if (<= x.im 4.4e+100)
       (* x.re (* -3.0 (* x.im x.im)))
       (if (<= x.im 1.3e+126) t_0 (* x.im (* x.im (* x.re -3.0))))))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (x_46_re * x_46_re);
	double tmp;
	if (x_46_im <= 7.6e-34) {
		tmp = t_0;
	} else if (x_46_im <= 4.4e+100) {
		tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
	} else if (x_46_im <= 1.3e+126) {
		tmp = t_0;
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x_46re * (x_46re * x_46re)
    if (x_46im <= 7.6d-34) then
        tmp = t_0
    else if (x_46im <= 4.4d+100) then
        tmp = x_46re * ((-3.0d0) * (x_46im * x_46im))
    else if (x_46im <= 1.3d+126) then
        tmp = t_0
    else
        tmp = x_46im * (x_46im * (x_46re * (-3.0d0)))
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (x_46_re * x_46_re);
	double tmp;
	if (x_46_im <= 7.6e-34) {
		tmp = t_0;
	} else if (x_46_im <= 4.4e+100) {
		tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
	} else if (x_46_im <= 1.3e+126) {
		tmp = t_0;
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	t_0 = x_46_re * (x_46_re * x_46_re)
	tmp = 0
	if x_46_im <= 7.6e-34:
		tmp = t_0
	elif x_46_im <= 4.4e+100:
		tmp = x_46_re * (-3.0 * (x_46_im * x_46_im))
	elif x_46_im <= 1.3e+126:
		tmp = t_0
	else:
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0))
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_re * Float64(x_46_re * x_46_re))
	tmp = 0.0
	if (x_46_im <= 7.6e-34)
		tmp = t_0;
	elseif (x_46_im <= 4.4e+100)
		tmp = Float64(x_46_re * Float64(-3.0 * Float64(x_46_im * x_46_im)));
	elseif (x_46_im <= 1.3e+126)
		tmp = t_0;
	else
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0)));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_re * (x_46_re * x_46_re);
	tmp = 0.0;
	if (x_46_im <= 7.6e-34)
		tmp = t_0;
	elseif (x_46_im <= 4.4e+100)
		tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
	elseif (x_46_im <= 1.3e+126)
		tmp = t_0;
	else
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, 7.6e-34], t$95$0, If[LessEqual[x$46$im, 4.4e+100], N[(x$46$re * N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1.3e+126], t$95$0, N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{if}\;x.im \leq 7.6 \cdot 10^{-34}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x.im \leq 4.4 \cdot 10^{+100}:\\
\;\;\;\;x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\\

\mathbf{elif}\;x.im \leq 1.3 \cdot 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < 7.6000000000000002e-34 or 4.4000000000000001e100 < x.im < 1.3e126

    1. Initial program 85.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative85.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--90.6%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg90.6%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+90.6%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef93.8%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-193.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-293.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*93.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--93.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*93.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval93.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified93.7%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around inf 65.9%

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    5. Step-by-step derivation
      1. unpow265.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified65.9%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]

    if 7.6000000000000002e-34 < x.im < 4.4000000000000001e100

    1. Initial program 90.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative90.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out90.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*90.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative90.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--99.5%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-99.5%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-99.5%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg99.5%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+99.5%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef99.5%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-199.5%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-299.5%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*99.5%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--99.5%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*99.6%

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

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around 0 65.4%

      \[\leadsto \color{blue}{-3 \cdot \left(x.re \cdot {x.im}^{2}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*65.5%

        \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot {x.im}^{2}} \]
      2. *-commutative65.5%

        \[\leadsto \color{blue}{\left(x.re \cdot -3\right)} \cdot {x.im}^{2} \]
      3. metadata-eval65.5%

        \[\leadsto \left(x.re \cdot \color{blue}{\left(-1 + -2\right)}\right) \cdot {x.im}^{2} \]
      4. distribute-rgt-out65.5%

        \[\leadsto \color{blue}{\left(-1 \cdot x.re + -2 \cdot x.re\right)} \cdot {x.im}^{2} \]
      5. metadata-eval65.5%

        \[\leadsto \left(-1 \cdot x.re + \color{blue}{\left(-2\right)} \cdot x.re\right) \cdot {x.im}^{2} \]
      6. cancel-sign-sub-inv65.5%

        \[\leadsto \color{blue}{\left(-1 \cdot x.re - 2 \cdot x.re\right)} \cdot {x.im}^{2} \]
      7. *-commutative65.5%

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(-1 \cdot x.re - 2 \cdot x.re\right)} \]
      8. cancel-sign-sub-inv65.5%

        \[\leadsto {x.im}^{2} \cdot \color{blue}{\left(-1 \cdot x.re + \left(-2\right) \cdot x.re\right)} \]
      9. metadata-eval65.5%

        \[\leadsto {x.im}^{2} \cdot \left(-1 \cdot x.re + \color{blue}{-2} \cdot x.re\right) \]
      10. +-commutative65.5%

        \[\leadsto {x.im}^{2} \cdot \color{blue}{\left(-2 \cdot x.re + -1 \cdot x.re\right)} \]
      11. distribute-lft-in65.4%

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(-2 \cdot x.re\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)} \]
    6. Simplified65.4%

      \[\leadsto \color{blue}{x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)} \]

    if 1.3e126 < x.im

    1. Initial program 64.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative64.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out64.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*64.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative64.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--67.7%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-67.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-67.7%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg67.7%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+67.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef76.0%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-176.0%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-276.0%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*76.0%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--76.0%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*76.0%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval76.0%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified76.0%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around 0 73.2%

      \[\leadsto \color{blue}{-3 \cdot \left(x.re \cdot {x.im}^{2}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*73.3%

        \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot {x.im}^{2}} \]
      2. unpow273.3%

        \[\leadsto \left(-3 \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot x.im\right)} \]
    6. Simplified73.3%

      \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt28.4%

        \[\leadsto \color{blue}{\sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)} \cdot \sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)}} \]
      2. pow228.4%

        \[\leadsto \color{blue}{{\left(\sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)}\right)}^{2}} \]
      3. *-commutative28.4%

        \[\leadsto {\left(\sqrt{\color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-3 \cdot x.re\right)}}\right)}^{2} \]
      4. sqrt-prod28.4%

        \[\leadsto {\color{blue}{\left(\sqrt{x.im \cdot x.im} \cdot \sqrt{-3 \cdot x.re}\right)}}^{2} \]
      5. sqrt-prod38.7%

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-3 \cdot x.re}\right)}^{2} \]
      6. add-sqr-sqrt38.8%

        \[\leadsto {\left(\color{blue}{x.im} \cdot \sqrt{-3 \cdot x.re}\right)}^{2} \]
      7. *-commutative38.8%

        \[\leadsto {\left(x.im \cdot \sqrt{\color{blue}{x.re \cdot -3}}\right)}^{2} \]
    8. Applied egg-rr38.8%

      \[\leadsto \color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2}} \]
    9. Step-by-step derivation
      1. add-cbrt-cube31.1%

        \[\leadsto {\color{blue}{\left(\sqrt[3]{\left(\left(x.im \cdot \sqrt{x.re \cdot -3}\right) \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)\right) \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)}\right)}}^{2} \]
      2. unpow231.1%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2}} \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)}\right)}^{2} \]
      3. pow131.1%

        \[\leadsto {\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2} \cdot \color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{1}}}\right)}^{2} \]
      4. pow-prod-up31.1%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{\left(2 + 1\right)}}}\right)}^{2} \]
      5. metadata-eval31.1%

        \[\leadsto {\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{\color{blue}{3}}}\right)}^{2} \]
    10. Applied egg-rr31.1%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{3}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. rem-cbrt-cube38.8%

        \[\leadsto {\color{blue}{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}}^{2} \]
      2. unpow-prod-down28.3%

        \[\leadsto \color{blue}{{x.im}^{2} \cdot {\left(\sqrt{x.re \cdot -3}\right)}^{2}} \]
      3. pow228.3%

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot {\left(\sqrt{x.re \cdot -3}\right)}^{2} \]
      4. pow228.3%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(\sqrt{x.re \cdot -3} \cdot \sqrt{x.re \cdot -3}\right)} \]
      5. add-sqr-sqrt73.3%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(x.re \cdot -3\right)} \]
      6. *-commutative73.3%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-3 \cdot x.re\right)} \]
      7. associate-*l*94.3%

        \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-3 \cdot x.re\right)\right)} \]
    12. Applied egg-rr94.3%

      \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-3 \cdot x.re\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 7.6 \cdot 10^{-34}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.im \leq 4.4 \cdot 10^{+100}:\\ \;\;\;\;x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\\ \mathbf{elif}\;x.im \leq 1.3 \cdot 10^{+126}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \]

Alternative 5: 96.4% accurate, 1.5× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq 6.5 \cdot 10^{+153}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.im \cdot -3\right) + x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 6.5e+153)
   (* x.re (+ (* x.im (* x.im -3.0)) (* x.re x.re)))
   (* x.im (* x.im (* x.re -3.0)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 6.5e+153) {
		tmp = x_46_re * ((x_46_im * (x_46_im * -3.0)) + (x_46_re * x_46_re));
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46im <= 6.5d+153) then
        tmp = x_46re * ((x_46im * (x_46im * (-3.0d0))) + (x_46re * x_46re))
    else
        tmp = x_46im * (x_46im * (x_46re * (-3.0d0)))
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 6.5e+153) {
		tmp = x_46_re * ((x_46_im * (x_46_im * -3.0)) + (x_46_re * x_46_re));
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= 6.5e+153:
		tmp = x_46_re * ((x_46_im * (x_46_im * -3.0)) + (x_46_re * x_46_re))
	else:
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0))
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= 6.5e+153)
		tmp = Float64(x_46_re * Float64(Float64(x_46_im * Float64(x_46_im * -3.0)) + Float64(x_46_re * x_46_re)));
	else
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0)));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= 6.5e+153)
		tmp = x_46_re * ((x_46_im * (x_46_im * -3.0)) + (x_46_re * x_46_re));
	else
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 6.5e+153], N[(x$46$re * N[(N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 6.5 \cdot 10^{+153}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(x.im \cdot -3\right) + x.re \cdot x.re\right)\\

\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 6.49999999999999972e153

    1. Initial program 85.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--92.1%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-92.1%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-92.1%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg92.1%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+92.1%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef94.8%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-194.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-294.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*94.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--94.8%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*94.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval94.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified94.7%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef92.1%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    5. Applied egg-rr92.1%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)} \]

    if 6.49999999999999972e153 < x.im

    1. Initial program 60.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative60.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out60.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*60.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative60.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--60.0%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-60.0%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-60.0%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg60.0%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+60.0%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef70.3%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-170.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-270.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*70.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--70.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*70.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval70.3%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified70.3%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around 0 70.3%

      \[\leadsto \color{blue}{-3 \cdot \left(x.re \cdot {x.im}^{2}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*70.3%

        \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot {x.im}^{2}} \]
      2. unpow270.3%

        \[\leadsto \left(-3 \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot x.im\right)} \]
    6. Simplified70.3%

      \[\leadsto \color{blue}{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt21.4%

        \[\leadsto \color{blue}{\sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)} \cdot \sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)}} \]
      2. pow221.4%

        \[\leadsto \color{blue}{{\left(\sqrt{\left(-3 \cdot x.re\right) \cdot \left(x.im \cdot x.im\right)}\right)}^{2}} \]
      3. *-commutative21.4%

        \[\leadsto {\left(\sqrt{\color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-3 \cdot x.re\right)}}\right)}^{2} \]
      4. sqrt-prod21.4%

        \[\leadsto {\color{blue}{\left(\sqrt{x.im \cdot x.im} \cdot \sqrt{-3 \cdot x.re}\right)}}^{2} \]
      5. sqrt-prod34.3%

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-3 \cdot x.re}\right)}^{2} \]
      6. add-sqr-sqrt34.3%

        \[\leadsto {\left(\color{blue}{x.im} \cdot \sqrt{-3 \cdot x.re}\right)}^{2} \]
      7. *-commutative34.3%

        \[\leadsto {\left(x.im \cdot \sqrt{\color{blue}{x.re \cdot -3}}\right)}^{2} \]
    8. Applied egg-rr34.3%

      \[\leadsto \color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2}} \]
    9. Step-by-step derivation
      1. add-cbrt-cube27.9%

        \[\leadsto {\color{blue}{\left(\sqrt[3]{\left(\left(x.im \cdot \sqrt{x.re \cdot -3}\right) \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)\right) \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)}\right)}}^{2} \]
      2. unpow227.9%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2}} \cdot \left(x.im \cdot \sqrt{x.re \cdot -3}\right)}\right)}^{2} \]
      3. pow127.9%

        \[\leadsto {\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{2} \cdot \color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{1}}}\right)}^{2} \]
      4. pow-prod-up27.9%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{\left(2 + 1\right)}}}\right)}^{2} \]
      5. metadata-eval27.9%

        \[\leadsto {\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{\color{blue}{3}}}\right)}^{2} \]
    10. Applied egg-rr27.9%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}^{3}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. rem-cbrt-cube34.3%

        \[\leadsto {\color{blue}{\left(x.im \cdot \sqrt{x.re \cdot -3}\right)}}^{2} \]
      2. unpow-prod-down21.4%

        \[\leadsto \color{blue}{{x.im}^{2} \cdot {\left(\sqrt{x.re \cdot -3}\right)}^{2}} \]
      3. pow221.4%

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot {\left(\sqrt{x.re \cdot -3}\right)}^{2} \]
      4. pow221.4%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(\sqrt{x.re \cdot -3} \cdot \sqrt{x.re \cdot -3}\right)} \]
      5. add-sqr-sqrt70.3%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(x.re \cdot -3\right)} \]
      6. *-commutative70.3%

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-3 \cdot x.re\right)} \]
      7. associate-*l*96.5%

        \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-3 \cdot x.re\right)\right)} \]
    12. Applied egg-rr96.5%

      \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-3 \cdot x.re\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 6.5 \cdot 10^{+153}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.im \cdot -3\right) + x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \]

Alternative 6: 71.0% accurate, 2.4× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq 2.3 \cdot 10^{+126}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 2.3e+126) (* x.re (* x.re x.re)) (* x.re (* x.im (- x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 2.3e+126) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = x_46_re * (x_46_im * -x_46_im);
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46im <= 2.3d+126) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = x_46re * (x_46im * -x_46im)
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 2.3e+126) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = x_46_re * (x_46_im * -x_46_im);
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= 2.3e+126:
		tmp = x_46_re * (x_46_re * x_46_re)
	else:
		tmp = x_46_re * (x_46_im * -x_46_im)
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= 2.3e+126)
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	else
		tmp = Float64(x_46_re * Float64(x_46_im * Float64(-x_46_im)));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= 2.3e+126)
		tmp = x_46_re * (x_46_re * x_46_re);
	else
		tmp = x_46_re * (x_46_im * -x_46_im);
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 2.3e+126], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 2.3 \cdot 10^{+126}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 2.3000000000000001e126

    1. Initial program 86.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative86.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. distribute-lft-out86.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
      3. associate-*l*85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
      4. *-commutative85.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--91.9%

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      6. associate--l-91.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      7. associate--l-91.9%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      8. sub-neg91.9%

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      9. associate--l+91.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
      10. fma-udef94.6%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      11. neg-mul-194.6%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      12. count-294.6%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*94.6%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--94.6%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*94.6%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval94.6%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
    3. Simplified94.6%

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. Taylor expanded in x.re around inf 61.9%

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    5. Step-by-step derivation
      1. unpow261.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified61.9%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]

    if 2.3000000000000001e126 < x.im

    1. Initial program 64.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative64.9%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. fma-neg64.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, -\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\right)} \]
      3. distribute-lft-neg-in64.9%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, \color{blue}{\left(-\left(x.re \cdot x.im + x.im \cdot x.re\right)\right) \cdot x.im}\right) \]
      4. *-commutative64.9%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, \color{blue}{x.im \cdot \left(-\left(x.re \cdot x.im + x.im \cdot x.re\right)\right)}\right) \]
      5. *-commutative64.9%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, x.im \cdot \left(-\left(\color{blue}{x.im \cdot x.re} + x.im \cdot x.re\right)\right)\right) \]
      6. count-264.9%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, x.im \cdot \left(-\color{blue}{2 \cdot \left(x.im \cdot x.re\right)}\right)\right) \]
      7. distribute-lft-neg-in64.9%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, x.im \cdot \color{blue}{\left(\left(-2\right) \cdot \left(x.im \cdot x.re\right)\right)}\right) \]
      8. metadata-eval64.9%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, x.im \cdot \left(\color{blue}{-2} \cdot \left(x.im \cdot x.re\right)\right)\right) \]
      9. *-commutative64.9%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, x.im \cdot \left(-2 \cdot \color{blue}{\left(x.re \cdot x.im\right)}\right)\right) \]
    3. Simplified64.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right)\right)} \]
    4. Taylor expanded in x.re around 0 73.2%

      \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{-1 \cdot {x.im}^{2}}, x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right)\right) \]
    5. Step-by-step derivation
      1. mul-1-neg73.2%

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{-{x.im}^{2}}, x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right)\right) \]
      2. unpow273.2%

        \[\leadsto \mathsf{fma}\left(x.re, -\color{blue}{x.im \cdot x.im}, x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right)\right) \]
      3. distribute-rgt-neg-out73.2%

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{x.im \cdot \left(-x.im\right)}, x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right)\right) \]
    6. Simplified73.2%

      \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{x.im \cdot \left(-x.im\right)}, x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right)\right) \]
    7. Step-by-step derivation
      1. fma-udef73.2%

        \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot \left(-x.im\right)\right) + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right)} \]
      2. add-sqr-sqrt0.0%

        \[\leadsto x.re \cdot \color{blue}{\left(\sqrt{x.im \cdot \left(-x.im\right)} \cdot \sqrt{x.im \cdot \left(-x.im\right)}\right)} + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right) \]
      3. sqrt-unprod0.1%

        \[\leadsto x.re \cdot \color{blue}{\sqrt{\left(x.im \cdot \left(-x.im\right)\right) \cdot \left(x.im \cdot \left(-x.im\right)\right)}} + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right) \]
      4. distribute-rgt-neg-out0.1%

        \[\leadsto x.re \cdot \sqrt{\color{blue}{\left(-x.im \cdot x.im\right)} \cdot \left(x.im \cdot \left(-x.im\right)\right)} + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right) \]
      5. distribute-rgt-neg-out0.1%

        \[\leadsto x.re \cdot \sqrt{\left(-x.im \cdot x.im\right) \cdot \color{blue}{\left(-x.im \cdot x.im\right)}} + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right) \]
      6. sqr-neg0.1%

        \[\leadsto x.re \cdot \sqrt{\color{blue}{\left(x.im \cdot x.im\right) \cdot \left(x.im \cdot x.im\right)}} + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right) \]
      7. sqrt-unprod2.0%

        \[\leadsto x.re \cdot \color{blue}{\left(\sqrt{x.im \cdot x.im} \cdot \sqrt{x.im \cdot x.im}\right)} + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right) \]
      8. add-sqr-sqrt2.0%

        \[\leadsto x.re \cdot \color{blue}{\left(x.im \cdot x.im\right)} + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right) \]
      9. associate-*r*2.0%

        \[\leadsto x.re \cdot \left(x.im \cdot x.im\right) + \color{blue}{\left(x.im \cdot -2\right) \cdot \left(x.re \cdot x.im\right)} \]
    8. Applied egg-rr2.0%

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot x.im\right) + \left(x.im \cdot -2\right) \cdot \left(x.re \cdot x.im\right)} \]
    9. Step-by-step derivation
      1. associate-*r*5.9%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot x.im} + \left(x.im \cdot -2\right) \cdot \left(x.re \cdot x.im\right) \]
      2. *-commutative5.9%

        \[\leadsto \left(x.re \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -2\right)} \]
      3. distribute-lft-out67.0%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(x.im + x.im \cdot -2\right)} \]
    10. Simplified67.0%

      \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(x.im + x.im \cdot -2\right)} \]
    11. Taylor expanded in x.re around 0 67.0%

      \[\leadsto \color{blue}{\left(-2 \cdot x.im + x.im\right) \cdot \left(x.re \cdot x.im\right)} \]
    12. Step-by-step derivation
      1. distribute-lft1-in67.0%

        \[\leadsto \color{blue}{\left(\left(-2 + 1\right) \cdot x.im\right)} \cdot \left(x.re \cdot x.im\right) \]
      2. metadata-eval67.0%

        \[\leadsto \left(\color{blue}{-1} \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) \]
      3. neg-mul-167.0%

        \[\leadsto \color{blue}{\left(-x.im\right)} \cdot \left(x.re \cdot x.im\right) \]
      4. *-commutative67.0%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(-x.im\right)} \]
      5. associate-*r*64.2%

        \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)} \]
    13. Simplified64.2%

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 2.3 \cdot 10^{+126}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \]

Alternative 7: 58.6% accurate, 3.8× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ x.re \cdot \left(x.re \cdot x.re\right) \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.re)))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_re * x_46_re);
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = x_46re * (x_46re * x_46re)
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_re * x_46_re);
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	return x_46_re * (x_46_re * x_46_re)
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	return Float64(x_46_re * Float64(x_46_re * x_46_re))
end
x.im = abs(x.im)
function tmp = code(x_46_re, x_46_im)
	tmp = x_46_re * (x_46_re * x_46_re);
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im = |x.im|\\
\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 83.0%

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
  2. Step-by-step derivation
    1. *-commutative83.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
    2. distribute-lft-out83.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im \]
    3. associate-*l*83.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)} \]
    4. *-commutative83.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
    5. distribute-rgt-out--88.5%

      \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
    6. associate--l-88.5%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
    7. associate--l-88.5%

      \[\leadsto x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
    8. sub-neg88.5%

      \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
    9. associate--l+88.5%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)} \]
    10. fma-udef92.0%

      \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
    11. neg-mul-192.0%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
    12. count-292.0%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
    13. associate-*l*92.0%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
    14. distribute-rgt-out--92.0%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
    15. associate-*r*92.0%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
    16. metadata-eval92.0%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right) \]
  3. Simplified92.0%

    \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
  4. Taylor expanded in x.re around inf 54.1%

    \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
  5. Step-by-step derivation
    1. unpow254.1%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
  6. Simplified54.1%

    \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
  7. Final simplification54.1%

    \[\leadsto x.re \cdot \left(x.re \cdot x.re\right) \]

Developer target: 87.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right) \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im)))))
double code(double x_46_re, double x_46_im) {
	return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = ((x_46re * x_46re) * (x_46re - x_46im)) + ((x_46re * x_46im) * (x_46re - (3.0d0 * x_46im)))
end function
public static double code(double x_46_re, double x_46_im) {
	return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
}
def code(x_46_re, x_46_im):
	return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)))
function code(x_46_re, x_46_im)
	return Float64(Float64(Float64(x_46_re * x_46_re) * Float64(x_46_re - x_46_im)) + Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re - Float64(3.0 * x_46_im))))
end
function tmp = code(x_46_re, x_46_im)
	tmp = ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
end
code[x$46$re_, x$46$im_] := N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re - N[(3.0 * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)
\end{array}

Reproduce

?
herbie shell --seed 2023200 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im))))

  (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))