math.cube on complex, imaginary part

Percentage Accurate: 82.1% → 99.8%
Time: 11.2s
Alternatives: 13
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (+
  (* (- (* x.re x.re) (* x.im x.im)) x.im)
  (* (+ (* x.re x.im) (* x.im x.re)) x.re)))
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_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re);
}
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_46im) + (((x_46re * x_46im) + (x_46im * x_46re)) * x_46re)
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_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re);
}
def code(x_46_re, x_46_im):
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re)
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_im) + Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_re))
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_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re);
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$im), $MachinePrecision] + N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
\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 13 alternatives:

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

Initial Program: 82.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (+
  (* (- (* x.re x.re) (* x.im x.im)) x.im)
  (* (+ (* x.re x.im) (* x.im x.re)) x.re)))
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_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re);
}
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_46im) + (((x_46re * x_46im) + (x_46im * x_46re)) * x_46re)
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_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re);
}
def code(x_46_re, x_46_im):
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re)
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_im) + Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_re))
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_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re);
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$im), $MachinePrecision] + N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.8% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 85.1%

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

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

    if 1.5e85 < x.im

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      5. expm1-undefine73.8%

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}}\right)} - 1\right) \]
      9. +-inverses0.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    8. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    9. Simplified100.0%

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

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

Alternative 2: 99.8% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := x.im\_m \cdot \left(\left(x.re - x.im\_m\right) \cdot \left(x.im\_m + x.re\right)\right)\\
t_1 := x.im\_m \cdot \left(x.re \cdot x.re - x.im\_m \cdot x.im\_m\right) + x.re \cdot \left(x.im\_m \cdot x.re + x.im\_m \cdot x.re\right)\\
x.im\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+288}:\\
\;\;\;\;t\_0 + x.re \cdot \left(\left(x.im\_m \cdot x.re\right) \cdot 2\right)\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.im\_m \cdot x.re, x.re \cdot 3, -1\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0 + -1\\


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

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

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

    1. Initial program 82.8%

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

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

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

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

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

        \[\leadsto \color{blue}{1 \cdot \mathsf{fma}\left(x.re \cdot x.im, x.re \cdot 3, -{x.im}^{3}\right)} \]
      2. add-sqr-sqrt64.4%

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

        \[\leadsto 1 \cdot \mathsf{fma}\left(x.re \cdot x.im, x.re \cdot 3, \color{blue}{\sqrt{\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right)}}\right) \]
      4. sqr-neg96.2%

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

        \[\leadsto 1 \cdot \mathsf{fma}\left(x.re \cdot x.im, x.re \cdot 3, \color{blue}{\sqrt{{x.im}^{3}} \cdot \sqrt{{x.im}^{3}}}\right) \]
      6. add-sqr-sqrt56.1%

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      5. expm1-undefine7.4%

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}}\right)} - 1\right) \]
      9. +-inverses0.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    8. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    9. Simplified100.0%

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

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

Alternative 3: 99.8% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 85.1%

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

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

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

    if 1.60000000000000009e85 < x.im

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      5. expm1-undefine73.8%

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}}\right)} - 1\right) \]
      9. +-inverses0.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    8. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    9. Simplified100.0%

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

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

Alternative 4: 94.0% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t\_0 + -1\\


\end{array}
\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.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < 9.9999999999999994e304

    1. Initial program 94.7%

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

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

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

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

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

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

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

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

    if 9.9999999999999994e304 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      5. expm1-undefine42.1%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} - 1\right)} \]
      6. *-commutative42.1%

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}}\right)} - 1\right) \]
      9. +-inverses0.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    8. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    9. Simplified88.7%

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

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

Alternative 5: 86.7% accurate, 0.8× speedup?

