math.cube on complex, real part

Percentage Accurate: 83.0% → 99.8%
Time: 9.1s
Alternatives: 9
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 83.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.2× 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 2 \cdot 10^{+93}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot \left(x.re\_m - x.re\_m\right) - x.im\_m \cdot \left(x.re\_m + x.re\_m \cdot 2\right)\right) + {x.re\_m}^{3}\\ \mathbf{else}:\\ \;\;\;\;x.re\_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 2e+93)
    (+
     (*
      x.im_m
      (- (* x.re_m (- x.re_m x.re_m)) (* x.im_m (+ x.re_m (* x.re_m 2.0)))))
     (pow x.re_m 3.0))
    (* x.re_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 <= 2e+93) {
		tmp = (x_46_im_m * ((x_46_re_m * (x_46_re_m - x_46_re_m)) - (x_46_im_m * (x_46_re_m + (x_46_re_m * 2.0))))) + pow(x_46_re_m, 3.0);
	} else {
		tmp = x_46_re_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 <= 2d+93) then
        tmp = (x_46im_m * ((x_46re_m * (x_46re_m - x_46re_m)) - (x_46im_m * (x_46re_m + (x_46re_m * 2.0d0))))) + (x_46re_m ** 3.0d0)
    else
        tmp = x_46re_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 <= 2e+93) {
		tmp = (x_46_im_m * ((x_46_re_m * (x_46_re_m - x_46_re_m)) - (x_46_im_m * (x_46_re_m + (x_46_re_m * 2.0))))) + Math.pow(x_46_re_m, 3.0);
	} else {
		tmp = x_46_re_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 <= 2e+93:
		tmp = (x_46_im_m * ((x_46_re_m * (x_46_re_m - x_46_re_m)) - (x_46_im_m * (x_46_re_m + (x_46_re_m * 2.0))))) + math.pow(x_46_re_m, 3.0)
	else:
		tmp = x_46_re_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 <= 2e+93)
		tmp = Float64(Float64(x_46_im_m * Float64(Float64(x_46_re_m * Float64(x_46_re_m - x_46_re_m)) - Float64(x_46_im_m * Float64(x_46_re_m + Float64(x_46_re_m * 2.0))))) + (x_46_re_m ^ 3.0));
	else
		tmp = Float64(x_46_re_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 <= 2e+93)
		tmp = (x_46_im_m * ((x_46_re_m * (x_46_re_m - x_46_re_m)) - (x_46_im_m * (x_46_re_m + (x_46_re_m * 2.0))))) + (x_46_re_m ^ 3.0);
	else
		tmp = x_46_re_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, 2e+93], N[(N[(x$46$im$95$m * N[(N[(x$46$re$95$m * N[(x$46$re$95$m - x$46$re$95$m), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(x$46$re$95$m + N[(x$46$re$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[x$46$re$95$m, 3.0], $MachinePrecision]), $MachinePrecision], N[(x$46$re$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 2 \cdot 10^{+93}:\\
\;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot \left(x.re\_m - x.re\_m\right) - x.im\_m \cdot \left(x.re\_m + x.re\_m \cdot 2\right)\right) + {x.re\_m}^{3}\\

\mathbf{else}:\\
\;\;\;\;x.re\_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 < 2.00000000000000009e93

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

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

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

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

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

    if 2.00000000000000009e93 < x.re

    1. Initial program 63.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-squares66.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. *-commutative66.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-rr66.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. Taylor expanded in x.re around 0 66.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.re - x.im\right), 0\right)} \]
    9. Step-by-step derivation
      1. fma-undefine89.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.9% accurate, 0.7× 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 4.7 \cdot 10^{-104}:\\ \;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\ \mathbf{elif}\;x.re\_m \leq 2 \cdot 10^{+90}:\\ \;\;\;\;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(x.re\_m \cdot \left(x.im\_m \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_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 4.7e-104)
    (* (* x.im_m -3.0) (* x.re_m x.im_m))
    (if (<= x.re_m 2e+90)
      (-
       (* 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.re_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 <= 4.7e-104) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else if (x_46_re_m <= 2e+90) {
		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_re_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 <= 4.7d-104) then
        tmp = (x_46im_m * (-3.0d0)) * (x_46re_m * x_46im_m)
    else if (x_46re_m <= 2d+90) then
        tmp = (x_46re_m * ((x_46re_m - x_46im_m) * (x_46re_m + x_46im_m))) - (x_46im_m * (x_46re_m * (x_46im_m * 2.0d0)))
    else
        tmp = x_46re_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 <= 4.7e-104) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else if (x_46_re_m <= 2e+90) {
		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_re_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 <= 4.7e-104:
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m)
	elif x_46_re_m <= 2e+90:
		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_re_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 <= 4.7e-104)
		tmp = Float64(Float64(x_46_im_m * -3.0) * Float64(x_46_re_m * x_46_im_m));
	elseif (x_46_re_m <= 2e+90)
		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(x_46_re_m * Float64(x_46_im_m * 2.0))));
	else
		tmp = Float64(x_46_re_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 <= 4.7e-104)
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	elseif (x_46_re_m <= 2e+90)
		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_re_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, 4.7e-104], N[(N[(x$46$im$95$m * -3.0), $MachinePrecision] * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re$95$m, 2e+90], 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[(x$46$re$95$m * N[(x$46$im$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re$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 4.7 \cdot 10^{-104}:\\
\;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\

\mathbf{elif}\;x.re\_m \leq 2 \cdot 10^{+90}:\\
\;\;\;\;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(x.re\_m \cdot \left(x.im\_m \cdot 2\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x.re\_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 < 4.7e-104

    1. Initial program 79.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. Taylor expanded in x.im around inf 59.2%

      \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(-1 \cdot x.re - 2 \cdot x.re\right)} \]
    4. Applied egg-rr25.1%

      \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right) + \log \left(x.im \cdot -3\right)}} \]
    5. Step-by-step derivation
      1. exp-sum25.1%

        \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)}} \]
      2. rem-exp-log35.9%

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

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      4. rem-exp-log70.2%

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

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

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

    if 4.7e-104 < x.re < 1.99999999999999993e90

    1. Initial program 97.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-squares97.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. *-commutative97.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-rr97.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. Taylor expanded in x.re around 0 97.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.im \cdot x.re\right)\right)} \cdot x.im \]
    6. Step-by-step derivation
      1. associate-*r*97.3%

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

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

    if 1.99999999999999993e90 < x.re

    1. Initial program 65.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-squares67.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. *-commutative67.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-rr67.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. Taylor expanded in x.re around 0 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.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 10^{+91}:\\ \;\;\;\;\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m \cdot \left(x.re\_m + x.im\_m\right)\right) - x.im\_m \cdot \left(x.re\_m \cdot \left(x.im\_m \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_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 1e+91)
    (-
     (* (- 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.re_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 <= 1e+91) {
		tmp = ((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_re_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 <= 1d+91) then
        tmp = ((x_46re_m - x_46im_m) * (x_46re_m * (x_46re_m + x_46im_m))) - (x_46im_m * (x_46re_m * (x_46im_m * 2.0d0)))
    else
        tmp = x_46re_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 <= 1e+91) {
		tmp = ((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_re_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 <= 1e+91:
		tmp = ((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_re_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 <= 1e+91)
		tmp = Float64(Float64(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(x_46_re_m * Float64(x_46_im_m * 2.0))));
	else
		tmp = Float64(x_46_re_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 <= 1e+91)
		tmp = ((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_re_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, 1e+91], N[(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]), $MachinePrecision] - N[(x$46$im$95$m * N[(x$46$re$95$m * N[(x$46$im$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re$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 10^{+91}:\\
\;\;\;\;\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m \cdot \left(x.re\_m + x.im\_m\right)\right) - x.im\_m \cdot \left(x.re\_m \cdot \left(x.im\_m \cdot 2\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x.re\_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.00000000000000008e91

    1. Initial program 82.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot \color{blue}{\left(x.re - x.im\right)} + x.re \cdot \left(x.re - x.im\right)\right) - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      11. distribute-lft-out77.8%

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

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

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

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

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

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

    if 1.00000000000000008e91 < x.re

    1. Initial program 65.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-squares67.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. *-commutative67.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-rr67.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. Taylor expanded in x.re around 0 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 87.6% 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 2.7 \cdot 10^{+48}:\\ \;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_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 2.7e+48)
    (* (* x.im_m -3.0) (* x.re_m x.im_m))
    (* x.re_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 <= 2.7e+48) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else {
		tmp = x_46_re_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 <= 2.7d+48) then
        tmp = (x_46im_m * (-3.0d0)) * (x_46re_m * x_46im_m)
    else
        tmp = x_46re_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 <= 2.7e+48) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else {
		tmp = x_46_re_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 <= 2.7e+48:
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m)
	else:
		tmp = x_46_re_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 <= 2.7e+48)
		tmp = Float64(Float64(x_46_im_m * -3.0) * Float64(x_46_re_m * x_46_im_m));
	else
		tmp = Float64(x_46_re_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 <= 2.7e+48)
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	else
		tmp = x_46_re_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, 2.7e+48], N[(N[(x$46$im$95$m * -3.0), $MachinePrecision] * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision], N[(x$46$re$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 2.7 \cdot 10^{+48}:\\
\;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\

\mathbf{else}:\\
\;\;\;\;x.re\_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 < 2.70000000000000004e48

    1. Initial program 82.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Taylor expanded in x.im around inf 58.8%

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)}} \]
      2. rem-exp-log33.1%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      3. *-commutative33.1%

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      4. rem-exp-log68.4%

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

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

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

    if 2.70000000000000004e48 < x.re

    1. Initial program 68.5%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares70.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. *-commutative70.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-rr70.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. Taylor expanded in x.re around 0 70.3%

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(\left(\color{blue}{\left(-1 \cdot x.im\right) \cdot x.im} + x.re \cdot x.im\right) + x.re \cdot \left(x.re - x.im\right)\right) - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      7. distribute-rgt-in64.8%

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

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot \color{blue}{\left(x.re - x.im\right)} + x.re \cdot \left(x.re - x.im\right)\right) - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      11. distribute-lft-out53.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.re - x.im\right), 0\right)} \]
    9. Step-by-step derivation
      1. fma-undefine87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 92.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 10^{-82}:\\ \;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m + x.im\_m\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 1e-82)
    (* (* x.im_m -3.0) (* x.re_m x.im_m))
    (* x.re_m (* (- x.re_m x.im_m) (+ x.re_m x.im_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 <= 1e-82) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else {
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_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 <= 1d-82) then
        tmp = (x_46im_m * (-3.0d0)) * (x_46re_m * x_46im_m)
    else
        tmp = x_46re_m * ((x_46re_m - x_46im_m) * (x_46re_m + x_46im_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 <= 1e-82) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else {
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_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 <= 1e-82:
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m)
	else:
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_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 <= 1e-82)
		tmp = Float64(Float64(x_46_im_m * -3.0) * Float64(x_46_re_m * x_46_im_m));
	else
		tmp = Float64(x_46_re_m * Float64(Float64(x_46_re_m - x_46_im_m) * Float64(x_46_re_m + x_46_im_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 <= 1e-82)
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	else
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_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, 1e-82], N[(N[(x$46$im$95$m * -3.0), $MachinePrecision] * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision], 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]]), $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 10^{-82}:\\
\;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 1e-82

    1. Initial program 79.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. Taylor expanded in x.im around inf 59.2%

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

      \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right) + \log \left(x.im \cdot -3\right)}} \]
    5. Step-by-step derivation
      1. exp-sum24.5%

        \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)}} \]
      2. rem-exp-log35.7%

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

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      4. rem-exp-log69.9%

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

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

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

    if 1e-82 < x.re

    1. Initial program 78.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. *-commutative78.3%

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - x.im \cdot \frac{\log 1}{\color{blue}{\log 1}} \]
      8. 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 \log 1}{\log 1}} \]
      9. metadata-eval0.0%

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

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

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

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

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

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

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

