math.cube on complex, real part

Percentage Accurate: 83.0% → 96.4%
Time: 10.2s
Alternatives: 11
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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: 96.4% accurate, 0.7× speedup?

\[\begin{array}{l} 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.4 \cdot 10^{-105}:\\ \;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re\_m \leq 1.8 \cdot 10^{+203}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m - x.im\right) \cdot \left(x.re\_m + x.im\right)\right) - x.im \cdot \left(x.re\_m \cdot x.im + x.re\_m \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m + x.im\right) \cdot \left(x.re\_m + -27\right)\right) - x.im\\ \end{array} \end{array} \]
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)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 4.4e-105)
    (* (* x.re_m x.im) (* x.im -3.0))
    (if (<= x.re_m 1.8e+203)
      (-
       (* x.re_m (* (- x.re_m x.im) (+ x.re_m x.im)))
       (* x.im (+ (* x.re_m x.im) (* x.re_m x.im))))
      (- (* x.re_m (* (+ x.re_m x.im) (+ x.re_m -27.0))) x.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) {
	double tmp;
	if (x_46_re_m <= 4.4e-105) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 1.8e+203) {
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im) * (x_46_re_m + x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) + (x_46_re_m * x_46_im)));
	} else {
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	}
	return x_46_re_s * tmp;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re_m <= 4.4d-105) then
        tmp = (x_46re_m * x_46im) * (x_46im * (-3.0d0))
    else if (x_46re_m <= 1.8d+203) then
        tmp = (x_46re_m * ((x_46re_m - x_46im) * (x_46re_m + x_46im))) - (x_46im * ((x_46re_m * x_46im) + (x_46re_m * x_46im)))
    else
        tmp = (x_46re_m * ((x_46re_m + x_46im) * (x_46re_m + (-27.0d0)))) - x_46im
    end if
    code = x_46re_s * tmp
end function
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) {
	double tmp;
	if (x_46_re_m <= 4.4e-105) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 1.8e+203) {
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im) * (x_46_re_m + x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) + (x_46_re_m * x_46_im)));
	} else {
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	}
	return x_46_re_s * tmp;
}
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):
	tmp = 0
	if x_46_re_m <= 4.4e-105:
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0)
	elif x_46_re_m <= 1.8e+203:
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im) * (x_46_re_m + x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) + (x_46_re_m * x_46_im)))
	else:
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im
	return x_46_re_s * tmp
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)
	tmp = 0.0
	if (x_46_re_m <= 4.4e-105)
		tmp = Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0));
	elseif (x_46_re_m <= 1.8e+203)
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m - x_46_im) * Float64(x_46_re_m + x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re_m * x_46_im) + Float64(x_46_re_m * x_46_im))));
	else
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m + x_46_im) * Float64(x_46_re_m + -27.0))) - x_46_im);
	end
	return Float64(x_46_re_s * tmp)
end
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)
	tmp = 0.0;
	if (x_46_re_m <= 4.4e-105)
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	elseif (x_46_re_m <= 1.8e+203)
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im) * (x_46_re_m + x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) + (x_46_re_m * x_46_im)));
	else
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	end
	tmp_2 = x_46_re_s * tmp;
end
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_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 4.4e-105], N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re$95$m, 1.8e+203], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m - x$46$im), $MachinePrecision] * N[(x$46$re$95$m + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] + N[(x$46$re$95$m * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m + x$46$im), $MachinePrecision] * N[(x$46$re$95$m + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x$46$im), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
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.4 \cdot 10^{-105}:\\
\;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\

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

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


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

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

      \[\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*83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.im \cdot x.re\right) + \log \left(x.im \cdot -3\right)}} \]
    12. Applied egg-rr26.9%

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

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

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

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

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

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

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

    if 4.40000000000000008e-105 < x.re < 1.79999999999999991e203

    1. Initial program 98.1%

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

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

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

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

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

    if 1.79999999999999991e203 < x.re

    1. Initial program 48.4%

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-undefine61.3%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(e^{\mathsf{log1p}\left(x.im\right)} - 1\right)} \]
      2. log1p-undefine61.3%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(\color{blue}{\left(x.im + 1\right)} - 1\right) \]
      5. associate--l+71.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq 4.4 \cdot 10^{-105}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re \leq 1.8 \cdot 10^{+203}:\\ \;\;\;\;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 x.im + x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re + -27\right)\right) - x.im\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 96.1% accurate, 0.2× speedup?