\[\begin{array}{l} x.im\_m = \left|x.im\right| \\ x.im\_s = \mathsf{copysign}\left(1, x.im\right) \\ \begin{array}{l} t_0 := x.im\_m \cdot \left(\left(x.re - x.im\_m\right) \cdot \left(x.im\_m + x.re\right)\right)\\ x.im\_s \cdot \begin{array}{l} \mathbf{if}\;x.im\_m \leq 2.8 \cdot 10^{-93}:\\ \;\;\;\;x.re \cdot \left(\left(x.im\_m \cdot x.re\right) \cdot 2\right) + x.im\_m \cdot \left(x.re \cdot \left(x.im\_m + x.re\right)\right)\\ \mathbf{elif}\;x.im\_m \leq 300000:\\ \;\;\;\;t\_0 - x.im\_m \cdot x.re\\ \mathbf{else}:\\ \;\;\;\;t\_0 + -1\\ \end{array} \end{array} \end{array} \]
x.im\_m = (fabs.f64 x.im)
x.im\_s = (copysign.f64 #s(literal 1 binary64) x.im)
(FPCore (x.im_s x.re x.im_m)
 :precision binary64
 (let* ((t_0 (* x.im_m (* (- x.re x.im_m) (+ x.im_m x.re)))))
   (*
    x.im_s
    (if (<= x.im_m 2.8e-93)
      (+ (* x.re (* (* x.im_m x.re) 2.0)) (* x.im_m (* x.re (+ x.im_m x.re))))
      (if (<= x.im_m 300000.0) (- t_0 (* x.im_m x.re)) (+ t_0 -1.0))))))
x.im\_m = fabs(x_46_im);
x.im\_s = copysign(1.0, x_46_im);
double code(double x_46_im_s, double x_46_re, double x_46_im_m) {
	double t_0 = x_46_im_m * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re));
	double tmp;
	if (x_46_im_m <= 2.8e-93) {
		tmp = (x_46_re * ((x_46_im_m * x_46_re) * 2.0)) + (x_46_im_m * (x_46_re * (x_46_im_m + x_46_re)));
	} else if (x_46_im_m <= 300000.0) {
		tmp = t_0 - (x_46_im_m * x_46_re);
	} else {
		tmp = t_0 + -1.0;
	}
	return x_46_im_s * tmp;
}
x.im\_m = abs(x_46im)
x.im\_s = copysign(1.0d0, x_46im)
real(8) function code(x_46im_s, x_46re, x_46im_m)
    real(8), intent (in) :: x_46im_s
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x_46im_m * ((x_46re - x_46im_m) * (x_46im_m + x_46re))
    if (x_46im_m <= 2.8d-93) then
        tmp = (x_46re * ((x_46im_m * x_46re) * 2.0d0)) + (x_46im_m * (x_46re * (x_46im_m + x_46re)))
    else if (x_46im_m <= 300000.0d0) then
        tmp = t_0 - (x_46im_m * x_46re)
    else
        tmp = t_0 + (-1.0d0)
    end if
    code = x_46im_s * tmp
end function
x.im\_m = Math.abs(x_46_im);
x.im\_s = Math.copySign(1.0, x_46_im);
public static double code(double x_46_im_s, double x_46_re, double x_46_im_m) {
	double t_0 = x_46_im_m * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re));
	double tmp;
	if (x_46_im_m <= 2.8e-93) {
		tmp = (x_46_re * ((x_46_im_m * x_46_re) * 2.0)) + (x_46_im_m * (x_46_re * (x_46_im_m + x_46_re)));
	} else if (x_46_im_m <= 300000.0) {
		tmp = t_0 - (x_46_im_m * x_46_re);
	} else {
		tmp = t_0 + -1.0;
	}
	return x_46_im_s * tmp;
}
x.im\_m = math.fabs(x_46_im)
x.im\_s = math.copysign(1.0, x_46_im)
def code(x_46_im_s, x_46_re, x_46_im_m):
	t_0 = x_46_im_m * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re))
	tmp = 0
	if x_46_im_m <= 2.8e-93:
		tmp = (x_46_re * ((x_46_im_m * x_46_re) * 2.0)) + (x_46_im_m * (x_46_re * (x_46_im_m + x_46_re)))
	elif x_46_im_m <= 300000.0:
		tmp = t_0 - (x_46_im_m * x_46_re)
	else:
		tmp = t_0 + -1.0
	return x_46_im_s * tmp
