math.cube on complex, real part

Percentage Accurate: 83.1% → 93.4%
Time: 9.9s
Alternatives: 8
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 83.1% 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: 93.4% accurate, 0.1× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ \begin{array}{l} \mathbf{if}\;x.im\_m \leq 7.2 \cdot 10^{+139}:\\ \;\;\;\;\mathsf{fma}\left(x.im\_m \cdot x.re, x.im\_m \cdot -3, {x.re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im\_m, x.re \cdot \left(x.im\_m + x.re\right), \left(x.im\_m \cdot x.re\right) \cdot \left(x.im\_m \cdot -2\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
(FPCore (x.re x.im_m)
 :precision binary64
 (if (<= x.im_m 7.2e+139)
   (fma (* x.im_m x.re) (* x.im_m -3.0) (pow x.re 3.0))
   (fma
    (- x.re x.im_m)
    (* x.re (+ x.im_m x.re))
    (* (* x.im_m x.re) (* x.im_m -2.0)))))
x.im_m = fabs(x_46_im);
double code(double x_46_re, double x_46_im_m) {
	double tmp;
	if (x_46_im_m <= 7.2e+139) {
		tmp = fma((x_46_im_m * x_46_re), (x_46_im_m * -3.0), pow(x_46_re, 3.0));
	} else {
		tmp = fma((x_46_re - x_46_im_m), (x_46_re * (x_46_im_m + x_46_re)), ((x_46_im_m * x_46_re) * (x_46_im_m * -2.0)));
	}
	return tmp;
}
x.im_m = abs(x_46_im)
function code(x_46_re, x_46_im_m)
	tmp = 0.0
	if (x_46_im_m <= 7.2e+139)
		tmp = fma(Float64(x_46_im_m * x_46_re), Float64(x_46_im_m * -3.0), (x_46_re ^ 3.0));
	else
		tmp = fma(Float64(x_46_re - x_46_im_m), Float64(x_46_re * Float64(x_46_im_m + x_46_re)), Float64(Float64(x_46_im_m * x_46_re) * Float64(x_46_im_m * -2.0)));
	end
	return tmp
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
code[x$46$re_, x$46$im$95$m_] := If[LessEqual[x$46$im$95$m, 7.2e+139], N[(N[(x$46$im$95$m * x$46$re), $MachinePrecision] * N[(x$46$im$95$m * -3.0), $MachinePrecision] + N[Power[x$46$re, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re - x$46$im$95$m), $MachinePrecision] * N[(x$46$re * N[(x$46$im$95$m + x$46$re), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$im$95$m * x$46$re), $MachinePrecision] * N[(x$46$im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im_m = \left|x.im\right|

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im\_m, x.re \cdot \left(x.im\_m + x.re\right), \left(x.im\_m \cdot x.re\right) \cdot \left(x.im\_m \cdot -2\right)\right)\\


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

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

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

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

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

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

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

    if 7.19999999999999971e139 < x.im

    1. Initial program 63.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares70.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. *-commutative70.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. Applied egg-rr70.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 \]
    5. Step-by-step derivation
      1. associate-*l*93.5%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, -\color{blue}{\log \left(e^{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}\right)}\right) \]
      6. neg-log67.1%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \color{blue}{\log \left(\frac{1}{e^{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}}\right)}\right) \]
      7. exp-prod69.6%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{\color{blue}{{\left(e^{x.re \cdot x.im + x.im \cdot x.re}\right)}^{x.im}}}\right)\right) \]
      8. *-commutative69.6%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{{\left(e^{x.re \cdot x.im + \color{blue}{x.re \cdot x.im}}\right)}^{x.im}}\right)\right) \]
      9. exp-sum69.6%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{{\color{blue}{\left(e^{x.re \cdot x.im} \cdot e^{x.re \cdot x.im}\right)}}^{x.im}}\right)\right) \]
      10. exp-lft-sqr69.6%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{{\color{blue}{\left(e^{\left(x.re \cdot x.im\right) \cdot 2}\right)}}^{x.im}}\right)\right) \]
      11. exp-prod67.1%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{\color{blue}{e^{\left(\left(x.re \cdot x.im\right) \cdot 2\right) \cdot x.im}}}\right)\right) \]
      12. neg-log67.1%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \color{blue}{-\log \left(e^{\left(\left(x.re \cdot x.im\right) \cdot 2\right) \cdot x.im}\right)}\right) \]
      13. add-log-exp93.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.im + x.re\right), \color{blue}{\left(x.im \cdot x.re\right)} \cdot \left(-2 \cdot x.im\right)\right) \]
      5. distribute-lft-neg-in93.4%

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

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

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

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

