math.cube on complex, real part

Percentage Accurate: 82.2% → 99.8%
Time: 11.7s
Alternatives: 14
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 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 82.2% 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.8% accurate, 0.1× speedup?

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

\mathbf{elif}\;x.re \leq 5 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot x.im, x.im \cdot -3, {x.re}^{3}\right)\\

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


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

    1. Initial program 53.3%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. difference-of-squares64.4%

        \[\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 \]
    3. Applied egg-rr64.4%

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

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

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

    if -5.49999999999999981e102 < x.re < 4.99999999999999989e101

    1. Initial program 89.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. Simplified89.8%

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)} + {x.re}^{3} \]
      3. 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)} \]

    if 4.99999999999999989e101 < x.re

    1. Initial program 62.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. difference-of-squares72.1%

        \[\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 \]
      2. *-commutative72.1%

        \[\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 \]
    3. Applied egg-rr72.1%

      \[\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. Step-by-step derivation
      1. *-commutative72.1%

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\color{blue}{\left(\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)\right)}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.im \]
      6. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

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

Alternative 2: 93.7% accurate, 0.1× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} t_0 := x.re \cdot x.re - x.im \cdot x.im\\ \mathbf{if}\;x.re \cdot t_0 - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq 5 \cdot 10^{+256}:\\ \;\;\;\;\mathsf{fma}\left(x.re, t_0, x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) - x.im \cdot -3\\ \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.im))))
   (if (<= (- (* x.re t_0) (* x.im (+ (* x.re x.im) (* x.re x.im)))) 5e+256)
     (fma x.re t_0 (* x.im (* (* x.re x.im) -2.0)))
     (- (* x.re (* (+ x.re x.im) (- x.re x.im))) (* x.im -3.0)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re * x_46_re) - (x_46_im * x_46_im);
	double tmp;
	if (((x_46_re * t_0) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 5e+256) {
		tmp = fma(x_46_re, t_0, (x_46_im * ((x_46_re * x_46_im) * -2.0)));
	} else {
		tmp = (x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) - (x_46_im * -3.0);
	}
	return tmp;
}
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))
	tmp = 0.0
	if (Float64(Float64(x_46_re * t_0) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= 5e+256)
		tmp = fma(x_46_re, t_0, Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * -2.0)));
	else
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re - x_46_im))) - Float64(x_46_im * -3.0));
	end
	return tmp
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x$46$re * t$95$0), $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], 5e+256], N[(x$46$re * t$95$0 + N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -2.0), $MachinePrecision]), $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] - N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot x.re - x.im \cdot x.im\\
\mathbf{if}\;x.re \cdot t_0 - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq 5 \cdot 10^{+256}:\\
\;\;\;\;\mathsf{fma}\left(x.re, t_0, x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -2\right)\right)\\

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


\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)) < 5.00000000000000015e256

    1. Initial program 95.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. Simplified95.5%

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

    if 5.00000000000000015e256 < (-.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 44.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. difference-of-squares55.5%

        \[\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 \]
      2. *-commutative55.5%

        \[\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 \]
    3. Applied egg-rr55.5%

      \[\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. Step-by-step derivation
      1. *-commutative55.5%

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\color{blue}{\left(\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)\right)}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.im \]
      6. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

    \[\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 5 \cdot 10^{+256}:\\ \;\;\;\;\mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) - x.im \cdot -3\\ \end{array} \]