\[\begin{array}{l} x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im \cdot x.im\right) - x.im \cdot \left(x.re\_m \cdot x.im + x.re\_m \cdot x.im\right) \leq -5 \cdot 10^{-300}:\\ \;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;{x.re\_m}^{3}\\ \end{array} \end{array} \]
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)
 :precision binary64
 (*
  x.re_s
  (if (<=
       (-
        (* x.re_m (- (* x.re_m x.re_m) (* x.im x.im)))
        (* x.im (+ (* x.re_m x.im) (* x.re_m x.im))))
       -5e-300)
    (* (* x.re_m x.im) (* x.im -3.0))
    (pow x.re_m 3.0))))
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) {
	double tmp;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) + (x_46_re_m * x_46_im)))) <= -5e-300) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else {
		tmp = pow(x_46_re_m, 3.0);
	}
	return x_46_re_s * tmp;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (((x_46re_m * ((x_46re_m * x_46re_m) - (x_46im * x_46im))) - (x_46im * ((x_46re_m * x_46im) + (x_46re_m * x_46im)))) <= (-5d-300)) then
        tmp = (x_46re_m * x_46im) * (x_46im * (-3.0d0))
    else
        tmp = x_46re_m ** 3.0d0
    end if
    code = x_46re_s * tmp
end function
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) {
	double tmp;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) + (x_46_re_m * x_46_im)))) <= -5e-300) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else {
		tmp = Math.pow(x_46_re_m, 3.0);
	}
	return x_46_re_s * tmp;
}
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):
	tmp = 0
	if ((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) + (x_46_re_m * x_46_im)))) <= -5e-300:
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0)
	else:
		tmp = math.pow(x_46_re_m, 3.0)
	return x_46_re_s * tmp
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)
	tmp = 0.0
	if (Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re_m * x_46_im) + Float64(x_46_re_m * x_46_im)))) <= -5e-300)
		tmp = Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0));
	else
		tmp = x_46_re_m ^ 3.0;
	end
	return Float64(x_46_re_s * tmp)
end
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)
	tmp = 0.0;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) + (x_46_re_m * x_46_im)))) <= -5e-300)
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	else
		tmp = x_46_re_m ^ 3.0;
	end
	tmp_2 = x_46_re_s * tmp;
end
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_] := N[(x$46$re$95$s * If[LessEqual[N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] + N[(x$46$re$95$m * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-300], N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[Power[x$46$re$95$m, 3.0], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

\mathbf{else}:\\
\;\;\;\;{x.re\_m}^{3}\\


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

    1. Initial program 94.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999996e-300 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im))

    1. Initial program 77.5%

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

        \[\leadsto \left(\color{blue}{\left(-x.re\right) \cdot \left(-x.re\right)} - 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. *-commutative77.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, x.im \cdot \left(-2 \cdot \left(x.re \cdot x.im\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x.re around inf 72.5%

      \[\leadsto \color{blue}{{x.re}^{3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.6%

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

Alternative 3: 97.2% accurate, 0.7× speedup?

\[\begin{array}{l} 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^{-105}:\\ \;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re\_m \leq 2.8 \cdot 10^{+135}:\\ \;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im \cdot x.im\right) - x.im \cdot \left(\left(x.re\_m \cdot x.im\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;x.im + x.re\_m \cdot \left(\left(x.re\_m + x.im\right) \cdot \left(x.re\_m + -27\right)\right)\\ \end{array} \end{array} \]
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)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 4.7e-105)
    (* (* x.re_m x.im) (* x.im -3.0))
    (if (<= x.re_m 2.8e+135)
      (-
       (* x.re_m (- (* x.re_m x.re_m) (* x.im x.im)))
       (* x.im (* (* x.re_m x.im) 2.0)))
      (+ x.im (* x.re_m (* (+ x.re_m x.im) (+ x.re_m -27.0))))))))
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) {
	double tmp;
	if (x_46_re_m <= 4.7e-105) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 2.8e+135) {
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) * 2.0));
	} else {
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0)));
	}
	return x_46_re_s * tmp;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re_m <= 4.7d-105) then
        tmp = (x_46re_m * x_46im) * (x_46im * (-3.0d0))
    else if (x_46re_m <= 2.8d+135) then
        tmp = (x_46re_m * ((x_46re_m * x_46re_m) - (x_46im * x_46im))) - (x_46im * ((x_46re_m * x_46im) * 2.0d0))
    else
        tmp = x_46im + (x_46re_m * ((x_46re_m + x_46im) * (x_46re_m + (-27.0d0))))
    end if
    code = x_46re_s * tmp
