math.cube on complex, real part

Percentage Accurate: 82.7% → 99.7%
Time: 8.5s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 82.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ \begin{array}{l} t_0 := x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im\_m \cdot x.im\_m\right) - x.im\_m \cdot \left(x.re\_m \cdot x.im\_m + x.re\_m \cdot x.im\_m\right)\\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+78}:\\ \;\;\;\;\mathsf{fma}\left(x.re\_m - x.im\_m, x.re\_m \cdot x.im\_m, x.im\_m \cdot \left(\left(x.re\_m \cdot x.im\_m\right) \cdot -2\right)\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;{x.re\_m}^{3} + x.re\_m \cdot \left(x.im\_m \cdot \left(x.im\_m \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot \left(x.re\_m + x.im\_m \cdot -2\right)\right)\\ \end{array} \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (let* ((t_0
         (-
          (* x.re_m (- (* x.re_m x.re_m) (* x.im_m x.im_m)))
          (* x.im_m (+ (* x.re_m x.im_m) (* x.re_m x.im_m))))))
   (*
    x.re_s
    (if (<= t_0 -1e+78)
      (fma
       (- x.re_m x.im_m)
       (* x.re_m x.im_m)
       (* x.im_m (* (* x.re_m x.im_m) -2.0)))
      (if (<= t_0 INFINITY)
        (+ (pow x.re_m 3.0) (* x.re_m (* x.im_m (* x.im_m -3.0))))
        (* x.im_m (* x.re_m (+ x.re_m (* x.im_m -2.0)))))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double t_0 = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)));
	double tmp;
	if (t_0 <= -1e+78) {
		tmp = fma((x_46_re_m - x_46_im_m), (x_46_re_m * x_46_im_m), (x_46_im_m * ((x_46_re_m * x_46_im_m) * -2.0)));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = pow(x_46_re_m, 3.0) + (x_46_re_m * (x_46_im_m * (x_46_im_m * -3.0)));
	} else {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	t_0 = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im_m * x_46_im_m))) - Float64(x_46_im_m * Float64(Float64(x_46_re_m * x_46_im_m) + Float64(x_46_re_m * x_46_im_m))))
	tmp = 0.0
	if (t_0 <= -1e+78)
		tmp = fma(Float64(x_46_re_m - x_46_im_m), Float64(x_46_re_m * x_46_im_m), Float64(x_46_im_m * Float64(Float64(x_46_re_m * x_46_im_m) * -2.0)));
	elseif (t_0 <= Inf)
		tmp = Float64((x_46_re_m ^ 3.0) + Float64(x_46_re_m * Float64(x_46_im_m * Float64(x_46_im_m * -3.0))));
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * Float64(x_46_re_m + Float64(x_46_im_m * -2.0))));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := Block[{t$95$0 = N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] + N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$46$re$95$s * If[LessEqual[t$95$0, -1e+78], N[(N[(x$46$re$95$m - x$46$im$95$m), $MachinePrecision] * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] + N[(x$46$im$95$m * N[(N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[Power[x$46$re$95$m, 3.0], $MachinePrecision] + N[(x$46$re$95$m * N[(x$46$im$95$m * N[(x$46$im$95$m * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * N[(x$46$re$95$m + N[(x$46$im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
\begin{array}{l}
t_0 := x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im\_m \cdot x.im\_m\right) - x.im\_m \cdot \left(x.re\_m \cdot x.im\_m + x.re\_m \cdot x.im\_m\right)\\
x.re\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(x.re\_m - x.im\_m, x.re\_m \cdot x.im\_m, x.im\_m \cdot \left(\left(x.re\_m \cdot x.im\_m\right) \cdot -2\right)\right)\\

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

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


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

    1. Initial program 89.8%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares89.8%

        \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. *-commutative89.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-rr89.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. Step-by-step derivation
      1. *-commutative89.8%

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

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

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

      \[\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 \]
    7. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.re + x.im\right), x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -2\right)\right)} \]
    9. Taylor expanded in x.re around 0 58.2%

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

    if -1.00000000000000001e78 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) < +inf.0

    1. Initial program 95.8%

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

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

    if +inf.0 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im))

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares24.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. *-commutative24.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-rr24.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. *-commutative24.1%

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

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

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

      \[\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 \]
    7. Taylor expanded in x.re around inf 13.8%

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

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot x.re - 2 \cdot {x.im}^{2}\right)} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-inv34.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 0.1× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im\_m \cdot x.im\_m\right) - x.im\_m \cdot \left(x.re\_m \cdot x.im\_m + x.re\_m \cdot x.im\_m\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(x.re\_m - x.im\_m, x.re\_m \cdot \left(x.re\_m + x.im\_m\right), x.im\_m \cdot \left(\left(x.re\_m \cdot x.im\_m\right) \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot \left(x.re\_m + x.im\_m \cdot -2\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<=
       (-
        (* x.re_m (- (* x.re_m x.re_m) (* x.im_m x.im_m)))
        (* x.im_m (+ (* x.re_m x.im_m) (* x.re_m x.im_m))))
       INFINITY)
    (fma
     (- x.re_m x.im_m)
     (* x.re_m (+ x.re_m x.im_m))
     (* x.im_m (* (* x.re_m x.im_m) -2.0)))
    (* x.im_m (* x.re_m (+ x.re_m (* x.im_m -2.0)))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= ((double) INFINITY)) {
		tmp = fma((x_46_re_m - x_46_im_m), (x_46_re_m * (x_46_re_m + x_46_im_m)), (x_46_im_m * ((x_46_re_m * x_46_im_m) * -2.0)));
	} else {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im_m * x_46_im_m))) - Float64(x_46_im_m * Float64(Float64(x_46_re_m * x_46_im_m) + Float64(x_46_re_m * x_46_im_m)))) <= Inf)
		tmp = fma(Float64(x_46_re_m - x_46_im_m), Float64(x_46_re_m * Float64(x_46_re_m + x_46_im_m)), Float64(x_46_im_m * Float64(Float64(x_46_re_m * x_46_im_m) * -2.0)));
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * Float64(x_46_re_m + Float64(x_46_im_m * -2.0))));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] + N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re$95$m - x$46$im$95$m), $MachinePrecision] * N[(x$46$re$95$m * N[(x$46$re$95$m + x$46$im$95$m), $MachinePrecision]), $MachinePrecision] + N[(x$46$im$95$m * N[(N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * N[(x$46$re$95$m + N[(x$46$im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

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


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

    1. Initial program 94.1%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares94.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. *-commutative94.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-rr94.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. *-commutative94.1%

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

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

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

      \[\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 \]
    7. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

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

    if +inf.0 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im))

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares24.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. *-commutative24.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-rr24.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. *-commutative24.1%

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

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

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

      \[\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 \]
    7. Taylor expanded in x.re around inf 13.8%

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

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot x.re - 2 \cdot {x.im}^{2}\right)} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-inv34.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 93.9% accurate, 0.5× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im\_m \cdot x.im\_m\right) - x.im\_m \cdot \left(x.re\_m \cdot x.im\_m + x.re\_m \cdot x.im\_m\right) \leq \infty:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m + x.im\_m\right)\right) - x.im\_m \cdot \left(\left(x.re\_m \cdot x.im\_m\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot \left(x.re\_m + x.im\_m \cdot -2\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<=
       (-
        (* x.re_m (- (* x.re_m x.re_m) (* x.im_m x.im_m)))
        (* x.im_m (+ (* x.re_m x.im_m) (* x.re_m x.im_m))))
       INFINITY)
    (-
     (* x.re_m (* (- x.re_m x.im_m) (+ x.re_m x.im_m)))
     (* x.im_m (* (* x.re_m x.im_m) 2.0)))
    (* x.im_m (* x.re_m (+ x.re_m (* x.im_m -2.0)))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= ((double) INFINITY)) {
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) * 2.0));
	} else {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	}
	return x_46_re_s * tmp;
}
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= Double.POSITIVE_INFINITY) {
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) * 2.0));
	} else {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if ((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= math.inf:
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) * 2.0))
	else:
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)))
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im_m * x_46_im_m))) - Float64(x_46_im_m * Float64(Float64(x_46_re_m * x_46_im_m) + Float64(x_46_re_m * x_46_im_m)))) <= Inf)
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m - x_46_im_m) * Float64(x_46_re_m + x_46_im_m))) - Float64(x_46_im_m * Float64(Float64(x_46_re_m * x_46_im_m) * 2.0)));
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * Float64(x_46_re_m + Float64(x_46_im_m * -2.0))));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= Inf)
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) * 2.0));
	else
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] + N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m - x$46$im$95$m), $MachinePrecision] * N[(x$46$re$95$m + x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * N[(x$46$re$95$m + N[(x$46$im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

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


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

    1. Initial program 94.1%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares94.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. *-commutative94.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-rr94.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. *-commutative94.1%

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

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

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

      \[\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 +inf.0 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im))

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares24.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. *-commutative24.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-rr24.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. *-commutative24.1%

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

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

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

      \[\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 \]
    7. Taylor expanded in x.re around inf 13.8%

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

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot x.re - 2 \cdot {x.im}^{2}\right)} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-inv34.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 84.7% accurate, 0.9× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \leq 42:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.im\_m \cdot x.im\_m\right) \cdot -3\right)\\ \mathbf{elif}\;x.re\_m \leq 4.5 \cdot 10^{+149}:\\ \;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im\_m \cdot x.im\_m\right) - 0.5\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot \left(x.re\_m + x.im\_m \cdot -2\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 42.0)
    (* x.re_m (* (* x.im_m x.im_m) -3.0))
    (if (<= x.re_m 4.5e+149)
      (- (* x.re_m (- (* x.re_m x.re_m) (* x.im_m x.im_m))) 0.5)
      (* x.im_m (* x.re_m (+ x.re_m (* x.im_m -2.0))))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 42.0) {
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	} else if (x_46_re_m <= 4.5e+149) {
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - 0.5;
	} else {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re_m <= 42.0d0) then
        tmp = x_46re_m * ((x_46im_m * x_46im_m) * (-3.0d0))
    else if (x_46re_m <= 4.5d+149) then
        tmp = (x_46re_m * ((x_46re_m * x_46re_m) - (x_46im_m * x_46im_m))) - 0.5d0
    else
        tmp = x_46im_m * (x_46re_m * (x_46re_m + (x_46im_m * (-2.0d0))))
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 42.0) {
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	} else if (x_46_re_m <= 4.5e+149) {
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - 0.5;
	} else {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_re_m <= 42.0:
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0)
	elif x_46_re_m <= 4.5e+149:
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - 0.5
	else:
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)))
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_re_m <= 42.0)
		tmp = Float64(x_46_re_m * Float64(Float64(x_46_im_m * x_46_im_m) * -3.0));
	elseif (x_46_re_m <= 4.5e+149)
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im_m * x_46_im_m))) - 0.5);
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * Float64(x_46_re_m + Float64(x_46_im_m * -2.0))));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_re_m <= 42.0)
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	elseif (x_46_re_m <= 4.5e+149)
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - 0.5;
	else
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 42.0], N[(x$46$re$95$m * N[(N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re$95$m, 4.5e+149], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * N[(x$46$re$95$m + N[(x$46$im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \begin{array}{l}
\mathbf{if}\;x.re\_m \leq 42:\\
\;\;\;\;x.re\_m \cdot \left(\left(x.im\_m \cdot x.im\_m\right) \cdot -3\right)\\

\mathbf{elif}\;x.re\_m \leq 4.5 \cdot 10^{+149}:\\
\;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im\_m \cdot x.im\_m\right) - 0.5\\

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


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

    1. Initial program 85.1%

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

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

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

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

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

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

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

      \[\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 \]
    7. Taylor expanded in x.re around 0 61.7%

      \[\leadsto \color{blue}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-out--61.7%

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

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

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

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

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

    if 42 < x.re < 4.49999999999999982e149

    1. Initial program 92.8%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative92.8%

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - x.im \cdot \frac{0}{\color{blue}{0}} \]
      6. associate-*r/0.0%

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

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

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

    if 4.49999999999999982e149 < x.re

    1. Initial program 63.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-squares70.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. *-commutative70.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-rr70.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. *-commutative70.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \color{blue}{\left(2 \cdot \left(x.re \cdot x.im\right)\right)} \cdot x.im \]
      3. *-commutative70.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 \]
    6. Applied egg-rr70.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 \]
    7. Taylor expanded in x.re around inf 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 72.4% accurate, 1.4× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \leq 1.8 \cdot 10^{+43}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.im\_m \cdot x.im\_m\right) \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot \left(x.re\_m + x.im\_m \cdot -2\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 1.8e+43)
    (* x.re_m (* (* x.im_m x.im_m) -3.0))
    (* x.im_m (* x.re_m (+ x.re_m (* x.im_m -2.0)))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 1.8e+43) {
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	} else {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re_m <= 1.8d+43) then
        tmp = x_46re_m * ((x_46im_m * x_46im_m) * (-3.0d0))
    else
        tmp = x_46im_m * (x_46re_m * (x_46re_m + (x_46im_m * (-2.0d0))))
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 1.8e+43) {
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	} else {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_re_m <= 1.8e+43:
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0)
	else:
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)))
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_re_m <= 1.8e+43)
		tmp = Float64(x_46_re_m * Float64(Float64(x_46_im_m * x_46_im_m) * -3.0));
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * Float64(x_46_re_m + Float64(x_46_im_m * -2.0))));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_re_m <= 1.8e+43)
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	else
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m + (x_46_im_m * -2.0)));
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 1.8e+43], N[(x$46$re$95$m * N[(N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * N[(x$46$re$95$m + N[(x$46$im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

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


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

    1. Initial program 85.4%

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

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

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

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

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

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

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

      \[\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 \]
    7. Taylor expanded in x.re around 0 62.3%

      \[\leadsto \color{blue}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-out--62.3%

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

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

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

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

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

    if 1.80000000000000005e43 < x.re

    1. Initial program 76.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-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 \]
      2. *-commutative80.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. Step-by-step derivation
      1. *-commutative80.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \color{blue}{\left(2 \cdot \left(x.re \cdot x.im\right)\right)} \cdot x.im \]
      3. *-commutative80.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 \]
    6. Applied egg-rr80.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 \]
    7. Taylor expanded in x.re around inf 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.im \cdot \left(x.re \cdot x.re + \left(-\color{blue}{x.im \cdot 2}\right) \cdot x.re\right) \]
      21. distribute-rgt-out42.6%

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

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

Alternative 6: 68.1% accurate, 1.6× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \leq 1.3 \cdot 10^{+154}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.im\_m \cdot x.im\_m\right) \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_m \cdot x.re\_m\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 1.3e+154)
    (* x.re_m (* (* x.im_m x.im_m) -3.0))
    (* x.re_m x.re_m))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 1.3e+154) {
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	} else {
		tmp = x_46_re_m * x_46_re_m;
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re_m <= 1.3d+154) then
        tmp = x_46re_m * ((x_46im_m * x_46im_m) * (-3.0d0))
    else
        tmp = x_46re_m * x_46re_m
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 1.3e+154) {
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	} else {
		tmp = x_46_re_m * x_46_re_m;
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_re_m <= 1.3e+154:
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0)
	else:
		tmp = x_46_re_m * x_46_re_m
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_re_m <= 1.3e+154)
		tmp = Float64(x_46_re_m * Float64(Float64(x_46_im_m * x_46_im_m) * -3.0));
	else
		tmp = Float64(x_46_re_m * x_46_re_m);
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_re_m <= 1.3e+154)
		tmp = x_46_re_m * ((x_46_im_m * x_46_im_m) * -3.0);
	else
		tmp = x_46_re_m * x_46_re_m;
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 1.3e+154], N[(x$46$re$95$m * N[(N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

\mathbf{else}:\\
\;\;\;\;x.re\_m \cdot x.re\_m\\


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

    1. Initial program 86.1%

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

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

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

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

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

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

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

      \[\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 \]
    7. Taylor expanded in x.re around 0 58.6%

      \[\leadsto \color{blue}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-out--58.6%

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

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

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

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

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

    if 1.29999999999999994e154 < x.re

    1. Initial program 63.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. Simplified63.3%

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

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

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

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

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

      \[\leadsto \color{blue}{x.re \cdot x.re} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 34.3% accurate, 6.3× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \left(x.re\_m \cdot x.re\_m\right) \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (* x.re_s (* x.re_m x.re_m)))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * (x_46_re_m * x_46_re_m);
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    code = x_46re_s * (x_46re_m * x_46re_m)
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * (x_46_re_m * x_46_re_m);
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	return x_46_re_s * (x_46_re_m * x_46_re_m)
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	return Float64(x_46_re_s * Float64(x_46_re_m * x_46_re_m))
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = x_46_re_s * (x_46_re_m * x_46_re_m);
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \left(x.re\_m \cdot x.re\_m\right)
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{x.re \cdot x.re} \]
  7. Add Preprocessing

Alternative 8: 4.4% accurate, 19.0× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot x.re\_m \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m) :precision binary64 (* x.re_s x.re_m))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * x_46_re_m;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    code = x_46re_s * x_46re_m
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * x_46_re_m;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	return x_46_re_s * x_46_re_m
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	return Float64(x_46_re_s * x_46_re_m)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = x_46_re_s * x_46_re_m;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * x$46$re$95$m), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot x.re\_m
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\log x.re\right)} \]
  7. Step-by-step derivation
    1. expm1-undefine2.1%

      \[\leadsto \color{blue}{e^{\log x.re} - 1} \]
    2. rem-exp-log4.0%

      \[\leadsto \color{blue}{x.re} - 1 \]
  8. Simplified4.0%

    \[\leadsto \color{blue}{x.re - 1} \]
  9. Taylor expanded in x.re around inf 4.5%

    \[\leadsto \color{blue}{x.re} \]
  10. Add Preprocessing