Alternative 3: 93.7% 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 5 \cdot 10^{+256}:\\ \;\;\;\;t_0 - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - x.im \cdot -3\\ \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))))
        5e+256)
     (- t_0 (* x.im (* (* x.re x.im) 2.0)))
     (- t_0 (* x.im -3.0)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * ((x_46_re + x_46_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)))) <= 5e+256) {
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0));
	} else {
		tmp = t_0 - (x_46_im * -3.0);
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x_46re * ((x_46re + x_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)))) <= 5d+256) then
        tmp = t_0 - (x_46im * ((x_46re * x_46im) * 2.0d0))
    else
        tmp = t_0 - (x_46im * (-3.0d0))
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * ((x_46_re + x_46_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)))) <= 5e+256) {
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0));
	} else {
		tmp = t_0 - (x_46_im * -3.0);
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	t_0 = x_46_re * ((x_46_re + x_46_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)))) <= 5e+256:
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0))
	else:
		tmp = t_0 - (x_46_im * -3.0)
	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)))) <= 5e+256)
		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_im * -3.0));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_re * ((x_46_re + x_46_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)))) <= 5e+256)
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0));
	else
		tmp = t_0 - (x_46_im * -3.0);
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(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], 5e+256], 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$im * -3.0), $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 5 \cdot 10^{+256}:\\
\;\;\;\;t_0 - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 - x.im \cdot -3\\