x.im\_m = abs(x_46_im)
x.im\_s = copysign(1.0, x_46_im)
function code(x_46_im_s, x_46_re, x_46_im_m)
	t_0 = Float64(x_46_im_m * Float64(Float64(x_46_re - x_46_im_m) * Float64(x_46_im_m + x_46_re)))
	tmp = 0.0
	if (x_46_im_m <= 2.8e-93)
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_im_m * x_46_re) * 2.0)) + Float64(x_46_im_m * Float64(x_46_re * Float64(x_46_im_m + x_46_re))));
	elseif (x_46_im_m <= 300000.0)
		tmp = Float64(t_0 - Float64(x_46_im_m * x_46_re));
	else
		tmp = Float64(t_0 + -1.0);
	end
	return Float64(x_46_im_s * tmp)
end
x.im\_m = abs(x_46_im);
x.im\_s = sign(x_46_im) * abs(1.0);
function tmp_2 = code(x_46_im_s, x_46_re, x_46_im_m)
	t_0 = x_46_im_m * ((x_46_re - x_46_im_m) * (x_46_im_m + x_46_re));
	tmp = 0.0;
	if (x_46_im_m <= 2.8e-93)
		tmp = (x_46_re * ((x_46_im_m * x_46_re) * 2.0)) + (x_46_im_m * (x_46_re * (x_46_im_m + x_46_re)));
	elseif (x_46_im_m <= 300000.0)
		tmp = t_0 - (x_46_im_m * x_46_re);
	else
		tmp = t_0 + -1.0;
	end
	tmp_2 = x_46_im_s * tmp;
end
x.im\_m = N[Abs[x$46$im], $MachinePrecision]
x.im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$im$95$s_, x$46$re_, x$46$im$95$m_] := Block[{t$95$0 = N[(x$46$im$95$m * N[(N[(x$46$re - x$46$im$95$m), $MachinePrecision] * N[(x$46$im$95$m + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$46$im$95$s * If[LessEqual[x$46$im$95$m, 2.8e-93], N[(N[(x$46$re * N[(N[(x$46$im$95$m * x$46$re), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] + N[(x$46$im$95$m * N[(x$46$re * N[(x$46$im$95$m + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im$95$m, 300000.0], N[(t$95$0 - N[(x$46$im$95$m * x$46$re), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + -1.0), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
x.im\_m = \left|x.im\right|
\\
x.im\_s = \mathsf{copysign}\left(1, x.im\right)

\\
\begin{array}{l}
t_0 := x.im\_m \cdot \left(\left(x.re - x.im\_m\right) \cdot \left(x.im\_m + x.re\right)\right)\\
x.im\_s \cdot \begin{array}{l}
\mathbf{if}\;x.im\_m \leq 2.8 \cdot 10^{-93}:\\
\;\;\;\;x.re \cdot \left(\left(x.im\_m \cdot x.re\right) \cdot 2\right) + x.im\_m \cdot \left(x.re \cdot \left(x.im\_m + x.re\right)\right)\\

\mathbf{elif}\;x.im\_m \leq 300000:\\
\;\;\;\;t\_0 - x.im\_m \cdot x.re\\

\mathbf{else}:\\
\;\;\;\;t\_0 + -1\\


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

    1. Initial program 82.9%

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

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

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

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

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

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

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

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

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

    if 2.79999999999999998e-93 < x.im < 3e5

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \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.re \]
      4. difference-of-squares0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\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 \left(x.re \cdot x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re \]
      15. +-inverses0.0%

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

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

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

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

    if 3e5 < x.im

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      5. expm1-undefine80.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} - 1\right)} \]
      6. *-commutative80.0%

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}}\right)} - 1\right) \]
      9. +-inverses0.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    8. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    9. Simplified97.0%

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

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

Alternative 6: 86.7% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x.im\_m \leq 200000:\\
\;\;\;\;t\_0 - x.im\_m \cdot x.re\\

\mathbf{else}:\\
\;\;\;\;t\_0 + -1\\


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

    1. Initial program 82.9%

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

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right) - {x.im}^{3}} \]
    3. Add Preprocessing
    4. Taylor expanded in x.re around inf 60.8%

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

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

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

    if 3.1999999999999999e-93 < x.im < 2e5

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \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.re \]
      4. difference-of-squares0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\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 \left(x.re \cdot x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re \]
      15. +-inverses0.0%

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

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

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

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

    if 2e5 < x.im

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      5. expm1-undefine80.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} - 1\right)} \]
      6. *-commutative80.0%

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}}\right)} - 1\right) \]
      9. +-inverses0.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    8. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    9. Simplified97.0%

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

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