Alternative 6: 92.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.7 \cdot 10^{-82}:\\ \;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m \cdot \left(x.re\_m + x.im\_m\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.7e-82)
    (* (* x.im_m -3.0) (* x.re_m x.im_m))
    (* (- x.re_m x.im_m) (* x.re_m (+ x.re_m x.im_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.7e-82) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else {
		tmp = (x_46_re_m - x_46_im_m) * (x_46_re_m * (x_46_re_m + x_46_im_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.7d-82) then
        tmp = (x_46im_m * (-3.0d0)) * (x_46re_m * x_46im_m)
    else
        tmp = (x_46re_m - x_46im_m) * (x_46re_m * (x_46re_m + x_46im_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.7e-82) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else {
		tmp = (x_46_re_m - x_46_im_m) * (x_46_re_m * (x_46_re_m + x_46_im_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.7e-82:
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m)
	else:
		tmp = (x_46_re_m - x_46_im_m) * (x_46_re_m * (x_46_re_m + x_46_im_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.7e-82)
		tmp = Float64(Float64(x_46_im_m * -3.0) * Float64(x_46_re_m * x_46_im_m));
	else
		tmp = Float64(Float64(x_46_re_m - x_46_im_m) * Float64(x_46_re_m * Float64(x_46_re_m + x_46_im_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.7e-82)
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	else
		tmp = (x_46_re_m - x_46_im_m) * (x_46_re_m * (x_46_re_m + x_46_im_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.7e-82], N[(N[(x$46$im$95$m * -3.0), $MachinePrecision] * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision], 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]), $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.7 \cdot 10^{-82}:\\
\;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 1.69999999999999988e-82

    1. Initial program 79.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. Taylor expanded in x.im around inf 59.2%

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

      \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right) + \log \left(x.im \cdot -3\right)}} \]
    5. Step-by-step derivation
      1. exp-sum24.5%

        \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)}} \]
      2. rem-exp-log35.7%

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

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      4. rem-exp-log69.9%

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

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

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

    if 1.69999999999999988e-82 < x.re

    1. Initial program 78.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-squares79.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot \color{blue}{\left(x.re - x.im\right)} + x.re \cdot \left(x.re - x.im\right)\right) - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      11. distribute-lft-out67.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - x.im \cdot \frac{\log 1}{\color{blue}{\log 1}} \]
      8. 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 \log 1}{\log 1}} \]
      9. metadata-eval0.0%

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

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

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

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

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