\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)) < 5.00000000000000015e256

    1. Initial program 95.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. difference-of-squares95.5%

        \[\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 \]
      2. *-commutative95.5%

        \[\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 \]
    3. Applied egg-rr95.5%

      \[\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. Step-by-step derivation
      1. *-commutative29.5%

        \[\leadsto x.im \cdot \left(x.re \cdot -27\right) - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. *-un-lft-identity29.5%

        \[\leadsto x.im \cdot \left(x.re \cdot -27\right) - \left(x.re \cdot x.im + \color{blue}{1 \cdot \left(x.re \cdot x.im\right)}\right) \cdot x.im \]
      3. *-un-lft-identity29.5%

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

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

        \[\leadsto x.im \cdot \left(x.re \cdot -27\right) - \left(\left(x.re \cdot x.im\right) \cdot \color{blue}{2}\right) \cdot x.im \]
    5. Applied egg-rr95.5%

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

    if 5.00000000000000015e256 < (-.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 44.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. difference-of-squares55.5%

        \[\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 \]
      2. *-commutative55.5%

        \[\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 \]
    3. Applied egg-rr55.5%

      \[\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. Step-by-step derivation
      1. *-commutative55.5%

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\color{blue}{\left(\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)\right)}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.im \]
      6. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

    \[\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 5 \cdot 10^{+256}:\\ \;\;\;\;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) - x.im \cdot -3\\ \end{array} \]

Alternative 4: 72.3% accurate, 0.9× 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.im \leq 1.85 \cdot 10^{-156}:\\ \;\;\;\;x.re \cdot x.im + t_0\\ \mathbf{elif}\;x.im \leq 5.1 \cdot 10^{+49}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.re - 27\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - x.im \cdot -3\\ \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.im 1.85e-156)
     (+ (* x.re x.im) t_0)
     (if (<= x.im 5.1e+49)
       (-
        (* x.re (* x.re (- x.re 27.0)))
        (* x.im (+ (* x.re x.im) (* x.re x.im))))
       (- t_0 (* x.im -3.0))))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im));
	double tmp;
	if (x_46_im <= 1.85e-156) {
		tmp = (x_46_re * x_46_im) + t_0;
	} else if (x_46_im <= 5.1e+49) {
		tmp = (x_46_re * (x_46_re * (x_46_re - 27.0))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	} else {
		tmp = t_0 - (x_46_im * -3.0);
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x_46re * ((x_46re + x_46im) * (x_46re - x_46im))
    if (x_46im <= 1.85d-156) then
        tmp = (x_46re * x_46im) + t_0
    else if (x_46im <= 5.1d+49) then
        tmp = (x_46re * (x_46re * (x_46re - 27.0d0))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))
    else
        tmp = t_0 - (x_46im * (-3.0d0))
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im));
	double tmp;
	if (x_46_im <= 1.85e-156) {
		tmp = (x_46_re * x_46_im) + t_0;
	} else if (x_46_im <= 5.1e+49) {
		tmp = (x_46_re * (x_46_re * (x_46_re - 27.0))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	} else {
		tmp = t_0 - (x_46_im * -3.0);
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	t_0 = x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im))
	tmp = 0
	if x_46_im <= 1.85e-156:
		tmp = (x_46_re * x_46_im) + t_0
	elif x_46_im <= 5.1e+49:
		tmp = (x_46_re * (x_46_re * (x_46_re - 27.0))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))
	else:
		tmp = t_0 - (x_46_im * -3.0)
	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 (x_46_im <= 1.85e-156)
		tmp = Float64(Float64(x_46_re * x_46_im) + t_0);
	elseif (x_46_im <= 5.1e+49)
		tmp = Float64(Float64(x_46_re * Float64(x_46_re * Float64(x_46_re - 27.0))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))));
	else
		tmp = Float64(t_0 - Float64(x_46_im * -3.0));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im));
	tmp = 0.0;
	if (x_46_im <= 1.85e-156)
		tmp = (x_46_re * x_46_im) + t_0;
	elseif (x_46_im <= 5.1e+49)
		tmp = (x_46_re * (x_46_re * (x_46_re - 27.0))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	else
		tmp = t_0 - (x_46_im * -3.0);
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, 1.85e-156], N[(N[(x$46$re * x$46$im), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[x$46$im, 5.1e+49], N[(N[(x$46$re * N[(x$46$re * N[(x$46$re - 27.0), $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], N[(t$95$0 - N[(x$46$im * -3.0), $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.im \leq 1.85 \cdot 10^{-156}:\\
\;\;\;\;x.re \cdot x.im + t_0\\

\mathbf{elif}\;x.im \leq 5.1 \cdot 10^{+49}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(x.re - 27\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 - x.im \cdot -3\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < 1.85e-156

    1. Initial program 82.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. difference-of-squares85.8%

        \[\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 \]
      2. *-commutative85.8%

        \[\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 \]
    3. Applied egg-rr85.8%

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

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

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

    if 1.85e-156 < x.im < 5.09999999999999956e49

    1. Initial program 100.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. 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 - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    3. 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 - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    4. Simplified46.4%

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

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

    if 5.09999999999999956e49 < x.im

    1. Initial program 55.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. difference-of-squares60.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 \]
      2. *-commutative60.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 \]
    3. Applied egg-rr60.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. Step-by-step derivation
      1. *-commutative60.7%

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\color{blue}{\left(\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)\right)}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.im \]
      6. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

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

Alternative 5: 72.6% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -2.20000000000000006e-58 or 6.1000000000000001e-61 < x.re

    1. Initial program 74.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-squares80.6%

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

        \[\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 \]
    3. Applied egg-rr80.6%

      \[\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. Step-by-step derivation
      1. *-commutative80.6%

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\color{blue}{\left(\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)\right)}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.im \]
      6. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

    if -2.20000000000000006e-58 < x.re < 6.1000000000000001e-61

    1. Initial program 85.1%

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

        \[\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 \]
    3. Applied egg-rr85.1%

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

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

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

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

Alternative 6: 72.5% accurate, 1.1× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \leq -3.6 \cdot 10^{-58} \lor \neg \left(x.re \leq 6.1 \cdot 10^{-61}\right):\\ \;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) - x.im \cdot -3\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot -27\right) - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\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.6e-58) (not (<= x.re 6.1e-61)))
   (- (* x.re (* (+ x.re x.im) (- x.re x.im))) (* x.im -3.0))
   (- (* x.im (* x.re -27.0)) (* x.im (* (* x.re x.im) 2.0)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -3.6e-58) || !(x_46_re <= 6.1e-61)) {
		tmp = (x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) - (x_46_im * -3.0);
	} else {
		tmp = (x_46_im * (x_46_re * -27.0)) - (x_46_im * ((x_46_re * x_46_im) * 2.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.6d-58)) .or. (.not. (x_46re <= 6.1d-61))) then
        tmp = (x_46re * ((x_46re + x_46im) * (x_46re - x_46im))) - (x_46im * (-3.0d0))
    else
        tmp = (x_46im * (x_46re * (-27.0d0))) - (x_46im * ((x_46re * x_46im) * 2.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.6e-58) || !(x_46_re <= 6.1e-61)) {
		tmp = (x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) - (x_46_im * -3.0);
	} else {
		tmp = (x_46_im * (x_46_re * -27.0)) - (x_46_im * ((x_46_re * x_46_im) * 2.0));
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -3.6e-58) or not (x_46_re <= 6.1e-61):
		tmp = (x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) - (x_46_im * -3.0)
	else:
		tmp = (x_46_im * (x_46_re * -27.0)) - (x_46_im * ((x_46_re * x_46_im) * 2.0))
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -3.6e-58) || !(x_46_re <= 6.1e-61))
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re - x_46_im))) - Float64(x_46_im * -3.0));
	else
		tmp = Float64(Float64(x_46_im * Float64(x_46_re * -27.0)) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * 2.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.6e-58) || ~((x_46_re <= 6.1e-61)))
		tmp = (x_46_re * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) - (x_46_im * -3.0);
	else
		tmp = (x_46_im * (x_46_re * -27.0)) - (x_46_im * ((x_46_re * x_46_im) * 2.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.6e-58], N[Not[LessEqual[x$46$re, 6.1e-61]], $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$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * N[(x$46$re * -27.0), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -3.6 \cdot 10^{-58} \lor \neg \left(x.re \leq 6.1 \cdot 10^{-61}\right):\\
\;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) - x.im \cdot -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -3.60000000000000009e-58 or 6.1000000000000001e-61 < x.re

    1. Initial program 74.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-squares80.6%

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

        \[\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 \]
    3. Applied egg-rr80.6%

      \[\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. Step-by-step derivation
      1. *-commutative80.6%

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\color{blue}{\left(\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)\right)}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.im \]
      6. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

    if -3.60000000000000009e-58 < x.re < 6.1000000000000001e-61

    1. Initial program 85.1%

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

        \[\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 \]
    3. Applied egg-rr85.1%

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

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

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

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

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

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

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

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

        \[\leadsto x.im \cdot \left(x.re \cdot -27\right) - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im \]
      2. *-un-lft-identity39.1%

        \[\leadsto x.im \cdot \left(x.re \cdot -27\right) - \left(x.re \cdot x.im + \color{blue}{1 \cdot \left(x.re \cdot x.im\right)}\right) \cdot x.im \]
      3. *-un-lft-identity39.1%

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

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

        \[\leadsto x.im \cdot \left(x.re \cdot -27\right) - \left(\left(x.re \cdot x.im\right) \cdot \color{blue}{2}\right) \cdot x.im \]
    9. Applied egg-rr39.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -3.6 \cdot 10^{-58} \lor \neg \left(x.re \leq 6.1 \cdot 10^{-61}\right):\\ \;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) - x.im \cdot -3\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot -27\right) - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)\\ \end{array} \]