Alternative 2: 93.9% accurate, 0.2× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ \begin{array}{l} \mathbf{if}\;x.re \leq 1.25 \cdot 10^{+203}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im\_m, x.re \cdot \left(x.im\_m + x.re\right), \left(x.im\_m \cdot x.re\right) \cdot \left(x.im\_m \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im\_m + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
(FPCore (x.re x.im_m)
 :precision binary64
 (if (<= x.re 1.25e+203)
   (fma
    (- x.re x.im_m)
    (* x.re (+ x.im_m x.re))
    (* (* x.im_m x.re) (* x.im_m -2.0)))
   (* (+ x.im_m x.re) (* x.re (+ x.re -27.0)))))
x.im_m = fabs(x_46_im);
double code(double x_46_re, double x_46_im_m) {
	double tmp;
	if (x_46_re <= 1.25e+203) {
		tmp = fma((x_46_re - x_46_im_m), (x_46_re * (x_46_im_m + x_46_re)), ((x_46_im_m * x_46_re) * (x_46_im_m * -2.0)));
	} else {
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	}
	return tmp;
}
x.im_m = abs(x_46_im)
function code(x_46_re, x_46_im_m)
	tmp = 0.0
	if (x_46_re <= 1.25e+203)
		tmp = fma(Float64(x_46_re - x_46_im_m), Float64(x_46_re * Float64(x_46_im_m + x_46_re)), Float64(Float64(x_46_im_m * x_46_re) * Float64(x_46_im_m * -2.0)));
	else
		tmp = Float64(Float64(x_46_im_m + x_46_re) * Float64(x_46_re * Float64(x_46_re + -27.0)));
	end
	return tmp
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
code[x$46$re_, x$46$im$95$m_] := If[LessEqual[x$46$re, 1.25e+203], N[(N[(x$46$re - x$46$im$95$m), $MachinePrecision] * N[(x$46$re * N[(x$46$im$95$m + x$46$re), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$im$95$m * x$46$re), $MachinePrecision] * N[(x$46$im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im$95$m + x$46$re), $MachinePrecision] * N[(x$46$re * N[(x$46$re + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im_m = \left|x.im\right|

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 1.25 \cdot 10^{+203}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im\_m, x.re \cdot \left(x.im\_m + x.re\right), \left(x.im\_m \cdot x.re\right) \cdot \left(x.im\_m \cdot -2\right)\right)\\

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


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

    1. Initial program 84.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares88.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 \]
      2. *-commutative88.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. Applied egg-rr88.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 \]
    5. Step-by-step derivation
      1. associate-*l*95.1%

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \color{blue}{\left(x.re + x.im\right)} \cdot x.re, -\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\right) \]
      5. add-log-exp63.4%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, -\color{blue}{\log \left(e^{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}\right)}\right) \]
      6. neg-log63.4%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \color{blue}{\log \left(\frac{1}{e^{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im}}\right)}\right) \]
      7. exp-prod62.0%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{\color{blue}{{\left(e^{x.re \cdot x.im + x.im \cdot x.re}\right)}^{x.im}}}\right)\right) \]
      8. *-commutative62.0%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{{\left(e^{x.re \cdot x.im + \color{blue}{x.re \cdot x.im}}\right)}^{x.im}}\right)\right) \]
      9. exp-sum62.0%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{{\color{blue}{\left(e^{x.re \cdot x.im} \cdot e^{x.re \cdot x.im}\right)}}^{x.im}}\right)\right) \]
      10. exp-lft-sqr62.0%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{{\color{blue}{\left(e^{\left(x.re \cdot x.im\right) \cdot 2}\right)}}^{x.im}}\right)\right) \]
      11. exp-prod63.4%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \log \left(\frac{1}{\color{blue}{e^{\left(\left(x.re \cdot x.im\right) \cdot 2\right) \cdot x.im}}}\right)\right) \]
      12. neg-log63.4%

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.re, \color{blue}{-\log \left(e^{\left(\left(x.re \cdot x.im\right) \cdot 2\right) \cdot x.im}\right)}\right) \]
      13. add-log-exp95.1%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.im + x.re\right), \color{blue}{\left(x.im \cdot x.re\right)} \cdot \left(-2 \cdot x.im\right)\right) \]
      5. distribute-lft-neg-in95.1%

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

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

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

    if 1.24999999999999999e203 < x.re

    1. Initial program 70.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares80.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. Applied egg-rr80.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 \]
    5. Simplified80.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 \]
    6. Step-by-step derivation
      1. *-commutative80.0%

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

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

        \[\leadsto \left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right) \cdot x.re - \color{blue}{\left(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-out80.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.re + -27\right) + {x.re}^{2} \cdot \left(x.re - 27\right) \]
      5. sub-neg50.0%

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

        \[\leadsto \left(x.re \cdot x.im\right) \cdot \left(x.re + -27\right) + {x.re}^{2} \cdot \left(x.re + \color{blue}{-27}\right) \]
      7. distribute-rgt-out80.0%

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

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

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

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

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

        \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.re - 27\right) + x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)} \]
      2. sub-neg35.0%

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

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

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

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

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

        \[\leadsto {x.re}^{2} \cdot \left(x.re + -27\right) + \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.re + -27\right) \]
      8. distribute-rgt-in80.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq 1.25 \cdot 10^{+203}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.im + x.re\right), \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 91.5% accurate, 0.2× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ \begin{array}{l} \mathbf{if}\;x.re \leq 2 \cdot 10^{+90}:\\ \;\;\;\;{x.re}^{3} + \left(x.im\_m \cdot x.re\right) \cdot \left(x.im\_m \cdot -3\right)\\ \mathbf{elif}\;x.re \leq 1.4 \cdot 10^{+200}:\\ \;\;\;\;x.re \cdot \left(\left(x.re - x.im\_m\right) \cdot \left(x.im\_m + x.re\right)\right) - x.im\_m \cdot \left(\left(x.im\_m \cdot x.re\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im\_m + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
(FPCore (x.re x.im_m)
 :precision binary64
 (if (<= x.re 2e+90)
   (+ (pow x.re 3.0) (* (* x.im_m x.re) (* x.im_m -3.0)))
   (if (<= x.re 1.4e+200)
     (-
      (* x.re (* (- x.re x.im_m) (+ x.im_m x.re)))
      (* x.im_m (* (* x.im_m x.re) 2.0)))
     (* (+ x.im_m x.re) (* x.re (+ x.re -27.0))))))
x.im_m = fabs(x_46_im);
double code(double x_46_re, double x_46_im_m) {
	double tmp;
	if (x_46_re <= 2e+90) {
		tmp = pow(x_46_re, 3.0) + ((x_46_im_m * x_46_re) * (x_46_im_m * -3.0));
	} else if (x_46_re <= 1.4e+200) {
		tmp = (x_46_re * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))) - (x_46_im_m * ((x_46_im_m * x_46_re) * 2.0));
	} else {
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	}
	return tmp;
}
x.im_m = abs(x_46im)
real(8) function code(x_46re, x_46im_m)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re <= 2d+90) then
        tmp = (x_46re ** 3.0d0) + ((x_46im_m * x_46re) * (x_46im_m * (-3.0d0)))
    else if (x_46re <= 1.4d+200) then
        tmp = (x_46re * ((x_46re - x_46im_m) * (x_46im_m + x_46re))) - (x_46im_m * ((x_46im_m * x_46re) * 2.0d0))
    else
        tmp = (x_46im_m + x_46re) * (x_46re * (x_46re + (-27.0d0)))
    end if
    code = tmp
