math.cube on complex, real part

Percentage Accurate: 83.6% → 94.8%
Time: 6.7s
Alternatives: 12
Speedup: 1.3×

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 12 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: 83.6% 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: 94.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.im \cdot -3\right)\\ \mathbf{if}\;x.re \leq -1.65 \cdot 10^{-108}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, t_0\right)\\ \mathbf{elif}\;x.re \leq 10^{-115}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(x.re, t_0, {x.re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.im (* x.im -3.0))))
   (if (<= x.re -1.65e-108)
     (* x.re (fma x.re x.re t_0))
     (if (<= x.re 1e-115)
       (* (* x.im -3.0) (* x.re x.im))
       (if (<= x.re 6.2e+100) (fma x.re t_0 (pow x.re 3.0)) (pow x.re 3.0))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_im * -3.0);
	double tmp;
	if (x_46_re <= -1.65e-108) {
		tmp = x_46_re * fma(x_46_re, x_46_re, t_0);
	} else if (x_46_re <= 1e-115) {
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	} else if (x_46_re <= 6.2e+100) {
		tmp = fma(x_46_re, t_0, pow(x_46_re, 3.0));
	} else {
		tmp = pow(x_46_re, 3.0);
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_im * Float64(x_46_im * -3.0))
	tmp = 0.0
	if (x_46_re <= -1.65e-108)
		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, t_0));
	elseif (x_46_re <= 1e-115)
		tmp = Float64(Float64(x_46_im * -3.0) * Float64(x_46_re * x_46_im));
	elseif (x_46_re <= 6.2e+100)
		tmp = fma(x_46_re, t_0, (x_46_re ^ 3.0));
	else
		tmp = x_46_re ^ 3.0;
	end
	return tmp
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -1.65e-108], N[(x$46$re * N[(x$46$re * x$46$re + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 1e-115], N[(N[(x$46$im * -3.0), $MachinePrecision] * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 6.2e+100], N[(x$46$re * t$95$0 + N[Power[x$46$re, 3.0], $MachinePrecision]), $MachinePrecision], N[Power[x$46$re, 3.0], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.im \cdot -3\right)\\
\mathbf{if}\;x.re \leq -1.65 \cdot 10^{-108}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, t_0\right)\\

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

\mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\
\;\;\;\;\mathsf{fma}\left(x.re, t_0, {x.re}^{3}\right)\\

\mathbf{else}:\\
\;\;\;\;{x.re}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x.re < -1.6500000000000001e-108

    1. Initial program 80.6%

      \[\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. *-commutative80.6%

        \[\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-out80.6%

        \[\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*80.6%

        \[\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. *-commutative80.6%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

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

    if -1.6500000000000001e-108 < x.re < 1.0000000000000001e-115

    1. Initial program 85.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. *-commutative85.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-out85.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.1%

        \[\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.1%

        \[\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--85.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-85.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-85.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-neg85.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+85.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-udef85.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-185.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-285.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*85.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--85.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*85.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-eval85.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. Simplified85.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 85.1%

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

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

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

      \[\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-sqrt61.6%

        \[\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. pow261.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0000000000000001e-115 < x.re < 6.20000000000000014e100

    1. Initial program 97.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. *-commutative97.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. sub-neg97.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.20000000000000014e100 < x.re

    1. Initial program 53.3%

      \[\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. *-commutative53.3%

        \[\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-out53.3%

        \[\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*53.3%

        \[\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. *-commutative53.3%

        \[\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.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-88.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-88.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-neg88.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+88.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-udef88.9%

        \[\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-188.9%

        \[\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-288.9%

        \[\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*88.9%

        \[\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--88.9%

        \[\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*88.9%

        \[\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-eval88.9%

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

      \[\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 100.0%

      \[\leadsto \color{blue}{{x.re}^{3}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification97.5%

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

Alternative 2: 92.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq 2.9 \cdot 10^{-270}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\ \;\;\;\;{x.re}^{3} + -3 \cdot {\left(x.im \cdot \sqrt{x.re}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re 2.9e-270)
   (* x.re (fma x.re x.re (* x.im (* x.im -3.0))))
   (if (<= x.re 6.2e+100)
     (+ (pow x.re 3.0) (* -3.0 (pow (* x.im (sqrt x.re)) 2.0)))
     (pow x.re 3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= 2.9e-270) {
		tmp = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
	} else if (x_46_re <= 6.2e+100) {
		tmp = pow(x_46_re, 3.0) + (-3.0 * pow((x_46_im * sqrt(x_46_re)), 2.0));
	} else {
		tmp = pow(x_46_re, 3.0);
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= 2.9e-270)
		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0))));
	elseif (x_46_re <= 6.2e+100)
		tmp = Float64((x_46_re ^ 3.0) + Float64(-3.0 * (Float64(x_46_im * sqrt(x_46_re)) ^ 2.0)));
	else
		tmp = x_46_re ^ 3.0;
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 2.9e-270], 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], If[LessEqual[x$46$re, 6.2e+100], N[(N[Power[x$46$re, 3.0], $MachinePrecision] + N[(-3.0 * N[Power[N[(x$46$im * N[Sqrt[x$46$re], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x$46$re, 3.0], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 2.9 \cdot 10^{-270}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;{x.re}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < 2.89999999999999983e-270

    1. Initial program 85.7%

      \[\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.7%

        \[\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.7%

        \[\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.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. *-commutative85.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--90.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.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-193.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-293.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*93.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--93.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*93.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-eval93.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. Simplified93.3%

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

    if 2.89999999999999983e-270 < x.re < 6.20000000000000014e100

    1. Initial program 88.3%

      \[\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. *-commutative88.3%

        \[\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. sub-neg88.3%

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

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

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.re\right) + \left(x.re \cdot \left(-x.im \cdot x.im\right) - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\right)} \]
      5. cube-unmult88.4%

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

        \[\leadsto {x.re}^{3} + \left(x.re \cdot \left(-x.im \cdot x.im\right) - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im\right) \]
      7. distribute-lft-out88.4%

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

        \[\leadsto {x.re}^{3} + \left(x.re \cdot \left(-x.im \cdot x.im\right) - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)}\right) \]
      9. distribute-lft-out--88.5%

        \[\leadsto {x.re}^{3} + \color{blue}{x.re \cdot \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      10. neg-mul-188.5%

        \[\leadsto {x.re}^{3} + x.re \cdot \left(\color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      11. count-288.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.20000000000000014e100 < x.re

    1. Initial program 53.3%

      \[\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. *-commutative53.3%

        \[\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-out53.3%

        \[\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*53.3%

        \[\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. *-commutative53.3%

        \[\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.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-88.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-88.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-neg88.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+88.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-udef88.9%

        \[\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-188.9%

        \[\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-288.9%

        \[\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*88.9%

        \[\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--88.9%

        \[\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*88.9%

        \[\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-eval88.9%

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

      \[\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 100.0%

      \[\leadsto \color{blue}{{x.re}^{3}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq 2.9 \cdot 10^{-270}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\ \;\;\;\;{x.re}^{3} + -3 \cdot {\left(x.im \cdot \sqrt{x.re}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \]

Alternative 3: 94.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -1 \cdot 10^{-109}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{elif}\;x.re \leq 1.52 \cdot 10^{-117}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\ \;\;\;\;{x.re}^{3} + -3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re -1e-109)
   (* x.re (fma x.re x.re (* x.im (* x.im -3.0))))
   (if (<= x.re 1.52e-117)
     (* (* x.im -3.0) (* x.re x.im))
     (if (<= x.re 6.2e+100)
       (+ (pow x.re 3.0) (* -3.0 (* x.re (* x.im x.im))))
       (pow x.re 3.0)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= -1e-109) {
		tmp = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
	} else if (x_46_re <= 1.52e-117) {
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	} else if (x_46_re <= 6.2e+100) {
		tmp = pow(x_46_re, 3.0) + (-3.0 * (x_46_re * (x_46_im * x_46_im)));
	} else {
		tmp = pow(x_46_re, 3.0);
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= -1e-109)
		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0))));
	elseif (x_46_re <= 1.52e-117)
		tmp = Float64(Float64(x_46_im * -3.0) * Float64(x_46_re * x_46_im));
	elseif (x_46_re <= 6.2e+100)
		tmp = Float64((x_46_re ^ 3.0) + Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im))));
	else
		tmp = x_46_re ^ 3.0;
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -1e-109], 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], If[LessEqual[x$46$re, 1.52e-117], N[(N[(x$46$im * -3.0), $MachinePrecision] * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 6.2e+100], N[(N[Power[x$46$re, 3.0], $MachinePrecision] + N[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x$46$re, 3.0], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1 \cdot 10^{-109}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\

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

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

\mathbf{else}:\\
\;\;\;\;{x.re}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x.re < -9.9999999999999999e-110

    1. Initial program 80.6%

      \[\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. *-commutative80.6%

        \[\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-out80.6%

        \[\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*80.6%

        \[\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. *-commutative80.6%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

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

    if -9.9999999999999999e-110 < x.re < 1.52e-117

    1. Initial program 84.5%

      \[\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. *-commutative84.5%

        \[\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-out84.5%

        \[\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*84.5%

        \[\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. *-commutative84.5%

        \[\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--84.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-84.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-84.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-neg84.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+84.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-udef84.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-184.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-284.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*84.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--84.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*84.5%

        \[\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-eval84.5%

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

      \[\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 84.5%

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

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

        \[\leadsto \left(-3 \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot x.im\right)} \]
    6. Simplified84.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-sqrt63.9%

        \[\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. pow263.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.52e-117 < x.re < 6.20000000000000014e100

    1. Initial program 98.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. *-commutative98.0%

        \[\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. sub-neg98.0%

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

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

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.re\right) + \left(x.re \cdot \left(-x.im \cdot x.im\right) - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\right)} \]
      5. cube-unmult98.2%

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

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

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

        \[\leadsto {x.re}^{3} + \left(x.re \cdot \left(-x.im \cdot x.im\right) - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)}\right) \]
      9. distribute-lft-out--98.3%

        \[\leadsto {x.re}^{3} + \color{blue}{x.re \cdot \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)} \]
      10. neg-mul-198.3%

        \[\leadsto {x.re}^{3} + x.re \cdot \left(\color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right) \]
      11. count-298.3%

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

        \[\leadsto {x.re}^{3} + x.re \cdot \left(-1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      13. distribute-rgt-out--98.3%

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

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

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

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

    if 6.20000000000000014e100 < x.re

    1. Initial program 53.3%

      \[\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. *-commutative53.3%

        \[\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-out53.3%

        \[\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*53.3%

        \[\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. *-commutative53.3%

        \[\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.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-88.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-88.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-neg88.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+88.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-udef88.9%

        \[\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-188.9%

        \[\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-288.9%

        \[\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*88.9%

        \[\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--88.9%

        \[\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*88.9%

        \[\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-eval88.9%

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

      \[\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 100.0%

      \[\leadsto \color{blue}{{x.re}^{3}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification97.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -1 \cdot 10^{-109}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{elif}\;x.re \leq 1.52 \cdot 10^{-117}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\ \;\;\;\;{x.re}^{3} + -3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \]

Alternative 4: 94.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.im \cdot -3\right)\\ \mathbf{if}\;x.re \leq -1.65 \cdot 10^{-110}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, t_0\right)\\ \mathbf{elif}\;x.re \leq 1.45 \cdot 10^{-111}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\ \;\;\;\;x.re \cdot \left(t_0 + x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.im (* x.im -3.0))))
   (if (<= x.re -1.65e-110)
     (* x.re (fma x.re x.re t_0))
     (if (<= x.re 1.45e-111)
       (* (* x.im -3.0) (* x.re x.im))
       (if (<= x.re 6.2e+100)
         (* x.re (+ t_0 (* x.re x.re)))
         (pow x.re 3.0))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_im * -3.0);
	double tmp;
	if (x_46_re <= -1.65e-110) {
		tmp = x_46_re * fma(x_46_re, x_46_re, t_0);
	} else if (x_46_re <= 1.45e-111) {
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	} else if (x_46_re <= 6.2e+100) {
		tmp = x_46_re * (t_0 + (x_46_re * x_46_re));
	} else {
		tmp = pow(x_46_re, 3.0);
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_im * Float64(x_46_im * -3.0))
	tmp = 0.0
	if (x_46_re <= -1.65e-110)
		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, t_0));
	elseif (x_46_re <= 1.45e-111)
		tmp = Float64(Float64(x_46_im * -3.0) * Float64(x_46_re * x_46_im));
	elseif (x_46_re <= 6.2e+100)
		tmp = Float64(x_46_re * Float64(t_0 + Float64(x_46_re * x_46_re)));
	else
		tmp = x_46_re ^ 3.0;
	end
	return tmp
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -1.65e-110], N[(x$46$re * N[(x$46$re * x$46$re + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 1.45e-111], N[(N[(x$46$im * -3.0), $MachinePrecision] * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 6.2e+100], N[(x$46$re * N[(t$95$0 + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x$46$re, 3.0], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.im \cdot -3\right)\\
\mathbf{if}\;x.re \leq -1.65 \cdot 10^{-110}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, t_0\right)\\

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

\mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\
\;\;\;\;x.re \cdot \left(t_0 + x.re \cdot x.re\right)\\

\mathbf{else}:\\
\;\;\;\;{x.re}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x.re < -1.65e-110

    1. Initial program 80.6%

      \[\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. *-commutative80.6%

        \[\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-out80.6%

        \[\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*80.6%

        \[\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. *-commutative80.6%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

        \[\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.9%

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

    if -1.65e-110 < x.re < 1.45000000000000001e-111

    1. Initial program 85.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. *-commutative85.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-out85.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.1%

        \[\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.1%

        \[\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--85.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-85.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-85.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-neg85.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+85.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-udef85.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-185.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-285.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*85.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--85.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*85.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-eval85.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. Simplified85.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 85.1%

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

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

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

      \[\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-sqrt61.6%

        \[\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. pow261.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.45000000000000001e-111 < x.re < 6.20000000000000014e100

    1. Initial program 97.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. *-commutative97.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-out97.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*97.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. *-commutative97.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--97.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-97.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-97.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-neg97.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+97.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-udef97.9%

        \[\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-197.9%

        \[\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-297.9%

        \[\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*97.9%

        \[\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--97.9%

        \[\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*97.9%

        \[\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-eval97.9%

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

      \[\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-udef97.9%

        \[\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-rr97.9%

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

    if 6.20000000000000014e100 < x.re

    1. Initial program 53.3%

      \[\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. *-commutative53.3%

        \[\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-out53.3%

        \[\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*53.3%

        \[\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. *-commutative53.3%

        \[\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.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-88.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-88.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-neg88.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+88.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-udef88.9%

        \[\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-188.9%

        \[\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-288.9%

        \[\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*88.9%

        \[\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--88.9%

        \[\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*88.9%

        \[\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-eval88.9%

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

      \[\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 100.0%

      \[\leadsto \color{blue}{{x.re}^{3}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification97.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -1.65 \cdot 10^{-110}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{elif}\;x.re \leq 1.45 \cdot 10^{-111}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.re \leq 6.2 \cdot 10^{+100}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.im \cdot -3\right) + x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \]

Alternative 5: 96.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -7.8 \cdot 10^{+153}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 7.6 \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(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -7.8e+153)
   (* (* x.im -3.0) (* x.re x.im))
   (if (<= x.im 7.6e+153)
     (* x.re (+ (* x.im (* x.im -3.0)) (* x.re x.re)))
     (* x.im (* -3.0 (* x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -7.8e+153) {
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	} else if (x_46_im <= 7.6e+153) {
		tmp = x_46_re * ((x_46_im * (x_46_im * -3.0)) + (x_46_re * x_46_re));
	} else {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
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 <= (-7.8d+153)) then
        tmp = (x_46im * (-3.0d0)) * (x_46re * x_46im)
    else if (x_46im <= 7.6d+153) then
        tmp = x_46re * ((x_46im * (x_46im * (-3.0d0))) + (x_46re * x_46re))
    else
        tmp = x_46im * ((-3.0d0) * (x_46re * x_46im))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -7.8e+153) {
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	} else if (x_46_im <= 7.6e+153) {
		tmp = x_46_re * ((x_46_im * (x_46_im * -3.0)) + (x_46_re * x_46_re));
	} else {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -7.8e+153:
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im)
	elif x_46_im <= 7.6e+153:
		tmp = x_46_re * ((x_46_im * (x_46_im * -3.0)) + (x_46_re * x_46_re))
	else:
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -7.8e+153)
		tmp = Float64(Float64(x_46_im * -3.0) * Float64(x_46_re * x_46_im));
	elseif (x_46_im <= 7.6e+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(-3.0 * Float64(x_46_re * x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= -7.8e+153)
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	elseif (x_46_im <= 7.6e+153)
		tmp = x_46_re * ((x_46_im * (x_46_im * -3.0)) + (x_46_re * x_46_re));
	else
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -7.8e+153], N[(N[(x$46$im * -3.0), $MachinePrecision] * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 7.6e+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[(-3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -7.8 \cdot 10^{+153}:\\
\;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\

\mathbf{elif}\;x.im \leq 7.6 \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(-3 \cdot \left(x.re \cdot x.im\right)\right)\\


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

    1. Initial program 53.7%

      \[\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. *-commutative53.7%

        \[\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-out53.7%

        \[\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*53.7%

        \[\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. *-commutative53.7%

        \[\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--53.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-53.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-53.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-neg53.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+53.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-udef61.7%

        \[\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-161.7%

        \[\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-261.7%

        \[\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*61.7%

        \[\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--61.7%

        \[\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*61.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-eval61.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. Simplified61.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 0 61.7%

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

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

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

      \[\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.1%

        \[\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.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.79999999999999966e153 < x.im < 7.59999999999999933e153

    1. Initial program 88.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. *-commutative88.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-out88.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*88.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. *-commutative88.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--99.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-99.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-99.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-neg99.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+99.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-udef99.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.7%

        \[\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.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-eval99.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. Simplified99.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-udef99.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-rr99.7%

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

    if 7.59999999999999933e153 < x.im

    1. Initial program 49.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. *-commutative49.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-out49.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*49.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. *-commutative49.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--49.8%

        \[\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-49.8%

        \[\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-49.8%

        \[\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-neg49.8%

        \[\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+49.8%

        \[\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-udef53.2%

        \[\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-153.2%

        \[\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-253.2%

        \[\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*53.2%

        \[\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--53.2%

        \[\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*53.2%

        \[\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-eval53.2%

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

      \[\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 53.2%

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

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

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

      \[\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.2%

        \[\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.2%

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

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

        \[\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. unpow234.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -7.8 \cdot 10^{+153}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 7.6 \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(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 6: 74.2% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 1.15 \cdot 10^{+18}\right):\\ \;\;\;\;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} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -5.6e-44) (not (<= x.re 1.15e+18)))
   (* x.re (* x.re x.re))
   (* -3.0 (* x.re (* x.im x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 1.15e+18)) {
		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;
}
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_46re <= (-5.6d-44)) .or. (.not. (x_46re <= 1.15d+18))) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 1.15e+18)) {
		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;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -5.6e-44) or not (x_46_re <= 1.15e+18):
		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
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 1.15e+18))
		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
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= -5.6e-44) || ~((x_46_re <= 1.15e+18)))
		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
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -5.6e-44], N[Not[LessEqual[x$46$re, 1.15e+18]], $MachinePrecision]], 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}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 1.15 \cdot 10^{+18}\right):\\
\;\;\;\;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.re < -5.6e-44 or 1.15e18 < x.re

    1. Initial program 72.5%

      \[\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. *-commutative72.5%

        \[\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-out72.5%

        \[\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*72.5%

        \[\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. *-commutative72.5%

        \[\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--89.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-89.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-89.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-neg89.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+89.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-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 83.0%

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

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

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

    if -5.6e-44 < x.re < 1.15e18

    1. Initial program 89.4%

      \[\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. *-commutative89.4%

        \[\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-out89.4%

        \[\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*89.4%

        \[\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. *-commutative89.4%

        \[\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--89.4%

        \[\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-89.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-89.4%

        \[\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-neg89.4%

        \[\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+89.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-udef89.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-189.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-289.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*89.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--89.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*89.4%

        \[\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-eval89.4%

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

      \[\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-udef89.4%

        \[\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-rr89.4%

      \[\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 75.4%

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

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

      \[\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 simplification79.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 1.15 \cdot 10^{+18}\right):\\ \;\;\;\;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 7: 74.2% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 1.35 \cdot 10^{+19}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -5.6e-44) (not (<= x.re 1.35e+19)))
   (* x.re (* x.re x.re))
   (* x.re (* -3.0 (* x.im x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 1.35e+19)) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
	}
	return tmp;
}
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_46re <= (-5.6d-44)) .or. (.not. (x_46re <= 1.35d+19))) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = x_46re * ((-3.0d0) * (x_46im * x_46im))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 1.35e+19)) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -5.6e-44) or not (x_46_re <= 1.35e+19):
		tmp = x_46_re * (x_46_re * x_46_re)
	else:
		tmp = x_46_re * (-3.0 * (x_46_im * x_46_im))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 1.35e+19))
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	else
		tmp = Float64(x_46_re * Float64(-3.0 * Float64(x_46_im * x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= -5.6e-44) || ~((x_46_re <= 1.35e+19)))
		tmp = x_46_re * (x_46_re * x_46_re);
	else
		tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -5.6e-44], N[Not[LessEqual[x$46$re, 1.35e+19]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 1.35 \cdot 10^{+19}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -5.6e-44 or 1.35e19 < x.re

    1. Initial program 72.5%

      \[\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. *-commutative72.5%

        \[\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-out72.5%

        \[\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*72.5%

        \[\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. *-commutative72.5%

        \[\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--89.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-89.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-89.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-neg89.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+89.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-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 83.0%

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

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

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

    if -5.6e-44 < x.re < 1.35e19

    1. Initial program 89.4%

      \[\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. *-commutative89.4%

        \[\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-out89.4%

        \[\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*89.4%

        \[\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. *-commutative89.4%

        \[\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--89.4%

        \[\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-89.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-89.4%

        \[\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-neg89.4%

        \[\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+89.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-udef89.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-189.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-289.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*89.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--89.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*89.4%

        \[\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-eval89.4%

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

      \[\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 75.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 1.35 \cdot 10^{+19}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\\ \end{array} \]

Alternative 8: 74.2% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 8.8 \cdot 10^{+18}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(x.re \cdot -3\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -5.6e-44) (not (<= x.re 8.8e+18)))
   (* x.re (* x.re x.re))
   (* (* x.im x.im) (* x.re -3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 8.8e+18)) {
		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;
}
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_46re <= (-5.6d-44)) .or. (.not. (x_46re <= 8.8d+18))) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = (x_46im * x_46im) * (x_46re * (-3.0d0))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 8.8e+18)) {
		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;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -5.6e-44) or not (x_46_re <= 8.8e+18):
		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
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 8.8e+18))
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	else
		tmp = Float64(Float64(x_46_im * x_46_im) * Float64(x_46_re * -3.0));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= -5.6e-44) || ~((x_46_re <= 8.8e+18)))
		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
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -5.6e-44], N[Not[LessEqual[x$46$re, 8.8e+18]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * x$46$im), $MachinePrecision] * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 8.8 \cdot 10^{+18}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -5.6e-44 or 8.8e18 < x.re

    1. Initial program 72.5%

      \[\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. *-commutative72.5%

        \[\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-out72.5%

        \[\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*72.5%

        \[\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. *-commutative72.5%

        \[\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--89.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-89.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-89.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-neg89.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+89.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-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 83.0%

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

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

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

    if -5.6e-44 < x.re < 8.8e18

    1. Initial program 89.4%

      \[\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. *-commutative89.4%

        \[\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-out89.4%

        \[\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*89.4%

        \[\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. *-commutative89.4%

        \[\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--89.4%

        \[\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-89.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-89.4%

        \[\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-neg89.4%

        \[\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+89.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-udef89.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-189.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-289.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*89.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--89.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*89.4%

        \[\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-eval89.4%

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

      \[\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 75.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 8.8 \cdot 10^{+18}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(x.re \cdot -3\right)\\ \end{array} \]

Alternative 9: 79.9% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 2.2 \cdot 10^{+17}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -5.6e-44) (not (<= x.re 2.2e+17)))
   (* x.re (* x.re x.re))
   (* x.im (* -3.0 (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 2.2e+17)) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
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_46re <= (-5.6d-44)) .or. (.not. (x_46re <= 2.2d+17))) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = x_46im * ((-3.0d0) * (x_46re * x_46im))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 2.2e+17)) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -5.6e-44) or not (x_46_re <= 2.2e+17):
		tmp = x_46_re * (x_46_re * x_46_re)
	else:
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -5.6e-44) || !(x_46_re <= 2.2e+17))
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	else
		tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_re * x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= -5.6e-44) || ~((x_46_re <= 2.2e+17)))
		tmp = x_46_re * (x_46_re * x_46_re);
	else
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -5.6e-44], N[Not[LessEqual[x$46$re, 2.2e+17]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(-3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 2.2 \cdot 10^{+17}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -5.6e-44 or 2.2e17 < x.re

    1. Initial program 72.5%

      \[\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. *-commutative72.5%

        \[\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-out72.5%

        \[\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*72.5%

        \[\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. *-commutative72.5%

        \[\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--89.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-89.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-89.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-neg89.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+89.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-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 83.0%

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

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

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

    if -5.6e-44 < x.re < 2.2e17

    1. Initial program 89.4%

      \[\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. *-commutative89.4%

        \[\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-out89.4%

        \[\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*89.4%

        \[\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. *-commutative89.4%

        \[\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--89.4%

        \[\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-89.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-89.4%

        \[\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-neg89.4%

        \[\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+89.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-udef89.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-189.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-289.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*89.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--89.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*89.4%

        \[\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-eval89.4%

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

      \[\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 75.4%

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

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

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

      \[\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-sqrt45.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. pow245.7%

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

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

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

        \[\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.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -5.6 \cdot 10^{-44} \lor \neg \left(x.re \leq 2.2 \cdot 10^{+17}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 10: 79.9% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -4.5 \cdot 10^{-44} \lor \neg \left(x.re \leq 4 \cdot 10^{+19}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -4.5e-44) (not (<= x.re 4e+19)))
   (* x.re (* x.re x.re))
   (* (* x.im -3.0) (* x.re x.im))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -4.5e-44) || !(x_46_re <= 4e+19)) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	}
	return tmp;
}
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_46re <= (-4.5d-44)) .or. (.not. (x_46re <= 4d+19))) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = (x_46im * (-3.0d0)) * (x_46re * x_46im)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -4.5e-44) || !(x_46_re <= 4e+19)) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -4.5e-44) or not (x_46_re <= 4e+19):
		tmp = x_46_re * (x_46_re * x_46_re)
	else:
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -4.5e-44) || !(x_46_re <= 4e+19))
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	else
		tmp = Float64(Float64(x_46_im * -3.0) * Float64(x_46_re * x_46_im));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= -4.5e-44) || ~((x_46_re <= 4e+19)))
		tmp = x_46_re * (x_46_re * x_46_re);
	else
		tmp = (x_46_im * -3.0) * (x_46_re * x_46_im);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -4.5e-44], N[Not[LessEqual[x$46$re, 4e+19]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * -3.0), $MachinePrecision] * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -4.5 \cdot 10^{-44} \lor \neg \left(x.re \leq 4 \cdot 10^{+19}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -4.4999999999999999e-44 or 4e19 < x.re

    1. Initial program 72.5%

      \[\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. *-commutative72.5%

        \[\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-out72.5%

        \[\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*72.5%

        \[\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. *-commutative72.5%

        \[\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--89.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-89.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-89.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-neg89.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+89.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-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 83.0%

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

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

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

    if -4.4999999999999999e-44 < x.re < 4e19

    1. Initial program 89.4%

      \[\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. *-commutative89.4%

        \[\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-out89.4%

        \[\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*89.4%

        \[\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. *-commutative89.4%

        \[\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--89.4%

        \[\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-89.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-89.4%

        \[\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-neg89.4%

        \[\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+89.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-udef89.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-189.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-289.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*89.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--89.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*89.4%

        \[\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-eval89.4%

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

      \[\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 75.4%

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

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

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

      \[\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-sqrt45.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. pow245.7%

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

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

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

        \[\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.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -4.5 \cdot 10^{-44} \lor \neg \left(x.re \leq 4 \cdot 10^{+19}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \end{array} \]

Alternative 11: 71.5% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -7.6 \cdot 10^{+138} \lor \neg \left(x.im \leq 3 \cdot 10^{+178}\right):\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -7.6e+138) (not (<= x.im 3e+178)))
   (* x.re (* x.im (- x.im)))
   (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -7.6e+138) || !(x_46_im <= 3e+178)) {
		tmp = x_46_re * (x_46_im * -x_46_im);
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
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 <= (-7.6d+138)) .or. (.not. (x_46im <= 3d+178))) then
        tmp = x_46re * (x_46im * -x_46im)
    else
        tmp = x_46re * (x_46re * x_46re)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -7.6e+138) || !(x_46_im <= 3e+178)) {
		tmp = x_46_re * (x_46_im * -x_46_im);
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -7.6e+138) or not (x_46_im <= 3e+178):
		tmp = x_46_re * (x_46_im * -x_46_im)
	else:
		tmp = x_46_re * (x_46_re * x_46_re)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= -7.6e+138) || !(x_46_im <= 3e+178))
		tmp = Float64(x_46_re * Float64(x_46_im * Float64(-x_46_im)));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_im <= -7.6e+138) || ~((x_46_im <= 3e+178)))
		tmp = x_46_re * (x_46_im * -x_46_im);
	else
		tmp = x_46_re * (x_46_re * x_46_re);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -7.6e+138], N[Not[LessEqual[x$46$im, 3e+178]], $MachinePrecision]], N[(x$46$re * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -7.6 \cdot 10^{+138} \lor \neg \left(x.im \leq 3 \cdot 10^{+178}\right):\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -7.60000000000000025e138 or 3.00000000000000016e178 < x.im

    1. Initial program 60.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. *-commutative60.2%

        \[\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-neg60.3%

        \[\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-in60.3%

        \[\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. *-commutative60.3%

        \[\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. *-commutative60.3%

        \[\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-260.3%

        \[\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-in60.3%

        \[\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-eval60.3%

        \[\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. *-commutative60.3%

        \[\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. Simplified60.3%

      \[\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 66.1%

      \[\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. neg-mul-166.1%

        \[\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. unpow266.1%

        \[\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-in66.1%

        \[\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. Simplified66.1%

      \[\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-udef66.1%

        \[\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. swap-sqr0.1%

        \[\leadsto x.re \cdot \sqrt{\color{blue}{\left(x.im \cdot x.im\right) \cdot \left(\left(-x.im\right) \cdot \left(-x.im\right)\right)}} + x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right) \]
      5. sqr-neg0.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. sqrt-unprod1.1%

        \[\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) \]
      7. add-sqr-sqrt1.1%

        \[\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) \]
      8. associate-*r*1.1%

        \[\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-rr1.1%

      \[\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.2%

        \[\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.2%

        \[\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-out64.0%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(x.im + x.im \cdot -2\right)} \]
    10. Simplified64.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 64.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. *-commutative64.0%

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

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

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

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

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

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

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

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

    if -7.60000000000000025e138 < x.im < 3.00000000000000016e178

    1. Initial program 86.1%

      \[\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.1%

        \[\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.1%

        \[\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*86.1%

        \[\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. *-commutative86.1%

        \[\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--96.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-96.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-96.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-neg96.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+96.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-udef96.9%

        \[\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-196.9%

        \[\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-296.9%

        \[\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*96.9%

        \[\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--96.9%

        \[\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*96.8%

        \[\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-eval96.8%

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

      \[\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 74.6%

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

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

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

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

Alternative 12: 59.0% accurate, 3.8× speedup?

\[\begin{array}{l} \\ x.re \cdot \left(x.re \cdot x.re\right) \end{array} \]
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.re)))
double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_re * x_46_re);
}
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
public static double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_re * x_46_re);
}
def code(x_46_re, x_46_im):
	return x_46_re * (x_46_re * x_46_re)
function code(x_46_re, x_46_im)
	return Float64(x_46_re * Float64(x_46_re * x_46_re))
end
function tmp = code(x_46_re, x_46_im)
	tmp = x_46_re * (x_46_re * x_46_re);
end
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 80.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. *-commutative80.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-out80.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*80.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. *-commutative80.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--89.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-89.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-89.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-neg89.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+89.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-udef90.7%

      \[\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-190.7%

      \[\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-290.7%

      \[\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*90.7%

      \[\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--90.7%

      \[\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*90.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-eval90.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. Simplified90.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 62.3%

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

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

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

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

Developer target: 87.9% 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 2023189 
(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)))