end function
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) {
	double tmp;
	if (x_46_re_m <= 4.7e-105) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 2.8e+135) {
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) * 2.0));
	} else {
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0)));
	}
	return x_46_re_s * tmp;
}
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):
	tmp = 0
	if x_46_re_m <= 4.7e-105:
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0)
	elif x_46_re_m <= 2.8e+135:
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) * 2.0))
	else:
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0)))
	return x_46_re_s * tmp
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)
	tmp = 0.0
	if (x_46_re_m <= 4.7e-105)
		tmp = Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0));
	elseif (x_46_re_m <= 2.8e+135)
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re_m * x_46_im) * 2.0)));
	else
		tmp = Float64(x_46_im + Float64(x_46_re_m * Float64(Float64(x_46_re_m + x_46_im) * Float64(x_46_re_m + -27.0))));
	end
	return Float64(x_46_re_s * tmp)
end
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)
	tmp = 0.0;
	if (x_46_re_m <= 4.7e-105)
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	elseif (x_46_re_m <= 2.8e+135)
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re_m * x_46_im) * 2.0));
	else
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0)));
	end
	tmp_2 = x_46_re_s * tmp;
end
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_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 4.7e-105], N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re$95$m, 2.8e+135], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im + N[(x$46$re$95$m * N[(N[(x$46$re$95$m + x$46$im), $MachinePrecision] * N[(x$46$re$95$m + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
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^{-105}:\\
\;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\

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

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


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

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

      \[\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*83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.im \cdot x.re\right) + \log \left(x.im \cdot -3\right)}} \]
    12. Applied egg-rr26.9%

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

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

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

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

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

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

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

    if 4.69999999999999986e-105 < x.re < 2.80000000000000002e135

    1. Initial program 99.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.re around 0 99.8%

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

    if 2.80000000000000002e135 < x.re

    1. Initial program 58.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. *-commutative58.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 91.0% accurate, 0.8× speedup?

\[\begin{array}{l} 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 5.4 \cdot 10^{-101}:\\ \;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re\_m \leq 3.4 \cdot 10^{+145}:\\ \;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im \cdot x.im\right) + x.im \cdot 0\\ \mathbf{else}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m + x.im\right) \cdot \left(x.re\_m + -27\right)\right) - x.im\\ \end{array} \end{array} \]
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)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 5.4e-101)
    (* (* x.re_m x.im) (* x.im -3.0))
    (if (<= x.re_m 3.4e+145)
      (+ (* x.re_m (- (* x.re_m x.re_m) (* x.im x.im))) (* x.im 0.0))
      (- (* x.re_m (* (+ x.re_m x.im) (+ x.re_m -27.0))) x.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) {
	double tmp;
	if (x_46_re_m <= 5.4e-101) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 3.4e+145) {
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) + (x_46_im * 0.0);
	} else {
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	}
	return x_46_re_s * tmp;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re_m <= 5.4d-101) then
        tmp = (x_46re_m * x_46im) * (x_46im * (-3.0d0))
    else if (x_46re_m <= 3.4d+145) then
        tmp = (x_46re_m * ((x_46re_m * x_46re_m) - (x_46im * x_46im))) + (x_46im * 0.0d0)
    else
        tmp = (x_46re_m * ((x_46re_m + x_46im) * (x_46re_m + (-27.0d0)))) - x_46im
    end if
    code = x_46re_s * tmp
