math.cube on complex, real part

Percentage Accurate: 83.0% → 99.1%
Time: 6.0s
Alternatives: 9
Speedup: 0.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 83.0% 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: 99.1% accurate, 0.2× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} t_0 := \frac{x.re}{-x.re}\\ \mathbf{if}\;x.re \leq -5 \cdot 10^{+102}:\\ \;\;\;\;x.re \cdot \left(\left(x.re + -27\right) \cdot \left(x.re + x.im\right)\right) + t_0\\ \mathbf{elif}\;x.re \leq 6300:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right) + {x.re}^{3}\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) + 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))))
   (if (<= x.re -5e+102)
     (+ (* x.re (* (+ x.re -27.0) (+ x.re x.im))) t_0)
     (if (<= x.re 6300.0)
       (+ (* (* x.re x.im) (* x.im -3.0)) (pow x.re 3.0))
       (+ (* x.re (* (- x.re x.im) (+ x.re x.im))) 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;
	double tmp;
	if (x_46_re <= -5e+102) {
		tmp = (x_46_re * ((x_46_re + -27.0) * (x_46_re + x_46_im))) + t_0;
	} else if (x_46_re <= 6300.0) {
		tmp = ((x_46_re * x_46_im) * (x_46_im * -3.0)) + pow(x_46_re, 3.0);
	} else {
		tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) + 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) :: tmp
    t_0 = x_46re / -x_46re
    if (x_46re <= (-5d+102)) then
        tmp = (x_46re * ((x_46re + (-27.0d0)) * (x_46re + x_46im))) + t_0
    else if (x_46re <= 6300.0d0) then
        tmp = ((x_46re * x_46im) * (x_46im * (-3.0d0))) + (x_46re ** 3.0d0)
    else
        tmp = (x_46re * ((x_46re - x_46im) * (x_46re + x_46im))) + 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;
	double tmp;
	if (x_46_re <= -5e+102) {
		tmp = (x_46_re * ((x_46_re + -27.0) * (x_46_re + x_46_im))) + t_0;
	} else if (x_46_re <= 6300.0) {
		tmp = ((x_46_re * x_46_im) * (x_46_im * -3.0)) + Math.pow(x_46_re, 3.0);
	} else {
		tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) + 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
	tmp = 0
	if x_46_re <= -5e+102:
		tmp = (x_46_re * ((x_46_re + -27.0) * (x_46_re + x_46_im))) + t_0
	elif x_46_re <= 6300.0:
		tmp = ((x_46_re * x_46_im) * (x_46_im * -3.0)) + math.pow(x_46_re, 3.0)
	else:
		tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) + 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))
	tmp = 0.0
	if (x_46_re <= -5e+102)
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re + -27.0) * Float64(x_46_re + x_46_im))) + t_0);
	elseif (x_46_re <= 6300.0)
		tmp = Float64(Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0)) + (x_46_re ^ 3.0));
	else
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im))) + 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;
	tmp = 0.0;
	if (x_46_re <= -5e+102)
		tmp = (x_46_re * ((x_46_re + -27.0) * (x_46_re + x_46_im))) + t_0;
	elseif (x_46_re <= 6300.0)
		tmp = ((x_46_re * x_46_im) * (x_46_im * -3.0)) + (x_46_re ^ 3.0);
	else
		tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) + 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 / (-x$46$re)), $MachinePrecision]}, If[LessEqual[x$46$re, -5e+102], N[(N[(x$46$re * N[(N[(x$46$re + -27.0), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[x$46$re, 6300.0], N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision] + N[Power[x$46$re, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := \frac{x.re}{-x.re}\\
\mathbf{if}\;x.re \leq -5 \cdot 10^{+102}:\\
\;\;\;\;x.re \cdot \left(\left(x.re + -27\right) \cdot \left(x.re + x.im\right)\right) + t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -5e102

    1. Initial program 75.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. *-commutative75.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares100.0%

        \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    6. Applied egg-rr100.0%

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

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

    if -5e102 < x.re < 6300

    1. Initial program 88.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. Simplified88.2%

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

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

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

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

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

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

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

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

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

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

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

    if 6300 < x.re

    1. Initial program 79.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. *-commutative79.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares100.0%

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

        \[\leadsto \color{blue}{\left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    6. Applied egg-rr100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -5 \cdot 10^{+102}:\\ \;\;\;\;x.re \cdot \left(\left(x.re + -27\right) \cdot \left(x.re + x.im\right)\right) + \frac{x.re}{-x.re}\\ \mathbf{elif}\;x.re \leq 6300:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right) + {x.re}^{3}\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) + \frac{x.re}{-x.re}\\ \end{array} \]

Alternative 2: 94.0% accurate, 0.5× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} t_0 := x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\ \mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq 2 \cdot 10^{+281}:\\ \;\;\;\;t_0 - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 + \frac{x.re}{-x.re}\\ \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.im) (+ x.re x.im)))))
   (if (<=
        (-
         (* x.re (- (* x.re x.re) (* x.im x.im)))
         (* x.im (+ (* x.re x.im) (* x.re x.im))))
        2e+281)
     (- t_0 (* x.im (* (* x.re x.im) 2.0)))
     (+ t_0 (/ x.re (- x.re))))))
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_im) * (x_46_re + x_46_im));
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 2e+281) {
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0));
	} else {
		tmp = t_0 + (x_46_re / -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) :: t_0
    real(8) :: tmp
    t_0 = x_46re * ((x_46re - x_46im) * (x_46re + x_46im))
    if (((x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))) <= 2d+281) then
        tmp = t_0 - (x_46im * ((x_46re * x_46im) * 2.0d0))
    else
        tmp = t_0 + (x_46re / -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 t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 2e+281) {
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0));
	} else {
		tmp = t_0 + (x_46_re / -x_46_re);
	}
	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_im) * (x_46_re + x_46_im))
	tmp = 0
	if ((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 2e+281:
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0))
	else:
		tmp = t_0 + (x_46_re / -x_46_re)
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_re * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im)))
	tmp = 0.0
	if (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_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= 2e+281)
		tmp = Float64(t_0 - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * 2.0)));
	else
		tmp = Float64(t_0 + Float64(x_46_re / Float64(-x_46_re)));
	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_im) * (x_46_re + x_46_im));
	tmp = 0.0;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 2e+281)
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0));
	else
		tmp = t_0 + (x_46_re / -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_] := Block[{t$95$0 = N[(x$46$re * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+281], N[(t$95$0 - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(x$46$re / (-x$46$re)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\
\mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq 2 \cdot 10^{+281}:\\
\;\;\;\;t_0 - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 + \frac{x.re}{-x.re}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) < 2.0000000000000001e281

    1. Initial program 92.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. difference-of-squares33.1%

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

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

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

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

    if 2.0000000000000001e281 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im))

    1. Initial program 67.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. *-commutative67.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares92.5%

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

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

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

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

Alternative 3: 54.2% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -1.75e-41 or 9.00000000000000023e-59 < x.re

    1. Initial program 83.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. *-commutative83.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares86.4%

        \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    6. Applied egg-rr86.4%

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

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

    if -1.75e-41 < x.re < 9.00000000000000023e-59

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares14.7%

        \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    6. Applied egg-rr14.7%

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

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

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} - \frac{-x.re}{-x.re} \]
    9. Taylor expanded in x.im around inf 33.1%

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
    10. Step-by-step derivation
      1. *-commutative33.1%

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot -27} \]
      2. associate-*l*33.1%

        \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot -27\right)} \]
    11. Simplified33.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -1.75 \cdot 10^{-41} \lor \neg \left(x.re \leq 9 \cdot 10^{-59}\right):\\ \;\;\;\;x.re \cdot \left(\left(x.re + -27\right) \cdot \left(x.re + x.im\right)\right) + \frac{x.re}{-x.re}\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot -27\right)\\ \end{array} \]

