math.cube on complex, real part

Percentage Accurate: 81.7% → 96.1%
Time: 8.0s
Alternatives: 9
Speedup: 0.9×

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 9 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: 81.7% accurate, 1.0× speedup?

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

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

Alternative 1: 96.1% accurate, 0.2× speedup?

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

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


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

    1. Initial program 86.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. Simplified85.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3, {x.re}^{3}\right) \]
      10. associate-*r*90.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.20000000000000001e147 < x.im

    1. Initial program 53.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. Simplified51.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.5% accurate, 0.8× speedup?

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

\mathbf{elif}\;x.re \leq -1.45 \cdot 10^{-98}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x.re \leq 2 \cdot 10^{+100}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -2.55000000000000014e120 or 2.00000000000000003e100 < x.re

    1. Initial program 60.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. Simplified56.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3, {x.re}^{3}\right) \]
      10. associate-*r*71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.55000000000000014e120 < x.re < -1.45e-98 or 2.1000000000000001e-75 < x.re < 2.00000000000000003e100

    1. Initial program 95.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. Taylor expanded in x.re around inf 87.0%

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

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

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

    if -1.45e-98 < x.re < 2.1000000000000001e-75

    1. Initial program 84.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. Simplified84.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.55 \cdot 10^{+120}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq -1.45 \cdot 10^{-98}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq 2.1 \cdot 10^{-75}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \mathbf{elif}\;x.re \leq 2 \cdot 10^{+100}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \]

Alternative 3: 86.5% accurate, 0.8× speedup?

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

\mathbf{elif}\;x.re \leq -2.6 \cdot 10^{-101}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;x.re \leq 2 \cdot 10^{+100}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -2.55000000000000014e120 or 2.00000000000000003e100 < x.re

    1. Initial program 60.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. Simplified56.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3, {x.re}^{3}\right) \]
      10. associate-*r*71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.55000000000000014e120 < x.re < -2.6000000000000001e-101 or 6.2000000000000003e-74 < x.re < 2.00000000000000003e100

    1. Initial program 95.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. Taylor expanded in x.re around inf 87.0%

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

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

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

    if -2.6000000000000001e-101 < x.re < 6.2000000000000003e-74

    1. Initial program 84.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. Taylor expanded in x.re around 0 83.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.55 \cdot 10^{+120}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq -2.6 \cdot 10^{-101}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq 6.2 \cdot 10^{-74}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.re\right)\right) - x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq 2 \cdot 10^{+100}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \]

Alternative 4: 90.0% accurate, 0.9× speedup?

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

\mathbf{elif}\;x.im \leq 4.7 \cdot 10^{+142}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

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


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

    1. Initial program 87.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 \]

    if 2.3499999999999999e126 < x.im < 4.7e142

    1. Initial program 0.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. Simplified0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3, {x.re}^{3}\right) \]
      10. associate-*r*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.7e142 < x.im

    1. Initial program 53.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. Simplified51.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 73.6% accurate, 1.7× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \leq -2.6 \cdot 10^{+18} \lor \neg \left(x.re \leq 6.8 \cdot 10^{-69}\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} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -2.6e+18) (not (<= x.re 6.8e-69)))
   (* x.re (* x.re x.re))
   (* -3.0 (* x.re (* x.im x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -2.6e+18) || !(x_46_re <= 6.8e-69)) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46re <= (-2.6d+18)) .or. (.not. (x_46re <= 6.8d-69))) then
        tmp = x_46re * (x_46re * x_46re)
    else
        tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -2.6e+18) || !(x_46_re <= 6.8e-69)) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else {
		tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -2.6e+18) or not (x_46_re <= 6.8e-69):
		tmp = x_46_re * (x_46_re * x_46_re)
	else:
		tmp = -3.0 * (x_46_re * (x_46_im * x_46_im))
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -2.6e+18) || !(x_46_re <= 6.8e-69))
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	else
		tmp = Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im)));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= -2.6e+18) || ~((x_46_re <= 6.8e-69)))
		tmp = x_46_re * (x_46_re * x_46_re);
	else
		tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -2.6e+18], N[Not[LessEqual[x$46$re, 6.8e-69]], $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}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -2.6 \cdot 10^{+18} \lor \neg \left(x.re \leq 6.8 \cdot 10^{-69}\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 < -2.6e18 or 6.80000000000000016e-69 < x.re

    1. Initial program 77.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. Simplified74.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3, {x.re}^{3}\right) \]
      10. associate-*r*83.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.6e18 < x.re < 6.80000000000000016e-69

    1. Initial program 86.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. Simplified86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.6 \cdot 10^{+18} \lor \neg \left(x.re \leq 6.8 \cdot 10^{-69}\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 6: 79.4% accurate, 1.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -7e14 or 5.10000000000000026e-49 < x.re

    1. Initial program 77.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. Simplified75.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3, {x.re}^{3}\right) \]
      10. associate-*r*83.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7e14 < x.re < 5.10000000000000026e-49

    1. Initial program 86.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Simplified85.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 58.4% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3, {x.re}^{3}\right) \]
    10. associate-*r*84.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
  9. Final simplification57.8%

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

Alternative 8: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ -38 \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 -38.0)
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	return -38.0;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = -38.0d0
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	return -38.0;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	return -38.0
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	return -38.0
end
x.im = abs(x.im)
function tmp = code(x_46_re, x_46_im)
	tmp = -38.0;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := -38.0
\begin{array}{l}
x.im = |x.im|\\
\\
-38
\end{array}
Derivation
  1. Initial program 81.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. Simplified80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-38} \]
  7. Final simplification2.6%

    \[\leadsto -38 \]

Alternative 9: 15.0% accurate, 19.0× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ 0 \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 0.0)
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	return 0.0;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = 0.0d0
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	return 0.0;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	return 0.0
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	return 0.0
end
x.im = abs(x.im)
function tmp = code(x_46_re, x_46_im)
	tmp = 0.0;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := 0.0
\begin{array}{l}
x.im = |x.im|\\
\\
0
\end{array}
Derivation
  1. Initial program 81.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. Simplified80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  7. Final simplification13.5%

    \[\leadsto 0 \]

Developer target: 86.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 2023297 
(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)))