end function
x.im_m = Math.abs(x_46_im);
public static double code(double x_46_re, double x_46_im_m) {
	double tmp;
	if (x_46_re <= 2e+90) {
		tmp = Math.pow(x_46_re, 3.0) + ((x_46_im_m * x_46_re) * (x_46_im_m * -3.0));
	} else if (x_46_re <= 1.4e+200) {
		tmp = (x_46_re * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))) - (x_46_im_m * ((x_46_im_m * x_46_re) * 2.0));
	} else {
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	}
	return tmp;
}
x.im_m = math.fabs(x_46_im)
def code(x_46_re, x_46_im_m):
	tmp = 0
	if x_46_re <= 2e+90:
		tmp = math.pow(x_46_re, 3.0) + ((x_46_im_m * x_46_re) * (x_46_im_m * -3.0))
	elif x_46_re <= 1.4e+200:
		tmp = (x_46_re * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))) - (x_46_im_m * ((x_46_im_m * x_46_re) * 2.0))
	else:
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0))
	return tmp
x.im_m = abs(x_46_im)
function code(x_46_re, x_46_im_m)
	tmp = 0.0
	if (x_46_re <= 2e+90)
		tmp = Float64((x_46_re ^ 3.0) + Float64(Float64(x_46_im_m * x_46_re) * Float64(x_46_im_m * -3.0)));
	elseif (x_46_re <= 1.4e+200)
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re - x_46_im_m) * Float64(x_46_im_m + x_46_re))) - Float64(x_46_im_m * Float64(Float64(x_46_im_m * x_46_re) * 2.0)));
	else
		tmp = Float64(Float64(x_46_im_m + x_46_re) * Float64(x_46_re * Float64(x_46_re + -27.0)));
	end
	return tmp