Alternative 7: 85.0% accurate, 1.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 3.20000000000000018e-31

    1. Initial program 84.0%

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

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right) - {x.im}^{3}} \]
    3. Add Preprocessing
    4. Taylor expanded in x.re around inf 59.1%

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

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

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

    if 3.20000000000000018e-31 < x.im

    1. Initial program 77.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{x.im \cdot x.re}\right) \cdot x.re \]
      4. expm1-log1p-u80.5%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      5. expm1-undefine80.5%

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}}\right)} - 1\right) \]
      9. +-inverses0.0%

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    8. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    9. Simplified92.4%

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

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

Alternative 8: 55.2% accurate, 1.6× speedup?

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

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

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


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

    1. Initial program 83.7%

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

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right) - {x.im}^{3}} \]
    3. Add Preprocessing
    4. Taylor expanded in x.re around inf 54.4%

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

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

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

    if 4.79999999999999961e218 < x.im

    1. Initial program 64.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(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}}, \left(\left(x.re - x.im\right) \cdot \left(x.re \cdot \left(1 + \frac{x.im}{x.re}\right)\right)\right) \cdot x.im\right) \]
      6. +-inverses0.0%

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

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

        \[\leadsto \mathsf{fma}\left(x.re, \frac{0}{0}, \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re \cdot \left(1 + \frac{x.im}{x.re}\right)\right) \cdot x.im\right)}\right) \]
      9. *-commutative0.0%

        \[\leadsto \mathsf{fma}\left(x.re, \frac{0}{0}, \left(x.re - x.im\right) \cdot \left(\color{blue}{\left(\left(1 + \frac{x.im}{x.re}\right) \cdot x.re\right)} \cdot x.im\right)\right) \]
      10. associate-*l*0.0%

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

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

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

      \[\leadsto -1 + \color{blue}{\left(-1 \cdot x.re\right)} \cdot \left(x.im \cdot x.re\right) \]
    10. Step-by-step derivation
      1. neg-mul-138.4%

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

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

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

Alternative 9: 52.6% accurate, 1.6× speedup?

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

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

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


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

    1. Initial program 83.7%

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

      \[\leadsto \color{blue}{x.re \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right) - {x.im}^{3}} \]
    3. Add Preprocessing
    4. Taylor expanded in x.re around inf 54.4%

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

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

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

    if 1e222 < x.im

    1. Initial program 64.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \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.re \]
      4. difference-of-squares0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\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 \left(x.re \cdot x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re \]
      15. +-inverses0.0%

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

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

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

      \[\leadsto -3 + \color{blue}{\left(-x.im\right)} \cdot x.re \]
    10. Step-by-step derivation
      1. distribute-lft-neg-out13.8%

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

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

        \[\leadsto \color{blue}{-3 - x.re \cdot x.im} \]
    11. Applied egg-rr13.8%

      \[\leadsto \color{blue}{-3 - x.re \cdot x.im} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.7%

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

Alternative 10: 22.3% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x.im\_m \cdot x.re + -3\\


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

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \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.re \]
      4. difference-of-squares0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\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 \left(x.re \cdot x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re \]
      15. +-inverses0.0%

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

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

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

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

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

        \[\leadsto \color{blue}{-x.im \cdot x.re} \]
      2. *-commutative21.8%

        \[\leadsto -\color{blue}{x.re \cdot x.im} \]
      3. distribute-lft-neg-in21.8%

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

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

    if 2.6e172 < x.re

    1. Initial program 57.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \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.re \]
      4. difference-of-squares0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\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 \left(x.re \cdot x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re \]
      15. +-inverses0.0%

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

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

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

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

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

        \[\leadsto -3 + \color{blue}{\left(0 + \left(-x.im\right)\right)} \cdot x.re \]
      3. add-sqr-sqrt2.9%

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

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

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

        \[\leadsto -3 + \left(0 + \color{blue}{\sqrt{x.im} \cdot \sqrt{x.im}}\right) \cdot x.re \]
      7. add-sqr-sqrt33.9%

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

      \[\leadsto -3 + \color{blue}{\left(0 + x.im\right)} \cdot x.re \]
    12. Step-by-step derivation
      1. +-lft-identity33.9%

        \[\leadsto -3 + \color{blue}{x.im} \cdot x.re \]
    13. Simplified33.9%

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

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