end function
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) {
	double tmp;
	if (x_46_re_m <= 5.4e-101) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 3.4e+145) {
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) + (x_46_im * 0.0);
	} else {
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	}
	return x_46_re_s * tmp;
}
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):
	tmp = 0
	if x_46_re_m <= 5.4e-101:
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0)
	elif x_46_re_m <= 3.4e+145:
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) + (x_46_im * 0.0)
	else:
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im
	return x_46_re_s * tmp
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)
	tmp = 0.0
	if (x_46_re_m <= 5.4e-101)
		tmp = Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0));
	elseif (x_46_re_m <= 3.4e+145)
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im * x_46_im))) + Float64(x_46_im * 0.0));
	else
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m + x_46_im) * Float64(x_46_re_m + -27.0))) - x_46_im);
	end
	return Float64(x_46_re_s * tmp)
end
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)
	tmp = 0.0;
	if (x_46_re_m <= 5.4e-101)
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	elseif (x_46_re_m <= 3.4e+145)
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) + (x_46_im * 0.0);
	else
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	end
	tmp_2 = x_46_re_s * tmp;
end
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_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 5.4e-101], N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re$95$m, 3.4e+145], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$im * 0.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m + x$46$im), $MachinePrecision] * N[(x$46$re$95$m + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x$46$im), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
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 5.4 \cdot 10^{-101}:\\
\;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\

\mathbf{elif}\;x.re\_m \leq 3.4 \cdot 10^{+145}:\\
\;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im \cdot x.im\right) + x.im \cdot 0\\

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


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

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

      \[\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*83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.im \cdot x.re\right) + \log \left(x.im \cdot -3\right)}} \]
    12. Applied egg-rr26.9%

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

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

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

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

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

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

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

    if 5.4000000000000003e-101 < x.re < 3.3999999999999999e145

    1. Initial program 99.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. *-commutative99.8%

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

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

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

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

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

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

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

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

    if 3.3999999999999999e145 < x.re

    1. Initial program 57.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. *-commutative57.5%

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-undefine67.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(e^{\mathsf{log1p}\left(x.im\right)} - 1\right)} \]
      2. log1p-undefine67.5%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(\color{blue}{\left(x.im + 1\right)} - 1\right) \]
      5. associate--l+75.0%

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

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

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

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

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

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

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

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

Alternative 5: 90.2% accurate, 0.9× speedup?

\[\begin{array}{l} 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.85 \cdot 10^{-16}:\\ \;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re\_m \leq 3.4 \cdot 10^{+145}:\\ \;\;\;\;x.im + x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m + x.im\right) \cdot \left(x.re\_m + -27\right)\right) - x.im\\ \end{array} \end{array} \]
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)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 1.85e-16)
    (* (* x.re_m x.im) (* x.im -3.0))
    (if (<= x.re_m 3.4e+145)
      (+ x.im (* x.re_m (- (* x.re_m x.re_m) (* x.im x.im))))
      (- (* x.re_m (* (+ x.re_m x.im) (+ x.re_m -27.0))) x.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) {
	double tmp;
	if (x_46_re_m <= 1.85e-16) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 3.4e+145) {
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im)));
	} else {
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	}
	return x_46_re_s * tmp;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re_m <= 1.85d-16) then
        tmp = (x_46re_m * x_46im) * (x_46im * (-3.0d0))
    else if (x_46re_m <= 3.4d+145) then
        tmp = x_46im + (x_46re_m * ((x_46re_m * x_46re_m) - (x_46im * x_46im)))
    else
        tmp = (x_46re_m * ((x_46re_m + x_46im) * (x_46re_m + (-27.0d0)))) - x_46im
    end if
    code = x_46re_s * tmp