end
x.im_m = abs(x_46_im);
function tmp_2 = code(x_46_re, x_46_im_m)
	tmp = 0.0;
	if (x_46_re <= 2e+90)
		tmp = (x_46_re ^ 3.0) + ((x_46_im_m * x_46_re) * (x_46_im_m * -3.0));
	elseif (x_46_re <= 1.4e+200)
		tmp = (x_46_re * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))) - (x_46_im_m * ((x_46_im_m * x_46_re) * 2.0));
	else
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	end
	tmp_2 = tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
code[x$46$re_, x$46$im$95$m_] := If[LessEqual[x$46$re, 2e+90], N[(N[Power[x$46$re, 3.0], $MachinePrecision] + N[(N[(x$46$im$95$m * x$46$re), $MachinePrecision] * N[(x$46$im$95$m * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 1.4e+200], N[(N[(x$46$re * N[(N[(x$46$re - x$46$im$95$m), $MachinePrecision] * N[(x$46$im$95$m + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(N[(x$46$im$95$m * x$46$re), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im$95$m + x$46$re), $MachinePrecision] * N[(x$46$re * N[(x$46$re + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x.im_m = \left|x.im\right|

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

\mathbf{elif}\;x.re \leq 1.4 \cdot 10^{+200}:\\
\;\;\;\;x.re \cdot \left(\left(x.re - x.im\_m\right) \cdot \left(x.im\_m + x.re\right)\right) - x.im\_m \cdot \left(\left(x.im\_m \cdot x.re\right) \cdot 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < 1.99999999999999993e90

    1. Initial program 84.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. Simplified83.4%

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999993e90 < x.re < 1.39999999999999992e200

    1. Initial program 83.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. Add Preprocessing
    3. 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 \]
      2. *-commutative100.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. 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 \]
    5. Step-by-step derivation
      1. *-commutative83.3%

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

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

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

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

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

      \[\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 1.39999999999999992e200 < x.re

    1. Initial program 70.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares80.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. Applied egg-rr80.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 \]
    5. Simplified80.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 \]
    6. Step-by-step derivation
      1. *-commutative80.0%

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

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

        \[\leadsto \left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right) \cdot x.re - \color{blue}{\left(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-out80.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.re + -27\right) + {x.re}^{2} \cdot \left(x.re - 27\right) \]
      5. sub-neg50.0%

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

        \[\leadsto \left(x.re \cdot x.im\right) \cdot \left(x.re + -27\right) + {x.re}^{2} \cdot \left(x.re + \color{blue}{-27}\right) \]
      7. distribute-rgt-out80.0%

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

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

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

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

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

        \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.re - 27\right) + x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)} \]
      2. sub-neg35.0%

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

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

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

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

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

        \[\leadsto {x.re}^{2} \cdot \left(x.re + -27\right) + \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.re + -27\right) \]
      8. distribute-rgt-in80.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq 2 \cdot 10^{+90}:\\ \;\;\;\;{x.re}^{3} + \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re \leq 1.4 \cdot 10^{+200}:\\ \;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right) - x.im \cdot \left(\left(x.im \cdot x.re\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 88.7% accurate, 0.9× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ \begin{array}{l} \mathbf{if}\;x.re \leq 1.16 \cdot 10^{+198}:\\ \;\;\;\;x.re \cdot \left(\left(x.re - x.im\_m\right) \cdot \left(x.im\_m + x.re\right)\right) - x.im\_m \cdot \left(\left(x.im\_m \cdot x.re\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im\_m + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
(FPCore (x.re x.im_m)
 :precision binary64
 (if (<= x.re 1.16e+198)
   (-
    (* x.re (* (- x.re x.im_m) (+ x.im_m x.re)))
    (* x.im_m (* (* x.im_m x.re) 2.0)))
   (* (+ x.im_m x.re) (* x.re (+ x.re -27.0)))))
x.im_m = fabs(x_46_im);
double code(double x_46_re, double x_46_im_m) {
	double tmp;
	if (x_46_re <= 1.16e+198) {
		tmp = (x_46_re * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))) - (x_46_im_m * ((x_46_im_m * x_46_re) * 2.0));
	} else {
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	}
	return tmp;
}
x.im_m = abs(x_46im)
real(8) function code(x_46re, x_46im_m)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re <= 1.16d+198) then
        tmp = (x_46re * ((x_46re - x_46im_m) * (x_46im_m + x_46re))) - (x_46im_m * ((x_46im_m * x_46re) * 2.0d0))
    else
        tmp = (x_46im_m + x_46re) * (x_46re * (x_46re + (-27.0d0)))
    end if
    code = tmp
end function
x.im_m = Math.abs(x_46_im);
public static double code(double x_46_re, double x_46_im_m) {
	double tmp;
	if (x_46_re <= 1.16e+198) {
		tmp = (x_46_re * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))) - (x_46_im_m * ((x_46_im_m * x_46_re) * 2.0));
	} else {
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	}
	return tmp;
}
x.im_m = math.fabs(x_46_im)
def code(x_46_re, x_46_im_m):
	tmp = 0
	if x_46_re <= 1.16e+198:
		tmp = (x_46_re * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))) - (x_46_im_m * ((x_46_im_m * x_46_re) * 2.0))
	else:
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0))
	return tmp
x.im_m = abs(x_46_im)
function code(x_46_re, x_46_im_m)
	tmp = 0.0
	if (x_46_re <= 1.16e+198)
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re - x_46_im_m) * Float64(x_46_im_m + x_46_re))) - Float64(x_46_im_m * Float64(Float64(x_46_im_m * x_46_re) * 2.0)));
	else
		tmp = Float64(Float64(x_46_im_m + x_46_re) * Float64(x_46_re * Float64(x_46_re + -27.0)));
	end
	return tmp
end
x.im_m = abs(x_46_im);
function tmp_2 = code(x_46_re, x_46_im_m)
	tmp = 0.0;
	if (x_46_re <= 1.16e+198)
		tmp = (x_46_re * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))) - (x_46_im_m * ((x_46_im_m * x_46_re) * 2.0));
	else
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	end
	tmp_2 = tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