Alternative 7: 55.0% 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 9.2 \cdot 10^{+135}:\\ \;\;\;\;-3 \cdot \left(x.re\_m \cdot \left(x.im\_m \cdot x.im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot x.im\_m\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 9.2e+135)
    (* -3.0 (* x.re_m (* x.im_m x.im_m)))
    (* x.im_m (* x.re_m x.im_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 <= 9.2e+135) {
		tmp = -3.0 * (x_46_re_m * (x_46_im_m * x_46_im_m));
	} else {
		tmp = x_46_im_m * (x_46_re_m * x_46_im_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 <= 9.2d+135) then
        tmp = (-3.0d0) * (x_46re_m * (x_46im_m * x_46im_m))
    else
        tmp = x_46im_m * (x_46re_m * x_46im_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 <= 9.2e+135) {
		tmp = -3.0 * (x_46_re_m * (x_46_im_m * x_46_im_m));
	} else {
		tmp = x_46_im_m * (x_46_re_m * x_46_im_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 <= 9.2e+135:
		tmp = -3.0 * (x_46_re_m * (x_46_im_m * x_46_im_m))
	else:
		tmp = x_46_im_m * (x_46_re_m * x_46_im_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 <= 9.2e+135)
		tmp = Float64(-3.0 * Float64(x_46_re_m * Float64(x_46_im_m * x_46_im_m)));
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * x_46_im_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 <= 9.2e+135)
		tmp = -3.0 * (x_46_re_m * (x_46_im_m * x_46_im_m));
	else
		tmp = x_46_im_m * (x_46_re_m * x_46_im_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, 9.2e+135], N[(-3.0 * N[(x$46$re$95$m * N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * x$46$im$95$m), $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 9.2 \cdot 10^{+135}:\\
\;\;\;\;-3 \cdot \left(x.re\_m \cdot \left(x.im\_m \cdot x.im\_m\right)\right)\\

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


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

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.2000000000000005e135 < x.re

    1. Initial program 59.5%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Taylor expanded in x.im around inf 5.3%

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)}} \]
      2. rem-exp-log2.7%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      3. *-commutative2.7%

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      4. rem-exp-log5.3%

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

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

      \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot \left(-3 \cdot x.im\right)} \]
    7. Step-by-step derivation
      1. associate-*l*5.3%

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

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

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

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

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

        \[\leadsto x.im \cdot \left(x.im \cdot \left(x.re \cdot \color{blue}{\left(-1 - 2\right)}\right)\right) \]
      7. distribute-rgt-out--5.3%

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

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

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

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

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

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

Alternative 8: 60.9% 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 9.2 \cdot 10^{+135}:\\ \;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot x.im\_m\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 9.2e+135)
    (* (* x.im_m -3.0) (* x.re_m x.im_m))
    (* x.im_m (* x.re_m x.im_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 <= 9.2e+135) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else {
		tmp = x_46_im_m * (x_46_re_m * x_46_im_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 <= 9.2d+135) then
        tmp = (x_46im_m * (-3.0d0)) * (x_46re_m * x_46im_m)
    else
        tmp = x_46im_m * (x_46re_m * x_46im_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 <= 9.2e+135) {
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	} else {
		tmp = x_46_im_m * (x_46_re_m * x_46_im_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 <= 9.2e+135:
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m)
	else:
		tmp = x_46_im_m * (x_46_re_m * x_46_im_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 <= 9.2e+135)
		tmp = Float64(Float64(x_46_im_m * -3.0) * Float64(x_46_re_m * x_46_im_m));
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * x_46_im_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 <= 9.2e+135)
		tmp = (x_46_im_m * -3.0) * (x_46_re_m * x_46_im_m);
	else
		tmp = x_46_im_m * (x_46_re_m * x_46_im_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, 9.2e+135], N[(N[(x$46$im$95$m * -3.0), $MachinePrecision] * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * x$46$im$95$m), $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 9.2 \cdot 10^{+135}:\\
\;\;\;\;\left(x.im\_m \cdot -3\right) \cdot \left(x.re\_m \cdot x.im\_m\right)\\

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


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

    1. Initial program 83.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Taylor expanded in x.im around inf 57.6%

      \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(-1 \cdot x.re - 2 \cdot x.re\right)} \]
    4. Applied egg-rr19.8%

      \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right) + \log \left(x.im \cdot -3\right)}} \]
    5. Step-by-step derivation
      1. exp-sum19.8%

        \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)}} \]
      2. rem-exp-log32.4%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      3. *-commutative32.4%

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      4. rem-exp-log66.6%

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

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

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

    if 9.2000000000000005e135 < x.re

    1. Initial program 59.5%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Taylor expanded in x.im around inf 5.3%

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)}} \]
      2. rem-exp-log2.7%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      3. *-commutative2.7%

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
      4. rem-exp-log5.3%

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

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

      \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot \left(-3 \cdot x.im\right)} \]
    7. Step-by-step derivation
      1. associate-*l*5.3%

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

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

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

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

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

        \[\leadsto x.im \cdot \left(x.im \cdot \left(x.re \cdot \color{blue}{\left(-1 - 2\right)}\right)\right) \]
      7. distribute-rgt-out--5.3%

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

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

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

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

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

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