end function
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) {
	double tmp;
	if (x_46_re_m <= 1.85e-16) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 3.4e+145) {
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im)));
	} else {
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	}
	return x_46_re_s * tmp;
}
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):
	tmp = 0
	if x_46_re_m <= 1.85e-16:
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0)
	elif x_46_re_m <= 3.4e+145:
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im)))
	else:
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im
	return x_46_re_s * tmp
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)
	tmp = 0.0
	if (x_46_re_m <= 1.85e-16)
		tmp = Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0));
	elseif (x_46_re_m <= 3.4e+145)
		tmp = Float64(x_46_im + Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im * x_46_im))));
	else
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m + x_46_im) * Float64(x_46_re_m + -27.0))) - x_46_im);
	end
	return Float64(x_46_re_s * tmp)
end
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)
	tmp = 0.0;
	if (x_46_re_m <= 1.85e-16)
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	elseif (x_46_re_m <= 3.4e+145)
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im)));
	else
		tmp = (x_46_re_m * ((x_46_re_m + x_46_im) * (x_46_re_m + -27.0))) - x_46_im;
	end
	tmp_2 = x_46_re_s * tmp;
end
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_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 1.85e-16], N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re$95$m, 3.4e+145], N[(x$46$im + N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m + x$46$im), $MachinePrecision] * N[(x$46$re$95$m + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x$46$im), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
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.85 \cdot 10^{-16}:\\
\;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\

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

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


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

    1. Initial program 86.4%

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

      \[\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*84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.im \cdot x.re\right) + \log \left(x.im \cdot -3\right)}} \]
    12. Applied egg-rr25.3%

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

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

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

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

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

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

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

    if 1.85e-16 < x.re < 3.3999999999999999e145

    1. Initial program 99.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. *-commutative99.8%

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

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

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

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

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

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

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

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

    if 3.3999999999999999e145 < x.re

    1. Initial program 57.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. *-commutative57.5%

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-undefine67.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(e^{\mathsf{log1p}\left(x.im\right)} - 1\right)} \]
      2. log1p-undefine67.5%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(\color{blue}{\left(x.im + 1\right)} - 1\right) \]
      5. associate--l+75.0%

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

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

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

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

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

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

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

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

Alternative 6: 79.0% accurate, 0.9× speedup?

\[\begin{array}{l} 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.85 \cdot 10^{-16}:\\ \;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re\_m \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;x.im + x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re\_m \cdot \left(x.re\_m - 27\right) + -1\right)\\ \end{array} \end{array} \]
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)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 1.85e-16)
    (* (* x.re_m x.im) (* x.im -3.0))
    (if (<= x.re_m 1.35e+154)
      (+ x.im (* x.re_m (- (* x.re_m x.re_m) (* x.im x.im))))
      (* x.im (+ (* x.re_m (- x.re_m 27.0)) -1.0))))))
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) {
	double tmp;
	if (x_46_re_m <= 1.85e-16) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 1.35e+154) {
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im)));
	} else {
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	}
	return x_46_re_s * tmp;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re_m <= 1.85d-16) then
        tmp = (x_46re_m * x_46im) * (x_46im * (-3.0d0))
    else if (x_46re_m <= 1.35d+154) then
        tmp = x_46im + (x_46re_m * ((x_46re_m * x_46re_m) - (x_46im * x_46im)))
    else
        tmp = x_46im * ((x_46re_m * (x_46re_m - 27.0d0)) + (-1.0d0))
    end if
    code = x_46re_s * tmp