Alternative 4: 65.1% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -2.09999999999999993e-114 or 2.4499999999999999e-107 < x.re

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares79.0%

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

        \[\leadsto \color{blue}{\left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    6. Applied egg-rr79.0%

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

    if -2.09999999999999993e-114 < x.re < 2.4499999999999999e-107

    1. Initial program 82.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. *-commutative82.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares7.6%

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

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

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

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} - \frac{-x.re}{-x.re} \]
    9. Taylor expanded in x.im around inf 41.2%

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
    10. Step-by-step derivation
      1. *-commutative41.2%

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot -27} \]
      2. associate-*l*41.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.1 \cdot 10^{-114} \lor \neg \left(x.re \leq 2.45 \cdot 10^{-107}\right):\\ \;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) + \frac{x.re}{-x.re}\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot -27\right)\\ \end{array} \]

Alternative 5: 47.9% accurate, 1.2× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -3.7e-16 or 1.06000000000000004e69 < x.re

    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 - \color{blue}{x.im \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} \]
      2. flip3-+35.7%

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \frac{x.im \cdot \left(2 \cdot {\left(x.re \cdot x.im\right)}^{3}\right)}{{\left(x.re \cdot x.im\right)}^{2} + \color{blue}{0}} \]
    3. Applied egg-rr35.7%

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares94.8%

        \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    6. Applied egg-rr94.8%

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

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

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

    if -3.7e-16 < x.re < 1.06000000000000004e69

    1. Initial program 87.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. *-commutative87.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \frac{x.im \cdot \left(2 \cdot {\left(x.re \cdot x.im\right)}^{3}\right)}{{\left(x.re \cdot x.im\right)}^{2} + \color{blue}{0}} \]
    3. Applied egg-rr18.7%

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares17.8%

        \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    6. Applied egg-rr17.8%

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

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

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} - \frac{-x.re}{-x.re} \]
    9. Taylor expanded in x.im around inf 28.9%

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
    10. Step-by-step derivation
      1. *-commutative28.9%

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot -27} \]
      2. associate-*l*28.9%

        \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot -27\right)} \]
    11. Simplified28.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -3.7 \cdot 10^{-16} \lor \neg \left(x.re \leq 1.06 \cdot 10^{+69}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.re - 27\right)\right) + \frac{x.re}{-x.re}\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot -27\right)\\ \end{array} \]