Alternative 9: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot 1 \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m) :precision binary64 (* x.re_s 1.0))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * 1.0;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    code = x_46re_s * 1.0d0
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * 1.0;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	return x_46_re_s * 1.0
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	return Float64(x_46_re_s * 1.0)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = x_46_re_s * 1.0;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * 1.0), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot 1
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{x.re}{x.re}} \]
  7. Step-by-step derivation
    1. *-inverses2.5%

      \[\leadsto \color{blue}{1} \]
  8. Simplified2.5%

    \[\leadsto \color{blue}{1} \]
  9. Add Preprocessing

Alternative 10: 2.8% accurate, 19.0× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot -1 \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m) :precision binary64 (* x.re_s -1.0))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * -1.0;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    code = x_46re_s * (-1.0d0)
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * -1.0;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	return x_46_re_s * -1.0
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	return Float64(x_46_re_s * -1.0)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = x_46_re_s * -1.0;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * -1.0), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot -1
\end{array}
Derivation
  1. Initial program 83.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\log x.re\right)} \]
  7. Step-by-step derivation
    1. expm1-undefine2.1%

      \[\leadsto \color{blue}{e^{\log x.re} - 1} \]
    2. rem-exp-log4.0%

      \[\leadsto \color{blue}{x.re} - 1 \]
  8. Simplified4.0%

    \[\leadsto \color{blue}{x.re - 1} \]
  9. Taylor expanded in x.re around 0 2.7%

    \[\leadsto \color{blue}{-1} \]
  10. Add Preprocessing

Developer Target 1: 99.8% 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 2024146 
(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)))