end function
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) {
	double tmp;
	if (x_46_re_m <= 1.85e-16) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 1.35e+154) {
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im)));
	} else {
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	}
	return x_46_re_s * tmp;
}
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):
	tmp = 0
	if x_46_re_m <= 1.85e-16:
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0)
	elif x_46_re_m <= 1.35e+154:
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im)))
	else:
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0)
	return x_46_re_s * tmp
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)
	tmp = 0.0
	if (x_46_re_m <= 1.85e-16)
		tmp = Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0));
	elseif (x_46_re_m <= 1.35e+154)
		tmp = Float64(x_46_im + Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im * x_46_im))));
	else
		tmp = Float64(x_46_im * Float64(Float64(x_46_re_m * Float64(x_46_re_m - 27.0)) + -1.0));
	end
	return Float64(x_46_re_s * tmp)
end
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)
	tmp = 0.0;
	if (x_46_re_m <= 1.85e-16)
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	elseif (x_46_re_m <= 1.35e+154)
		tmp = x_46_im + (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im)));
	else
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	end
	tmp_2 = x_46_re_s * tmp;
end
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_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 1.85e-16], N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re$95$m, 1.35e+154], N[(x$46$im + N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re$95$m * N[(x$46$re$95$m - 27.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
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.85 \cdot 10^{-16}:\\
\;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\

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

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


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

    1. Initial program 86.4%

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

      \[\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*84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.im \cdot x.re\right) + \log \left(x.im \cdot -3\right)}} \]
    12. Applied egg-rr25.3%

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

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

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

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

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

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

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

    if 1.85e-16 < x.re < 1.35000000000000003e154

    1. Initial program 99.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. *-commutative99.8%

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

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

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

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

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

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

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

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

    if 1.35000000000000003e154 < x.re

    1. Initial program 56.4%

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-undefine66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(e^{\mathsf{log1p}\left(x.im\right)} - 1\right)} \]
      2. log1p-undefine66.7%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(\color{blue}{\left(x.im + 1\right)} - 1\right) \]
      5. associate--l+74.4%

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

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

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

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

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

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

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

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

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

Alternative 7: 78.9% accurate, 0.9× speedup?

\[\begin{array}{l} 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.55 \cdot 10^{-15}:\\ \;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re\_m \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im \cdot x.im\right) - x.im\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re\_m \cdot \left(x.re\_m - 27\right) + -1\right)\\ \end{array} \end{array} \]
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)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 2.55e-15)
    (* (* x.re_m x.im) (* x.im -3.0))
    (if (<= x.re_m 1.35e+154)
      (- (* x.re_m (- (* x.re_m x.re_m) (* x.im x.im))) x.im)
      (* x.im (+ (* x.re_m (- x.re_m 27.0)) -1.0))))))
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) {
	double tmp;
	if (x_46_re_m <= 2.55e-15) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 1.35e+154) {
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - x_46_im;
	} else {
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	}
	return x_46_re_s * tmp;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re_m <= 2.55d-15) then
        tmp = (x_46re_m * x_46im) * (x_46im * (-3.0d0))
    else if (x_46re_m <= 1.35d+154) then
        tmp = (x_46re_m * ((x_46re_m * x_46re_m) - (x_46im * x_46im))) - x_46im
    else
        tmp = x_46im * ((x_46re_m * (x_46re_m - 27.0d0)) + (-1.0d0))
    end if
    code = x_46re_s * tmp
end function
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) {
	double tmp;
	if (x_46_re_m <= 2.55e-15) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else if (x_46_re_m <= 1.35e+154) {
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - x_46_im;
	} else {
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	}
	return x_46_re_s * tmp;
}
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):
	tmp = 0
	if x_46_re_m <= 2.55e-15:
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0)
	elif x_46_re_m <= 1.35e+154:
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - x_46_im
	else:
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0)
	return x_46_re_s * tmp
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)
	tmp = 0.0
	if (x_46_re_m <= 2.55e-15)
		tmp = Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0));
	elseif (x_46_re_m <= 1.35e+154)
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im * x_46_im))) - x_46_im);
	else
		tmp = Float64(x_46_im * Float64(Float64(x_46_re_m * Float64(x_46_re_m - 27.0)) + -1.0));
	end
	return Float64(x_46_re_s * tmp)