code[x$46$re_, x$46$im$95$m_] := If[LessEqual[x$46$re, 1.16e+198], N[(N[(x$46$re * N[(N[(x$46$re - x$46$im$95$m), $MachinePrecision] * N[(x$46$im$95$m + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(N[(x$46$im$95$m * x$46$re), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im$95$m + x$46$re), $MachinePrecision] * N[(x$46$re * N[(x$46$re + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im_m = \left|x.im\right|

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 1.16 \cdot 10^{+198}:\\
\;\;\;\;x.re \cdot \left(\left(x.re - x.im\_m\right) \cdot \left(x.im\_m + x.re\right)\right) - x.im\_m \cdot \left(\left(x.im\_m \cdot x.re\right) \cdot 2\right)\\

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


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

    1. Initial program 84.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares88.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 \]
      2. *-commutative88.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. Applied egg-rr88.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 \]
    5. Step-by-step derivation
      1. *-commutative55.7%

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

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

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

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

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

      \[\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 1.16000000000000001e198 < x.re

    1. Initial program 70.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares80.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. Applied egg-rr80.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 \]
    5. Simplified80.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 \]
    6. Step-by-step derivation
      1. *-commutative80.0%

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

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

        \[\leadsto \left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right) \cdot x.re - \color{blue}{\left(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-out80.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.re + -27\right) + {x.re}^{2} \cdot \left(x.re - 27\right) \]
      5. sub-neg50.0%

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

        \[\leadsto \left(x.re \cdot x.im\right) \cdot \left(x.re + -27\right) + {x.re}^{2} \cdot \left(x.re + \color{blue}{-27}\right) \]
      7. distribute-rgt-out80.0%

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

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

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

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

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

        \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.re - 27\right) + x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)} \]
      2. sub-neg35.0%

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

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

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

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

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

        \[\leadsto {x.re}^{2} \cdot \left(x.re + -27\right) + \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.re + -27\right) \]
      8. distribute-rgt-in80.0%

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

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

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

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

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

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

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

Alternative 5: 62.4% accurate, 0.9× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ \begin{array}{l} \mathbf{if}\;x.re \leq 4 \cdot 10^{+130}:\\ \;\;\;\;x.re \cdot \left(\left(x.im\_m + x.re\right) \cdot \left(x.re + -27\right) - x.im\_m \cdot \left(x.im\_m \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im\_m + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
(FPCore (x.re x.im_m)
 :precision binary64
 (if (<= x.re 4e+130)
   (* x.re (- (* (+ x.im_m x.re) (+ x.re -27.0)) (* x.im_m (* x.im_m 2.0))))
   (* (+ x.im_m x.re) (* x.re (+ x.re -27.0)))))
x.im_m = fabs(x_46_im);
double code(double x_46_re, double x_46_im_m) {
	double tmp;
	if (x_46_re <= 4e+130) {
		tmp = x_46_re * (((x_46_im_m + x_46_re) * (x_46_re + -27.0)) - (x_46_im_m * (x_46_im_m * 2.0)));
	} else {
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	}
	return tmp;
}
x.im_m = abs(x_46im)
real(8) function code(x_46re, x_46im_m)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re <= 4d+130) then
        tmp = x_46re * (((x_46im_m + x_46re) * (x_46re + (-27.0d0))) - (x_46im_m * (x_46im_m * 2.0d0)))
    else
        tmp = (x_46im_m + x_46re) * (x_46re * (x_46re + (-27.0d0)))
    end if
    code = tmp
end function
x.im_m = Math.abs(x_46_im);
public static double code(double x_46_re, double x_46_im_m) {
	double tmp;
	if (x_46_re <= 4e+130) {
		tmp = x_46_re * (((x_46_im_m + x_46_re) * (x_46_re + -27.0)) - (x_46_im_m * (x_46_im_m * 2.0)));
	} else {
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	}
	return tmp;
}
x.im_m = math.fabs(x_46_im)
def code(x_46_re, x_46_im_m):
	tmp = 0
	if x_46_re <= 4e+130:
		tmp = x_46_re * (((x_46_im_m + x_46_re) * (x_46_re + -27.0)) - (x_46_im_m * (x_46_im_m * 2.0)))
	else:
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0))
	return tmp
x.im_m = abs(x_46_im)
function code(x_46_re, x_46_im_m)
	tmp = 0.0
	if (x_46_re <= 4e+130)
		tmp = Float64(x_46_re * Float64(Float64(Float64(x_46_im_m + x_46_re) * Float64(x_46_re + -27.0)) - Float64(x_46_im_m * Float64(x_46_im_m * 2.0))));
	else
		tmp = Float64(Float64(x_46_im_m + x_46_re) * Float64(x_46_re * Float64(x_46_re + -27.0)));
	end
	return tmp
end
x.im_m = abs(x_46_im);
function tmp_2 = code(x_46_re, x_46_im_m)
	tmp = 0.0;
	if (x_46_re <= 4e+130)
		tmp = x_46_re * (((x_46_im_m + x_46_re) * (x_46_re + -27.0)) - (x_46_im_m * (x_46_im_m * 2.0)));
	else
		tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
	end
	tmp_2 = tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
code[x$46$re_, x$46$im$95$m_] := If[LessEqual[x$46$re, 4e+130], N[(x$46$re * N[(N[(N[(x$46$im$95$m + x$46$re), $MachinePrecision] * N[(x$46$re + -27.0), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(x$46$im$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im$95$m + x$46$re), $MachinePrecision] * N[(x$46$re * N[(x$46$re + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im_m = \left|x.im\right|

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 4 \cdot 10^{+130}:\\
\;\;\;\;x.re \cdot \left(\left(x.im\_m + x.re\right) \cdot \left(x.re + -27\right) - x.im\_m \cdot \left(x.im\_m \cdot 2\right)\right)\\

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


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

    1. Initial program 85.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. 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 \]
    4. 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 \]
    5. Simplified52.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 \]
    6. Step-by-step derivation
      1. *-commutative52.9%

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

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

        \[\leadsto \left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right) \cdot x.re - \color{blue}{\left(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-out52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000002e130 < x.re

    1. Initial program 73.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares89.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. Applied egg-rr89.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 \]
    5. Simplified84.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 \]
    6. Step-by-step derivation
      1. *-commutative84.2%

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

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

        \[\leadsto \left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right) \cdot x.re - \color{blue}{\left(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-out84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.re - 27\right) + x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)} \]
      2. sub-neg36.8%

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

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

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

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

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

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

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

        \[\leadsto \left(x.re + -27\right) \cdot \left(\color{blue}{x.re \cdot x.re} + x.re \cdot x.im\right) \]
      10. distribute-lft-in94.7%

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

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

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

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

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

Alternative 6: 56.9% accurate, 1.5× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ \left(x.re + -27\right) \cdot \left(x.re \cdot \left(x.re \cdot \left(1 + \frac{x.im\_m}{x.re}\right)\right)\right) \end{array} \]
x.im_m = (fabs.f64 x.im)
(FPCore (x.re x.im_m)
 :precision binary64
 (* (+ x.re -27.0) (* x.re (* x.re (+ 1.0 (/ x.im_m x.re))))))
x.im_m = fabs(x_46_im);
double code(double x_46_re, double x_46_im_m) {
	return (x_46_re + -27.0) * (x_46_re * (x_46_re * (1.0 + (x_46_im_m / x_46_re))));
}
x.im_m = abs(x_46im)
real(8) function code(x_46re, x_46im_m)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im_m
    code = (x_46re + (-27.0d0)) * (x_46re * (x_46re * (1.0d0 + (x_46im_m / x_46re))))
end function
x.im_m = Math.abs(x_46_im);
public static double code(double x_46_re, double x_46_im_m) {
	return (x_46_re + -27.0) * (x_46_re * (x_46_re * (1.0 + (x_46_im_m / x_46_re))));
}
x.im_m = math.fabs(x_46_im)
def code(x_46_re, x_46_im_m):
	return (x_46_re + -27.0) * (x_46_re * (x_46_re * (1.0 + (x_46_im_m / x_46_re))))
x.im_m = abs(x_46_im)
function code(x_46_re, x_46_im_m)
	return Float64(Float64(x_46_re + -27.0) * Float64(x_46_re * Float64(x_46_re * Float64(1.0 + Float64(x_46_im_m / x_46_re)))))
end
x.im_m = abs(x_46_im);
function tmp = code(x_46_re, x_46_im_m)
	tmp = (x_46_re + -27.0) * (x_46_re * (x_46_re * (1.0 + (x_46_im_m / x_46_re))));
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
code[x$46$re_, x$46$im$95$m_] := N[(N[(x$46$re + -27.0), $MachinePrecision] * N[(x$46$re * N[(x$46$re * N[(1.0 + N[(x$46$im$95$m / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|

\\
\left(x.re + -27\right) \cdot \left(x.re \cdot \left(x.re \cdot \left(1 + \frac{x.im\_m}{x.re}\right)\right)\right)
\end{array}
Derivation
  1. Initial program 83.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. Add Preprocessing
  3. Step-by-step derivation
    1. difference-of-squares87.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. Applied egg-rr87.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 \]
  5. Simplified57.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 \]
  6. Step-by-step derivation
    1. *-commutative57.6%

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

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

      \[\leadsto \left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right) \cdot x.re - \color{blue}{\left(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-out57.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 53.3% accurate, 2.1× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ \left(x.im\_m + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right) \end{array} \]
x.im_m = (fabs.f64 x.im)
(FPCore (x.re x.im_m)
 :precision binary64
 (* (+ x.im_m x.re) (* x.re (+ x.re -27.0))))
x.im_m = fabs(x_46_im);
double code(double x_46_re, double x_46_im_m) {
	return (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
}
x.im_m = abs(x_46im)
real(8) function code(x_46re, x_46im_m)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im_m
    code = (x_46im_m + x_46re) * (x_46re * (x_46re + (-27.0d0)))
end function
x.im_m = Math.abs(x_46_im);
public static double code(double x_46_re, double x_46_im_m) {
	return (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
}
x.im_m = math.fabs(x_46_im)
def code(x_46_re, x_46_im_m):
	return (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0))
x.im_m = abs(x_46_im)
function code(x_46_re, x_46_im_m)
	return Float64(Float64(x_46_im_m + x_46_re) * Float64(x_46_re * Float64(x_46_re + -27.0)))
end
x.im_m = abs(x_46_im);
function tmp = code(x_46_re, x_46_im_m)
	tmp = (x_46_im_m + x_46_re) * (x_46_re * (x_46_re + -27.0));
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
code[x$46$re_, x$46$im$95$m_] := N[(N[(x$46$im$95$m + x$46$re), $MachinePrecision] * N[(x$46$re * N[(x$46$re + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|

\\
\left(x.im\_m + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right)
\end{array}
Derivation
  1. Initial program 83.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. Add Preprocessing
  3. Step-by-step derivation
    1. difference-of-squares87.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. Applied egg-rr87.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 \]
  5. Simplified57.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 \]
  6. Step-by-step derivation
    1. *-commutative57.6%

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

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

      \[\leadsto \left(\left(x.im + x.re\right) \cdot \left(x.re + -27\right)\right) \cdot x.re - \color{blue}{\left(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-out57.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.re - 27\right) + x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)} \]
    2. sub-neg36.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(x.im + x.re\right) \cdot \left(x.re \cdot \left(x.re + -27\right)\right) \]
  15. Add Preprocessing

Alternative 8: 2.8% accurate, 19.0× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ 8 \end{array} \]
x.im_m = (fabs.f64 x.im)
(FPCore (x.re x.im_m) :precision binary64 8.0)
x.im_m = fabs(x_46_im);
double code(double x_46_re, double x_46_im_m) {
	return 8.0;
}
x.im_m = abs(x_46im)
real(8) function code(x_46re, x_46im_m)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im_m
    code = 8.0d0
end function
x.im_m = Math.abs(x_46_im);
public static double code(double x_46_re, double x_46_im_m) {
	return 8.0;
}
x.im_m = math.fabs(x_46_im)
def code(x_46_re, x_46_im_m):
	return 8.0
x.im_m = abs(x_46_im)
function code(x_46_re, x_46_im_m)
	return 8.0
end
x.im_m = abs(x_46_im);
function tmp = code(x_46_re, x_46_im_m)
	tmp = 8.0;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
code[x$46$re_, x$46$im$95$m_] := 8.0
\begin{array}{l}
x.im_m = \left|x.im\right|

\\
8
\end{array}
Derivation
  1. Initial program 83.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. Simplified81.5%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{8} \]
  7. Add Preprocessing

Developer Target 1: 87.4% 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 2024179 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

  :alt
  (! :herbie-platform default (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3 x.im)))))

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