Alternative 7: 40.1% accurate, 1.2× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} t_0 := x.re \cdot \left(x.re \cdot -27\right)\\ t_1 := x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\ \mathbf{if}\;x.re \leq -3.5 \cdot 10^{+149}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.re \leq -6 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.re \leq 1.9 \cdot 10^{-180}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.re \leq 1.1 \cdot 10^{+157}:\\ \;\;\;\;-27 \cdot \left(x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 -27.0))) (t_1 (* x.im (* x.re (- x.re 27.0)))))
   (if (<= x.re -3.5e+149)
     t_0
     (if (<= x.re -6e-160)
       t_1
       (if (<= x.re 1.9e-180)
         t_0
         (if (<= x.re 1.1e+157) (* -27.0 (* x.re x.im)) t_1))))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (x_46_re * -27.0);
	double t_1 = x_46_im * (x_46_re * (x_46_re - 27.0));
	double tmp;
	if (x_46_re <= -3.5e+149) {
		tmp = t_0;
	} else if (x_46_re <= -6e-160) {
		tmp = t_1;
	} else if (x_46_re <= 1.9e-180) {
		tmp = t_0;
	} else if (x_46_re <= 1.1e+157) {
		tmp = -27.0 * (x_46_re * x_46_im);
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x_46re * (x_46re * (-27.0d0))
    t_1 = x_46im * (x_46re * (x_46re - 27.0d0))
    if (x_46re <= (-3.5d+149)) then
        tmp = t_0
    else if (x_46re <= (-6d-160)) then
        tmp = t_1
    else if (x_46re <= 1.9d-180) then
        tmp = t_0
    else if (x_46re <= 1.1d+157) then
        tmp = (-27.0d0) * (x_46re * x_46im)
    else
        tmp = t_1
    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 * -27.0);
	double t_1 = x_46_im * (x_46_re * (x_46_re - 27.0));
	double tmp;
	if (x_46_re <= -3.5e+149) {
		tmp = t_0;
	} else if (x_46_re <= -6e-160) {
		tmp = t_1;
	} else if (x_46_re <= 1.9e-180) {
		tmp = t_0;
	} else if (x_46_re <= 1.1e+157) {
		tmp = -27.0 * (x_46_re * x_46_im);
	} else {
		tmp = t_1;
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	t_0 = x_46_re * (x_46_re * -27.0)
	t_1 = x_46_im * (x_46_re * (x_46_re - 27.0))
	tmp = 0
	if x_46_re <= -3.5e+149:
		tmp = t_0
	elif x_46_re <= -6e-160:
		tmp = t_1
	elif x_46_re <= 1.9e-180:
		tmp = t_0
	elif x_46_re <= 1.1e+157:
		tmp = -27.0 * (x_46_re * x_46_im)
	else:
		tmp = t_1
	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 * -27.0))
	t_1 = Float64(x_46_im * Float64(x_46_re * Float64(x_46_re - 27.0)))
	tmp = 0.0
	if (x_46_re <= -3.5e+149)
		tmp = t_0;
	elseif (x_46_re <= -6e-160)
		tmp = t_1;
	elseif (x_46_re <= 1.9e-180)
		tmp = t_0;
	elseif (x_46_re <= 1.1e+157)
		tmp = Float64(-27.0 * Float64(x_46_re * x_46_im));
	else
		tmp = t_1;
	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 * -27.0);
	t_1 = x_46_im * (x_46_re * (x_46_re - 27.0));
	tmp = 0.0;
	if (x_46_re <= -3.5e+149)
		tmp = t_0;
	elseif (x_46_re <= -6e-160)
		tmp = t_1;
	elseif (x_46_re <= 1.9e-180)
		tmp = t_0;
	elseif (x_46_re <= 1.1e+157)
		tmp = -27.0 * (x_46_re * x_46_im);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(x$46$re * -27.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$46$im * N[(x$46$re * N[(x$46$re - 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -3.5e+149], t$95$0, If[LessEqual[x$46$re, -6e-160], t$95$1, If[LessEqual[x$46$re, 1.9e-180], t$95$0, If[LessEqual[x$46$re, 1.1e+157], N[(-27.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot -27\right)\\
t_1 := x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\
\mathbf{if}\;x.re \leq -3.5 \cdot 10^{+149}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x.re \leq 1.9 \cdot 10^{-180}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x.re \leq 1.1 \cdot 10^{+157}:\\
\;\;\;\;-27 \cdot \left(x.re \cdot x.im\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -3.50000000000000011e149 or -5.99999999999999993e-160 < x.re < 1.9e-180

    1. Initial program 65.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. difference-of-squares70.6%

        \[\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 \]
    3. Applied egg-rr70.6%

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

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

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

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

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

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

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

    if -3.50000000000000011e149 < x.re < -5.99999999999999993e-160 or 1.1000000000000001e157 < x.re

    1. Initial program 82.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. difference-of-squares85.2%

        \[\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 \]
    3. Applied egg-rr85.2%

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

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

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

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

    if 1.9e-180 < x.re < 1.1000000000000001e157

    1. Initial program 93.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. difference-of-squares95.5%

        \[\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 \]
    3. Applied egg-rr95.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -3.5 \cdot 10^{+149}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot -27\right)\\ \mathbf{elif}\;x.re \leq -6 \cdot 10^{-160}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\ \mathbf{elif}\;x.re \leq 1.9 \cdot 10^{-180}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot -27\right)\\ \mathbf{elif}\;x.re \leq 1.1 \cdot 10^{+157}:\\ \;\;\;\;-27 \cdot \left(x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\ \end{array} \]

Alternative 8: 62.4% accurate, 1.3× speedup?

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

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


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

    1. Initial program 83.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. difference-of-squares86.3%

        \[\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 \]
    3. Applied egg-rr86.3%

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

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

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

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

    if 2.1999999999999999e129 < x.im

    1. Initial program 50.9%

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

        \[\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 \]
    3. Applied egg-rr59.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto x.im \cdot \left(x.re \cdot -27\right) - \left(x.re \cdot x.im + \color{blue}{1 \cdot \left(x.re \cdot x.im\right)}\right) \cdot x.im \]
      3. *-un-lft-identity58.9%

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

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

        \[\leadsto x.im \cdot \left(x.re \cdot -27\right) - \left(\left(x.re \cdot x.im\right) \cdot \color{blue}{2}\right) \cdot x.im \]
    9. Applied egg-rr58.9%

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

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

Alternative 9: 55.4% accurate, 1.4× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq 7 \cdot 10^{-14}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\ \mathbf{elif}\;x.im \leq 1.78 \cdot 10^{+227}:\\ \;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re + -27\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re + x.im\right) \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 (<= x.im 7e-14)
   (* x.re (* x.re (- x.re 27.0)))
   (if (<= x.im 1.78e+227)
     (* x.re (* (+ x.re x.im) (+ x.re -27.0)))
     (* (+ 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_im <= 7e-14) {
		tmp = x_46_re * (x_46_re * (x_46_re - 27.0));
	} else if (x_46_im <= 1.78e+227) {
		tmp = x_46_re * ((x_46_re + x_46_im) * (x_46_re + -27.0));
	} else {
		tmp = (x_46_re + 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_46im <= 7d-14) then
        tmp = x_46re * (x_46re * (x_46re - 27.0d0))
    else if (x_46im <= 1.78d+227) then
        tmp = x_46re * ((x_46re + x_46im) * (x_46re + (-27.0d0)))
    else
        tmp = (x_46re + 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_im <= 7e-14) {
		tmp = x_46_re * (x_46_re * (x_46_re - 27.0));
	} else if (x_46_im <= 1.78e+227) {
		tmp = x_46_re * ((x_46_re + x_46_im) * (x_46_re + -27.0));
	} else {
		tmp = (x_46_re + 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_im <= 7e-14:
		tmp = x_46_re * (x_46_re * (x_46_re - 27.0))
	elif x_46_im <= 1.78e+227:
		tmp = x_46_re * ((x_46_re + x_46_im) * (x_46_re + -27.0))
	else:
		tmp = (x_46_re + 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_im <= 7e-14)
		tmp = Float64(x_46_re * Float64(x_46_re * Float64(x_46_re - 27.0)));
	elseif (x_46_im <= 1.78e+227)
		tmp = Float64(x_46_re * Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re + -27.0)));
	else
		tmp = Float64(Float64(x_46_re + 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_im <= 7e-14)
		tmp = x_46_re * (x_46_re * (x_46_re - 27.0));
	elseif (x_46_im <= 1.78e+227)
		tmp = x_46_re * ((x_46_re + x_46_im) * (x_46_re + -27.0));
	else
		tmp = (x_46_re + 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[LessEqual[x$46$im, 7e-14], N[(x$46$re * N[(x$46$re * N[(x$46$re - 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1.78e+227], N[(x$46$re * N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re * -27.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 7 \cdot 10^{-14}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\

\mathbf{elif}\;x.im \leq 1.78 \cdot 10^{+227}:\\
\;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re + -27\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < 7.0000000000000005e-14

    1. Initial program 84.3%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. difference-of-squares87.4%

        \[\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 \]
    3. Applied egg-rr87.4%

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

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

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

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

    if 7.0000000000000005e-14 < x.im < 1.77999999999999995e227

    1. Initial program 65.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. difference-of-squares67.8%

        \[\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 \]
    3. Applied egg-rr67.8%

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

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

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

    if 1.77999999999999995e227 < x.im

    1. Initial program 54.9%

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

        \[\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 \]
    3. Applied egg-rr68.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 7 \cdot 10^{-14}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\ \mathbf{elif}\;x.im \leq 1.78 \cdot 10^{+227}:\\ \;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re + -27\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot -27\right)\\ \end{array} \]

Alternative 10: 52.7% accurate, 2.1× speedup?

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

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


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

    1. Initial program 80.1%

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

        \[\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 \]
    3. Applied egg-rr83.0%

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

      \[\leadsto \color{blue}{\left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right)} \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    5. Applied egg-rr50.4%

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

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

    if 9.49999999999999938e234 < x.im

    1. Initial program 58.1%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. difference-of-squares72.4%

        \[\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 \]
    3. Applied egg-rr72.4%

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

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

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

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

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

Alternative 11: 53.9% accurate, 2.1× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq 2.9 \cdot 10^{+190}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re + x.im\right) \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 (<= x.im 2.9e+190)
   (* x.re (* x.re (- x.re 27.0)))
   (* (+ 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_im <= 2.9e+190) {
		tmp = x_46_re * (x_46_re * (x_46_re - 27.0));
	} else {
		tmp = (x_46_re + 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_46im <= 2.9d+190) then
        tmp = x_46re * (x_46re * (x_46re - 27.0d0))
    else
        tmp = (x_46re + 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_im <= 2.9e+190) {
		tmp = x_46_re * (x_46_re * (x_46_re - 27.0));
	} else {
		tmp = (x_46_re + 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_im <= 2.9e+190:
		tmp = x_46_re * (x_46_re * (x_46_re - 27.0))
	else:
		tmp = (x_46_re + 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_im <= 2.9e+190)
		tmp = Float64(x_46_re * Float64(x_46_re * Float64(x_46_re - 27.0)));
	else
		tmp = Float64(Float64(x_46_re + 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_im <= 2.9e+190)
		tmp = x_46_re * (x_46_re * (x_46_re - 27.0));
	else
		tmp = (x_46_re + 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[LessEqual[x$46$im, 2.9e+190], N[(x$46$re * N[(x$46$re * N[(x$46$re - 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re * -27.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 2.9 \cdot 10^{+190}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\

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


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

    1. Initial program 81.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. difference-of-squares84.4%

        \[\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 \]
    3. Applied egg-rr84.4%

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

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

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

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

    if 2.89999999999999989e190 < x.im

    1. Initial program 52.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. difference-of-squares61.4%

        \[\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 \]
    3. Applied egg-rr61.4%

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

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

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

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

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

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

Alternative 12: 28.4% accurate, 2.7× speedup?

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

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


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

    1. Initial program 80.1%

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

        \[\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 \]
    3. Applied egg-rr83.0%

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

      \[\leadsto \color{blue}{\left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right)} \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    5. Applied egg-rr50.4%

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

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

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

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

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

    if 5.60000000000000052e235 < x.im

    1. Initial program 58.1%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. difference-of-squares72.4%

        \[\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 \]
    3. Applied egg-rr72.4%

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

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

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

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

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

Alternative 13: 19.8% 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 78.9%

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
  2. Step-by-step derivation
    1. difference-of-squares82.4%

      \[\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 \]
  3. Applied egg-rr82.4%

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

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

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

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

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

Alternative 14: 3.1% accurate, 9.5× speedup?

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

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

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

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

    \[\leadsto \color{blue}{-x.re} \]
  5. Final simplification3.3%

    \[\leadsto -x.re \]

Developer target: 87.3% 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 2023305 
(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)))