end
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)
	tmp = 0.0;
	if (x_46_re_m <= 2.55e-15)
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	elseif (x_46_re_m <= 1.35e+154)
		tmp = (x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im * x_46_im))) - x_46_im;
	else
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	end
	tmp_2 = x_46_re_s * tmp;
end
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_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 2.55e-15], N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re$95$m, 1.35e+154], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x$46$im), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re$95$m * N[(x$46$re$95$m - 27.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
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.55 \cdot 10^{-15}:\\
\;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\

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

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


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

    1. Initial program 86.4%

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

      \[\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*84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(x.im \cdot x.re\right) + \log \left(x.im \cdot -3\right)}} \]
    12. Applied egg-rr25.3%

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

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

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

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

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

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

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

    if 2.55e-15 < x.re < 1.35000000000000003e154

    1. Initial program 99.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. *-commutative99.8%

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-undefine64.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(e^{\mathsf{log1p}\left(x.im\right)} - 1\right)} \]
      2. log1p-undefine64.8%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(\color{blue}{\left(x.im + 1\right)} - 1\right) \]
      5. associate--l+96.8%

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

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

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

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

    if 1.35000000000000003e154 < x.re

    1. Initial program 56.4%

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-undefine66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(e^{\mathsf{log1p}\left(x.im\right)} - 1\right)} \]
      2. log1p-undefine66.7%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(\color{blue}{\left(x.im + 1\right)} - 1\right) \]
      5. associate--l+74.4%

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

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

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

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

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

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

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

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

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

Alternative 8: 64.9% accurate, 1.4× speedup?

\[\begin{array}{l} 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 3.1 \cdot 10^{+159}:\\ \;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re\_m \cdot \left(x.re\_m - 27\right) + -1\right)\\ \end{array} \end{array} \]
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)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 3.1e+159)
    (* (* x.re_m x.im) (* x.im -3.0))
    (* x.im (+ (* x.re_m (- x.re_m 27.0)) -1.0)))))
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) {
	double tmp;
	if (x_46_re_m <= 3.1e+159) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else {
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	}
	return x_46_re_s * tmp;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re_m <= 3.1d+159) then
        tmp = (x_46re_m * x_46im) * (x_46im * (-3.0d0))
    else
        tmp = x_46im * ((x_46re_m * (x_46re_m - 27.0d0)) + (-1.0d0))
    end if
    code = x_46re_s * tmp
end function
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) {
	double tmp;
	if (x_46_re_m <= 3.1e+159) {
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	} else {
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	}
	return x_46_re_s * tmp;
}
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):
	tmp = 0
	if x_46_re_m <= 3.1e+159:
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0)
	else:
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0)
	return x_46_re_s * tmp
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)
	tmp = 0.0
	if (x_46_re_m <= 3.1e+159)
		tmp = Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0));
	else
		tmp = Float64(x_46_im * Float64(Float64(x_46_re_m * Float64(x_46_re_m - 27.0)) + -1.0));
	end
	return Float64(x_46_re_s * tmp)
end
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)
	tmp = 0.0;
	if (x_46_re_m <= 3.1e+159)
		tmp = (x_46_re_m * x_46_im) * (x_46_im * -3.0);
	else
		tmp = x_46_im * ((x_46_re_m * (x_46_re_m - 27.0)) + -1.0);
	end
	tmp_2 = x_46_re_s * tmp;
end
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_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 3.1e+159], N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re$95$m * N[(x$46$re$95$m - 27.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
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 3.1 \cdot 10^{+159}:\\
\;\;\;\;\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\

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


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

    1. Initial program 88.7%

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

      \[\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*85.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0999999999999998e159 < x.re

    1. Initial program 56.4%

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-undefine66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(e^{\mathsf{log1p}\left(x.im\right)} - 1\right)} \]
      2. log1p-undefine66.7%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(\color{blue}{\left(x.im + 1\right)} - 1\right) \]
      5. associate--l+74.4%

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

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

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

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

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

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

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

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

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

Alternative 9: 56.0% accurate, 2.7× speedup?