Alternative 6: 29.5% accurate, 1.4× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \leq 7.2 \cdot 10^{+160}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot -27\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right) + \frac{x.re}{-x.re}\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re 7.2e+160)
   (* x.im (* x.re -27.0))
   (+ (* x.im (* x.re (- x.re 27.0))) (/ x.re (- x.re)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= 7.2e+160) {
		tmp = x_46_im * (x_46_re * -27.0);
	} else {
		tmp = (x_46_im * (x_46_re * (x_46_re - 27.0))) + (x_46_re / -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 <= 7.2d+160) then
        tmp = x_46im * (x_46re * (-27.0d0))
    else
        tmp = (x_46im * (x_46re * (x_46re - 27.0d0))) + (x_46re / -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 <= 7.2e+160) {
		tmp = x_46_im * (x_46_re * -27.0);
	} else {
		tmp = (x_46_im * (x_46_re * (x_46_re - 27.0))) + (x_46_re / -x_46_re);
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_re <= 7.2e+160:
		tmp = x_46_im * (x_46_re * -27.0)
	else:
		tmp = (x_46_im * (x_46_re * (x_46_re - 27.0))) + (x_46_re / -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 <= 7.2e+160)
		tmp = Float64(x_46_im * Float64(x_46_re * -27.0));
	else
		tmp = Float64(Float64(x_46_im * Float64(x_46_re * Float64(x_46_re - 27.0))) + Float64(x_46_re / Float64(-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 <= 7.2e+160)
		tmp = x_46_im * (x_46_re * -27.0);
	else
		tmp = (x_46_im * (x_46_re * (x_46_re - 27.0))) + (x_46_re / -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$re, 7.2e+160], N[(x$46$im * N[(x$46$re * -27.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * N[(x$46$re * N[(x$46$re - 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re / (-x$46$re)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 7.2 \cdot 10^{+160}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot -27\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 7.20000000000000042e160

    1. Initial program 86.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. *-commutative86.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares47.3%

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

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

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

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} - \frac{-x.re}{-x.re} \]
    9. Taylor expanded in x.im around inf 24.7%

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
    10. Step-by-step derivation
      1. *-commutative24.7%

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot -27} \]
      2. associate-*l*24.7%

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

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

    if 7.20000000000000042e160 < x.re

    1. Initial program 65.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. *-commutative65.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
    5. Step-by-step derivation
      1. difference-of-squares100.0%

        \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    6. Applied egg-rr100.0%

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

      \[\leadsto \color{blue}{\left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right)} \cdot x.re - \frac{-x.re}{-x.re} \]
    8. Taylor expanded in x.im around inf 55.2%

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

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

Alternative 7: 20.0% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
  5. Step-by-step derivation
    1. difference-of-squares53.3%

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

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

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

    \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} - \frac{-x.re}{-x.re} \]
  9. Taylor expanded in x.im around inf 23.6%

    \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
  10. Final simplification23.6%

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

Alternative 8: 20.0% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
  5. Step-by-step derivation
    1. difference-of-squares53.3%

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

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

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

    \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} - \frac{-x.re}{-x.re} \]
  9. Taylor expanded in x.im around inf 23.6%

    \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
  10. Step-by-step derivation
    1. *-commutative23.6%

      \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot -27} \]
    2. associate-*l*23.6%

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

    \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot -27\right)} \]
  12. Final simplification23.6%

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

Alternative 9: 2.7% accurate, 19.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\frac{-x.re}{-x.re}} \]
  5. Step-by-step derivation
    1. difference-of-squares53.3%

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

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

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

    \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} - \frac{-x.re}{-x.re} \]
  9. Taylor expanded in x.im around 0 2.7%

    \[\leadsto \color{blue}{-1} \]
  10. Final simplification2.7%

    \[\leadsto -1 \]

Developer target: 87.6% 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 2023292 
(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)))