Alternative 11: 20.2% accurate, 4.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \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.re \]
    4. difference-of-squares0.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\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 \left(x.re \cdot x.im\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re \]
    15. +-inverses0.0%

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

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

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

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

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

      \[\leadsto \color{blue}{-x.im \cdot x.re} \]
    2. *-commutative19.7%

      \[\leadsto -\color{blue}{x.re \cdot x.im} \]
    3. distribute-lft-neg-in19.7%

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

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

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

Alternative 12: 2.7% accurate, 19.0× speedup?

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

\\
x.im\_s \cdot 2
\end{array}
Derivation
  1. Initial program 82.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{{\left(\mathsf{fma}\left(x.re, \color{blue}{2 \cdot \left(x.re \cdot x.im\right)}, -3\right)\right)}^{2}} \]
    8. count-213.9%

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

      \[\leadsto \sqrt{{\left(\mathsf{fma}\left(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}}, -3\right)\right)}^{2}} \]
    10. +-inverses0.0%

      \[\leadsto \sqrt{{\left(\mathsf{fma}\left(x.re, \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im}, -3\right)\right)}^{2}} \]
    11. +-inverses0.0%

      \[\leadsto \sqrt{{\left(\mathsf{fma}\left(x.re, \frac{0}{\color{blue}{0}}, -3\right)\right)}^{2}} \]
  8. Applied egg-rr0.0%

    \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(x.re, \frac{0}{0}, -3\right)\right)}^{2}}} \]
  9. Simplified2.7%

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

Alternative 13: 2.6% accurate, 19.0× speedup?

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

\\
x.im\_s \cdot -3
\end{array}
Derivation
  1. Initial program 82.4%

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

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

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

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

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

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

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

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

Developer target: 91.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \left(x.re \cdot x.im\right) \cdot \left(2 \cdot x.re\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right) \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (+ (* (* x.re x.im) (* 2.0 x.re)) (* (* x.im (- x.re x.im)) (+ x.re x.im))))
double code(double x_46_re, double x_46_im) {
	return ((x_46_re * x_46_im) * (2.0 * x_46_re)) + ((x_46_im * (x_46_re - 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_46im) * (2.0d0 * x_46re)) + ((x_46im * (x_46re - 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_im) * (2.0 * x_46_re)) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
}
def code(x_46_re, x_46_im):
	return ((x_46_re * x_46_im) * (2.0 * x_46_re)) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im))
function code(x_46_re, x_46_im)
	return Float64(Float64(Float64(x_46_re * x_46_im) * Float64(2.0 * x_46_re)) + Float64(Float64(x_46_im * Float64(x_46_re - x_46_im)) * Float64(x_46_re + x_46_im)))
end
function tmp = code(x_46_re, x_46_im)
	tmp = ((x_46_re * x_46_im) * (2.0 * x_46_re)) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
end
code[x$46$re_, x$46$im_] := N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(2.0 * x$46$re), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Reproduce

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

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

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