Alternative 9: 24.0% accurate, 3.8× 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.im\_m \cdot \left(x.re\_m \cdot x.im\_m\right)\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.im_m (* x.re_m x.im_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_im_m * (x_46_re_m * x_46_im_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_46im_m * (x_46re_m * x_46im_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_im_m * (x_46_re_m * x_46_im_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_im_m * (x_46_re_m * x_46_im_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_im_m * Float64(x_46_re_m * x_46_im_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_im_m * (x_46_re_m * x_46_im_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$im$95$m * N[(x$46$re$95$m * x$46$im$95$m), $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 \left(x.im\_m \cdot \left(x.re\_m \cdot x.im\_m\right)\right)
\end{array}
Derivation
  1. Initial program 79.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. Taylor expanded in x.im around inf 49.0%

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

    \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right) + \log \left(x.im \cdot -3\right)}} \]
  5. Step-by-step derivation
    1. exp-sum16.6%

      \[\leadsto \color{blue}{e^{\log \left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)}} \]
    2. rem-exp-log27.5%

      \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
    3. *-commutative27.5%

      \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot e^{\log \left(x.im \cdot -3\right)} \]
    4. rem-exp-log56.6%

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

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

    \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot \left(-3 \cdot x.im\right)} \]
  7. Step-by-step derivation
    1. associate-*l*56.6%

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

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

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

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

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

      \[\leadsto x.im \cdot \left(x.im \cdot \left(x.re \cdot \color{blue}{\left(-1 - 2\right)}\right)\right) \]
    7. distribute-rgt-out--56.6%

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

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.im\right)} \]
  10. Simplified26.9%

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

    \[\leadsto x.im \cdot \left(x.re \cdot x.im\right) \]
  12. Add Preprocessing

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

  :alt
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im))))

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