\[\begin{array}{l} x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \left(\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\right) \end{array} \]
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)
 :precision binary64
 (* x.re_s (* (* x.re_m x.im) (* x.im -3.0))))
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) {
	return x_46_re_s * ((x_46_re_m * x_46_im) * (x_46_im * -3.0));
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    code = x_46re_s * ((x_46re_m * x_46im) * (x_46im * (-3.0d0)))
end function
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) {
	return x_46_re_s * ((x_46_re_m * x_46_im) * (x_46_im * -3.0));
}
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):
	return x_46_re_s * ((x_46_re_m * x_46_im) * (x_46_im * -3.0))
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)
	return Float64(x_46_re_s * Float64(Float64(x_46_re_m * x_46_im) * Float64(x_46_im * -3.0)))
end
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)
	tmp = x_46_re_s * ((x_46_re_m * x_46_im) * (x_46_im * -3.0));
end
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_] := N[(x$46$re$95$s * N[(N[(x$46$re$95$m * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \left(\left(x.re\_m \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\right)
\end{array}
Derivation
  1. Initial program 83.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. Simplified80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot \left(x.im \cdot -3\right) \]
    5. add-exp-log38.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right) \]
  16. Add Preprocessing

Alternative 10: 50.8% accurate, 2.7× speedup?

\[\begin{array}{l} x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \left(x.re\_m \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)\right) \end{array} \]
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)
 :precision binary64
 (* x.re_s (* x.re_m (* (* x.im x.im) -3.0))))
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) {
	return x_46_re_s * (x_46_re_m * ((x_46_im * x_46_im) * -3.0));
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    code = x_46re_s * (x_46re_m * ((x_46im * x_46im) * (-3.0d0)))
end function
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) {
	return x_46_re_s * (x_46_re_m * ((x_46_im * x_46_im) * -3.0));
}
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):
	return x_46_re_s * (x_46_re_m * ((x_46_im * x_46_im) * -3.0))
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)
	return Float64(x_46_re_s * Float64(x_46_re_m * Float64(Float64(x_46_im * x_46_im) * -3.0)))
end
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)
	tmp = x_46_re_s * (x_46_re_m * ((x_46_im * x_46_im) * -3.0));
end
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_] := N[(x$46$re$95$s * N[(x$46$re$95$m * N[(N[(x$46$im * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \left(x.re\_m \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)\right)
\end{array}
Derivation
  1. Initial program 83.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. Simplified80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 3.6% accurate, 9.5× speedup?

\[\begin{array}{l} x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \left(-x.im\right) \end{array} \]
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) :precision binary64 (* x.re_s (- x.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) {
	return x_46_re_s * -x_46_im;
}
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)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im
    code = x_46re_s * -x_46im
end function
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) {
	return x_46_re_s * -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):
	return x_46_re_s * -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)
	return Float64(x_46_re_s * Float64(-x_46_im))
end
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)
	tmp = x_46_re_s * -x_46_im;
end
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_] := N[(x$46$re$95$s * (-x$46$im)), $MachinePrecision]
\begin{array}{l}
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \left(-x.im\right)
\end{array}
Derivation
  1. Initial program 83.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. *-commutative83.8%

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

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

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

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

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

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

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

    \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im\right)\right)} \]
  6. Step-by-step derivation
    1. expm1-undefine61.4%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(e^{\mathsf{log1p}\left(x.im\right)} - 1\right)} \]
    2. log1p-undefine61.4%

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(\color{blue}{\left(x.im + 1\right)} - 1\right) \]
    5. associate--l+54.1%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot x.im} \]
  12. Step-by-step derivation
    1. neg-mul-13.6%

      \[\leadsto \color{blue}{-x.im} \]
  13. Simplified3.6%

    \[\leadsto \color{blue}{-x.im} \]
  14. Add Preprocessing

Developer Target 1: 86.6% accurate, 1.1× speedup?

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

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

Reproduce

?
herbie shell --seed 2024145 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

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

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