math.cube on complex, imaginary part

Percentage Accurate: 82.7% → 96.5%
Time: 7.3s
Alternatives: 11
Speedup: 1.4×

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 11 alternatives:

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

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

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -7.5 \cdot 10^{+154}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \mathbf{elif}\;x.re \leq 7.7 \cdot 10^{+149}:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot x.re, x.im \cdot 3, -{x.im}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re -7.5e+154)
   (* x.re (* x.re (* x.im 3.0)))
   (if (<= x.re 7.7e+149)
     (fma (* x.re x.re) (* x.im 3.0) (- (pow x.im 3.0)))
     (* x.re (* 3.0 (* x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= -7.5e+154) {
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	} else if (x_46_re <= 7.7e+149) {
		tmp = fma((x_46_re * x_46_re), (x_46_im * 3.0), -pow(x_46_im, 3.0));
	} else {
		tmp = x_46_re * (3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= -7.5e+154)
		tmp = Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0)));
	elseif (x_46_re <= 7.7e+149)
		tmp = fma(Float64(x_46_re * x_46_re), Float64(x_46_im * 3.0), Float64(-(x_46_im ^ 3.0)));
	else
		tmp = Float64(x_46_re * Float64(3.0 * Float64(x_46_re * x_46_im)));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -7.5e+154], N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 7.7e+149], N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$im * 3.0), $MachinePrecision] + (-N[Power[x$46$im, 3.0], $MachinePrecision])), $MachinePrecision], N[(x$46$re * N[(3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x.re \leq 7.7 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot x.re, x.im \cdot 3, -{x.im}^{3}\right)\\

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


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

    1. Initial program 48.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. Step-by-step derivation
      1. add-log-exp48.6%

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

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

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

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      5. add-log-exp48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.5000000000000004e154 < x.re < 7.69999999999999998e149

    1. Initial program 89.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. Taylor expanded in x.re around 0 89.6%

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

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

    if 7.69999999999999998e149 < x.re

    1. Initial program 65.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. Step-by-step derivation
      1. add-log-exp61.8%

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

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

        \[\leadsto \color{blue}{\left(\log 1 + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      4. metadata-eval61.8%

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      5. add-log-exp65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -7.5 \cdot 10^{+154}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \mathbf{elif}\;x.re \leq 7.7 \cdot 10^{+149}:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot x.re, x.im \cdot 3, -{x.im}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 2: 96.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -7.5 \cdot 10^{+154}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \mathbf{elif}\;x.re \leq 6.5 \cdot 10^{+149}:\\ \;\;\;\;\mathsf{fma}\left(x.im, x.re \cdot \left(x.re + x.re\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re -7.5e+154)
   (* x.re (* x.re (* x.im 3.0)))
   (if (<= x.re 6.5e+149)
     (fma x.im (* x.re (+ x.re x.re)) (* x.im (- (* x.re x.re) (* x.im x.im))))
     (* x.re (* 3.0 (* x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= -7.5e+154) {
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	} else if (x_46_re <= 6.5e+149) {
		tmp = fma(x_46_im, (x_46_re * (x_46_re + x_46_re)), (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))));
	} else {
		tmp = x_46_re * (3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= -7.5e+154)
		tmp = Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0)));
	elseif (x_46_re <= 6.5e+149)
		tmp = fma(x_46_im, Float64(x_46_re * Float64(x_46_re + x_46_re)), Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))));
	else
		tmp = Float64(x_46_re * Float64(3.0 * Float64(x_46_re * x_46_im)));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -7.5e+154], N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 6.5e+149], N[(x$46$im * N[(x$46$re * N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision] + N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x.re \leq 6.5 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(x.im, x.re \cdot \left(x.re + x.re\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\\

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


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

    1. Initial program 48.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. Step-by-step derivation
      1. add-log-exp48.6%

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

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

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

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      5. add-log-exp48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.5000000000000004e154 < x.re < 6.50000000000000015e149

    1. Initial program 89.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. Step-by-step derivation
      1. add-cube-cbrt89.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.im, x.re \cdot \left(x.re + x.re\right), \color{blue}{\left(\sqrt[3]{\left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)} \cdot \sqrt[3]{\left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)}\right) \cdot \sqrt[3]{\left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)}}\right) \]
      5. add-cube-cbrt99.8%

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

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

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

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

    if 6.50000000000000015e149 < x.re

    1. Initial program 65.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. Step-by-step derivation
      1. add-log-exp61.8%

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

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

        \[\leadsto \color{blue}{\left(\log 1 + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      4. metadata-eval61.8%

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      5. add-log-exp65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -7.5 \cdot 10^{+154}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \mathbf{elif}\;x.re \leq 6.5 \cdot 10^{+149}:\\ \;\;\;\;\mathsf{fma}\left(x.im, x.re \cdot \left(x.re + x.re\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 3: 96.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \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.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.re + x.im\right)\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re + x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (+
       (* x.im (- (* x.re x.re) (* x.im x.im)))
       (* x.re (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (+ (* (- x.re x.im) (* x.im (+ x.re x.im))) (* (* x.re x.im) (+ x.re x.re)))
   (* x.im (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + ((x_46_re * x_46_im) * (x_46_re + x_46_re));
	} else {
		tmp = x_46_im * (x_46_im * -x_46_im);
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Double.POSITIVE_INFINITY) {
		tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + ((x_46_re * x_46_im) * (x_46_re + x_46_re));
	} else {
		tmp = x_46_im * (x_46_im * -x_46_im);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= math.inf:
		tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + ((x_46_re * x_46_im) * (x_46_re + x_46_re))
	else:
		tmp = x_46_im * (x_46_im * -x_46_im)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = Float64(Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_re + x_46_im))) + Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re + x_46_re)));
	else
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Inf)
		tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + ((x_46_re * x_46_im) * (x_46_re + x_46_re));
	else
		tmp = x_46_im * (x_46_im * -x_46_im);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    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. Step-by-step derivation
      1. add-cube-cbrt94.1%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[3]{\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. pow394.2%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)} \cdot \sqrt[3]{\left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)}\right) \cdot \sqrt[3]{\left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)}} + \left(x.im \cdot x.re\right) \cdot \left(x.re + x.re\right) \]
      2. add-cube-cbrt99.8%

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

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

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

      \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)} + \left(x.im \cdot x.re\right) \cdot \left(x.re + x.re\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. Step-by-step derivation
      1. expm1-log1p-u0.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
      2. expm1-udef0.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
    3. Applied egg-rr0.0%

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

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

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

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

    \[\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.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.re + x.im\right)\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re + x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \]

Alternative 4: 75.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -1.7 \cdot 10^{+72} \lor \neg \left(x.re \leq -3.4 \cdot 10^{+23} \lor \neg \left(x.re \leq -5.6 \cdot 10^{-64}\right) \land x.re \leq 4.9 \cdot 10^{+60}\right):\\ \;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -1.7e+72)
         (not
          (or (<= x.re -3.4e+23)
              (and (not (<= x.re -5.6e-64)) (<= x.re 4.9e+60)))))
   (* x.im (* 3.0 (* x.re x.re)))
   (* x.im (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -1.7e+72) || !((x_46_re <= -3.4e+23) || (!(x_46_re <= -5.6e-64) && (x_46_re <= 4.9e+60)))) {
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	} else {
		tmp = x_46_im * (x_46_im * -x_46_im);
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46re <= (-1.7d+72)) .or. (.not. (x_46re <= (-3.4d+23)) .or. (.not. (x_46re <= (-5.6d-64))) .and. (x_46re <= 4.9d+60))) then
        tmp = x_46im * (3.0d0 * (x_46re * x_46re))
    else
        tmp = x_46im * (x_46im * -x_46im)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -1.7e+72) || !((x_46_re <= -3.4e+23) || (!(x_46_re <= -5.6e-64) && (x_46_re <= 4.9e+60)))) {
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	} else {
		tmp = x_46_im * (x_46_im * -x_46_im);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -1.7e+72) or not ((x_46_re <= -3.4e+23) or (not (x_46_re <= -5.6e-64) and (x_46_re <= 4.9e+60))):
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re))
	else:
		tmp = x_46_im * (x_46_im * -x_46_im)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -1.7e+72) || !((x_46_re <= -3.4e+23) || (!(x_46_re <= -5.6e-64) && (x_46_re <= 4.9e+60))))
		tmp = Float64(x_46_im * Float64(3.0 * Float64(x_46_re * x_46_re)));
	else
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= -1.7e+72) || ~(((x_46_re <= -3.4e+23) || (~((x_46_re <= -5.6e-64)) && (x_46_re <= 4.9e+60)))))
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	else
		tmp = x_46_im * (x_46_im * -x_46_im);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -1.7e+72], N[Not[Or[LessEqual[x$46$re, -3.4e+23], And[N[Not[LessEqual[x$46$re, -5.6e-64]], $MachinePrecision], LessEqual[x$46$re, 4.9e+60]]]], $MachinePrecision]], N[(x$46$im * N[(3.0 * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.7 \cdot 10^{+72} \lor \neg \left(x.re \leq -3.4 \cdot 10^{+23} \lor \neg \left(x.re \leq -5.6 \cdot 10^{-64}\right) \land x.re \leq 4.9 \cdot 10^{+60}\right):\\
\;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -1.6999999999999999e72 or -3.39999999999999992e23 < x.re < -5.60000000000000008e-64 or 4.9000000000000003e60 < x.re

    1. Initial program 67.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. Taylor expanded in x.im around 0 70.9%

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

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

    if -1.6999999999999999e72 < x.re < -3.39999999999999992e23 or -5.60000000000000008e-64 < x.re < 4.9000000000000003e60

    1. Initial program 93.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. Step-by-step derivation
      1. expm1-log1p-u67.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
      2. expm1-udef48.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
    3. Applied egg-rr0.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -1.7 \cdot 10^{+72} \lor \neg \left(x.re \leq -3.4 \cdot 10^{+23} \lor \neg \left(x.re \leq -5.6 \cdot 10^{-64}\right) \land x.re \leq 4.9 \cdot 10^{+60}\right):\\ \;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \]

Alternative 5: 75.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -8 \cdot 10^{+71}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{elif}\;x.re \leq -7 \cdot 10^{+23} \lor \neg \left(x.re \leq -5.6 \cdot 10^{-64}\right) \land x.re \leq 4 \cdot 10^{+59}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re -8e+71)
   (* x.im (* x.re (* x.re 3.0)))
   (if (or (<= x.re -7e+23) (and (not (<= x.re -5.6e-64)) (<= x.re 4e+59)))
     (* x.im (* x.im (- x.im)))
     (* x.im (* 3.0 (* x.re x.re))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= -8e+71) {
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	} else if ((x_46_re <= -7e+23) || (!(x_46_re <= -5.6e-64) && (x_46_re <= 4e+59))) {
		tmp = x_46_im * (x_46_im * -x_46_im);
	} else {
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re <= (-8d+71)) then
        tmp = x_46im * (x_46re * (x_46re * 3.0d0))
    else if ((x_46re <= (-7d+23)) .or. (.not. (x_46re <= (-5.6d-64))) .and. (x_46re <= 4d+59)) then
        tmp = x_46im * (x_46im * -x_46im)
    else
        tmp = x_46im * (3.0d0 * (x_46re * x_46re))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= -8e+71) {
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	} else if ((x_46_re <= -7e+23) || (!(x_46_re <= -5.6e-64) && (x_46_re <= 4e+59))) {
		tmp = x_46_im * (x_46_im * -x_46_im);
	} else {
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_re <= -8e+71:
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0))
	elif (x_46_re <= -7e+23) or (not (x_46_re <= -5.6e-64) and (x_46_re <= 4e+59)):
		tmp = x_46_im * (x_46_im * -x_46_im)
	else:
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= -8e+71)
		tmp = Float64(x_46_im * Float64(x_46_re * Float64(x_46_re * 3.0)));
	elseif ((x_46_re <= -7e+23) || (!(x_46_re <= -5.6e-64) && (x_46_re <= 4e+59)))
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im)));
	else
		tmp = Float64(x_46_im * Float64(3.0 * Float64(x_46_re * x_46_re)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_re <= -8e+71)
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	elseif ((x_46_re <= -7e+23) || (~((x_46_re <= -5.6e-64)) && (x_46_re <= 4e+59)))
		tmp = x_46_im * (x_46_im * -x_46_im);
	else
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -8e+71], N[(x$46$im * N[(x$46$re * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x$46$re, -7e+23], And[N[Not[LessEqual[x$46$re, -5.6e-64]], $MachinePrecision], LessEqual[x$46$re, 4e+59]]], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(3.0 * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x.re \leq -7 \cdot 10^{+23} \lor \neg \left(x.re \leq -5.6 \cdot 10^{-64}\right) \land x.re \leq 4 \cdot 10^{+59}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\

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


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

    1. Initial program 55.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. Step-by-step derivation
      1. add-log-exp37.5%

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

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

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

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      5. add-log-exp55.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.0000000000000003e71 < x.re < -7.0000000000000004e23 or -5.60000000000000008e-64 < x.re < 3.99999999999999989e59

    1. Initial program 93.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. Step-by-step derivation
      1. expm1-log1p-u67.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
      2. expm1-udef48.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
    3. Applied egg-rr0.0%

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

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

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

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

    if -7.0000000000000004e23 < x.re < -5.60000000000000008e-64 or 3.99999999999999989e59 < x.re

    1. Initial program 78.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. Taylor expanded in x.im around 0 72.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -8 \cdot 10^{+71}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{elif}\;x.re \leq -7 \cdot 10^{+23} \lor \neg \left(x.re \leq -5.6 \cdot 10^{-64}\right) \land x.re \leq 4 \cdot 10^{+59}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\ \end{array} \]

Alternative 6: 81.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ t_1 := x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{if}\;x.re \leq -7.5 \cdot 10^{+71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.re \leq -2.65 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.re \leq -5.6 \cdot 10^{-64}:\\ \;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\ \mathbf{elif}\;x.re \leq 2.85 \cdot 10^{+60}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.re (* 3.0 (* x.re x.im)))) (t_1 (* x.im (* x.im (- x.im)))))
   (if (<= x.re -7.5e+71)
     t_0
     (if (<= x.re -2.65e+23)
       t_1
       (if (<= x.re -5.6e-64)
         (* x.im (* 3.0 (* x.re x.re)))
         (if (<= x.re 2.85e+60) t_1 t_0))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (3.0 * (x_46_re * x_46_im));
	double t_1 = x_46_im * (x_46_im * -x_46_im);
	double tmp;
	if (x_46_re <= -7.5e+71) {
		tmp = t_0;
	} else if (x_46_re <= -2.65e+23) {
		tmp = t_1;
	} else if (x_46_re <= -5.6e-64) {
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	} else if (x_46_re <= 2.85e+60) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x_46re * (3.0d0 * (x_46re * x_46im))
    t_1 = x_46im * (x_46im * -x_46im)
    if (x_46re <= (-7.5d+71)) then
        tmp = t_0
    else if (x_46re <= (-2.65d+23)) then
        tmp = t_1
    else if (x_46re <= (-5.6d-64)) then
        tmp = x_46im * (3.0d0 * (x_46re * x_46re))
    else if (x_46re <= 2.85d+60) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (3.0 * (x_46_re * x_46_im));
	double t_1 = x_46_im * (x_46_im * -x_46_im);
	double tmp;
	if (x_46_re <= -7.5e+71) {
		tmp = t_0;
	} else if (x_46_re <= -2.65e+23) {
		tmp = t_1;
	} else if (x_46_re <= -5.6e-64) {
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	} else if (x_46_re <= 2.85e+60) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = x_46_re * (3.0 * (x_46_re * x_46_im))
	t_1 = x_46_im * (x_46_im * -x_46_im)
	tmp = 0
	if x_46_re <= -7.5e+71:
		tmp = t_0
	elif x_46_re <= -2.65e+23:
		tmp = t_1
	elif x_46_re <= -5.6e-64:
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re))
	elif x_46_re <= 2.85e+60:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_re * Float64(3.0 * Float64(x_46_re * x_46_im)))
	t_1 = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im)))
	tmp = 0.0
	if (x_46_re <= -7.5e+71)
		tmp = t_0;
	elseif (x_46_re <= -2.65e+23)
		tmp = t_1;
	elseif (x_46_re <= -5.6e-64)
		tmp = Float64(x_46_im * Float64(3.0 * Float64(x_46_re * x_46_re)));
	elseif (x_46_re <= 2.85e+60)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_re * (3.0 * (x_46_re * x_46_im));
	t_1 = x_46_im * (x_46_im * -x_46_im);
	tmp = 0.0;
	if (x_46_re <= -7.5e+71)
		tmp = t_0;
	elseif (x_46_re <= -2.65e+23)
		tmp = t_1;
	elseif (x_46_re <= -5.6e-64)
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	elseif (x_46_re <= 2.85e+60)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -7.5e+71], t$95$0, If[LessEqual[x$46$re, -2.65e+23], t$95$1, If[LessEqual[x$46$re, -5.6e-64], N[(x$46$im * N[(3.0 * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 2.85e+60], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\
t_1 := x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\
\mathbf{if}\;x.re \leq -7.5 \cdot 10^{+71}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x.re \leq -2.65 \cdot 10^{+23}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x.re \leq -5.6 \cdot 10^{-64}:\\
\;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\

\mathbf{elif}\;x.re \leq 2.85 \cdot 10^{+60}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -7.50000000000000007e71 or 2.84999999999999989e60 < x.re

    1. Initial program 60.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. Step-by-step derivation
      1. add-log-exp38.6%

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

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

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

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      5. add-log-exp60.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.50000000000000007e71 < x.re < -2.6500000000000001e23 or -5.60000000000000008e-64 < x.re < 2.84999999999999989e60

    1. Initial program 93.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. Step-by-step derivation
      1. expm1-log1p-u67.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
      2. expm1-udef48.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
    3. Applied egg-rr0.0%

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

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

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

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

    if -2.6500000000000001e23 < x.re < -5.60000000000000008e-64

    1. Initial program 99.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. Taylor expanded in x.im around 0 72.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -7.5 \cdot 10^{+71}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.re \leq -2.65 \cdot 10^{+23}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{elif}\;x.re \leq -5.6 \cdot 10^{-64}:\\ \;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\ \mathbf{elif}\;x.re \leq 2.85 \cdot 10^{+60}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 7: 81.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ t_1 := x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{if}\;x.re \leq -8.2 \cdot 10^{+71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.re \leq -2.7 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.re \leq -5.6 \cdot 10^{-64}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)\\ \mathbf{elif}\;x.re \leq 4 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.re (* 3.0 (* x.re x.im)))) (t_1 (* x.im (* x.im (- x.im)))))
   (if (<= x.re -8.2e+71)
     t_0
     (if (<= x.re -2.7e+23)
       t_1
       (if (<= x.re -5.6e-64)
         (* (* x.re x.re) (* x.im 3.0))
         (if (<= x.re 4e+59) t_1 t_0))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (3.0 * (x_46_re * x_46_im));
	double t_1 = x_46_im * (x_46_im * -x_46_im);
	double tmp;
	if (x_46_re <= -8.2e+71) {
		tmp = t_0;
	} else if (x_46_re <= -2.7e+23) {
		tmp = t_1;
	} else if (x_46_re <= -5.6e-64) {
		tmp = (x_46_re * x_46_re) * (x_46_im * 3.0);
	} else if (x_46_re <= 4e+59) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x_46re * (3.0d0 * (x_46re * x_46im))
    t_1 = x_46im * (x_46im * -x_46im)
    if (x_46re <= (-8.2d+71)) then
        tmp = t_0
    else if (x_46re <= (-2.7d+23)) then
        tmp = t_1
    else if (x_46re <= (-5.6d-64)) then
        tmp = (x_46re * x_46re) * (x_46im * 3.0d0)
    else if (x_46re <= 4d+59) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (3.0 * (x_46_re * x_46_im));
	double t_1 = x_46_im * (x_46_im * -x_46_im);
	double tmp;
	if (x_46_re <= -8.2e+71) {
		tmp = t_0;
	} else if (x_46_re <= -2.7e+23) {
		tmp = t_1;
	} else if (x_46_re <= -5.6e-64) {
		tmp = (x_46_re * x_46_re) * (x_46_im * 3.0);
	} else if (x_46_re <= 4e+59) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = x_46_re * (3.0 * (x_46_re * x_46_im))
	t_1 = x_46_im * (x_46_im * -x_46_im)
	tmp = 0
	if x_46_re <= -8.2e+71:
		tmp = t_0
	elif x_46_re <= -2.7e+23:
		tmp = t_1
	elif x_46_re <= -5.6e-64:
		tmp = (x_46_re * x_46_re) * (x_46_im * 3.0)
	elif x_46_re <= 4e+59:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_re * Float64(3.0 * Float64(x_46_re * x_46_im)))
	t_1 = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im)))
	tmp = 0.0
	if (x_46_re <= -8.2e+71)
		tmp = t_0;
	elseif (x_46_re <= -2.7e+23)
		tmp = t_1;
	elseif (x_46_re <= -5.6e-64)
		tmp = Float64(Float64(x_46_re * x_46_re) * Float64(x_46_im * 3.0));
	elseif (x_46_re <= 4e+59)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_re * (3.0 * (x_46_re * x_46_im));
	t_1 = x_46_im * (x_46_im * -x_46_im);
	tmp = 0.0;
	if (x_46_re <= -8.2e+71)
		tmp = t_0;
	elseif (x_46_re <= -2.7e+23)
		tmp = t_1;
	elseif (x_46_re <= -5.6e-64)
		tmp = (x_46_re * x_46_re) * (x_46_im * 3.0);
	elseif (x_46_re <= 4e+59)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -8.2e+71], t$95$0, If[LessEqual[x$46$re, -2.7e+23], t$95$1, If[LessEqual[x$46$re, -5.6e-64], N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 4e+59], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\
t_1 := x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\
\mathbf{if}\;x.re \leq -8.2 \cdot 10^{+71}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x.re \leq -2.7 \cdot 10^{+23}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x.re \leq -5.6 \cdot 10^{-64}:\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)\\

\mathbf{elif}\;x.re \leq 4 \cdot 10^{+59}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -8.2000000000000004e71 or 3.99999999999999989e59 < x.re

    1. Initial program 60.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. Step-by-step derivation
      1. add-log-exp38.6%

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

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

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

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      5. add-log-exp60.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.2000000000000004e71 < x.re < -2.6999999999999999e23 or -5.60000000000000008e-64 < x.re < 3.99999999999999989e59

    1. Initial program 93.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. Step-by-step derivation
      1. expm1-log1p-u67.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
      2. expm1-udef48.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
    3. Applied egg-rr0.0%

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

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

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

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

    if -2.6999999999999999e23 < x.re < -5.60000000000000008e-64

    1. Initial program 99.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. Taylor expanded in x.re around inf 72.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -8.2 \cdot 10^{+71}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.re \leq -2.7 \cdot 10^{+23}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{elif}\;x.re \leq -5.6 \cdot 10^{-64}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)\\ \mathbf{elif}\;x.re \leq 4 \cdot 10^{+59}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 8: 86.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -7.8 \cdot 10^{-48} \lor \neg \left(x.im \leq 9.5 \cdot 10^{-97}\right):\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -7.8e-48) (not (<= x.im 9.5e-97)))
   (* x.im (- (* x.re x.re) (* x.im x.im)))
   (* x.re (* 3.0 (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -7.8e-48) || !(x_46_im <= 9.5e-97)) {
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	} else {
		tmp = x_46_re * (3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46im <= (-7.8d-48)) .or. (.not. (x_46im <= 9.5d-97))) then
        tmp = x_46im * ((x_46re * x_46re) - (x_46im * x_46im))
    else
        tmp = x_46re * (3.0d0 * (x_46re * x_46im))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -7.8e-48) || !(x_46_im <= 9.5e-97)) {
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	} else {
		tmp = x_46_re * (3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -7.8e-48) or not (x_46_im <= 9.5e-97):
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))
	else:
		tmp = x_46_re * (3.0 * (x_46_re * x_46_im))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= -7.8e-48) || !(x_46_im <= 9.5e-97))
		tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)));
	else
		tmp = Float64(x_46_re * Float64(3.0 * Float64(x_46_re * x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_im <= -7.8e-48) || ~((x_46_im <= 9.5e-97)))
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	else
		tmp = x_46_re * (3.0 * (x_46_re * x_46_im));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -7.8e-48], N[Not[LessEqual[x$46$im, 9.5e-97]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -7.8 \cdot 10^{-48} \lor \neg \left(x.im \leq 9.5 \cdot 10^{-97}\right):\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -7.800000000000001e-48 or 9.5000000000000001e-97 < x.im

    1. Initial program 77.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. Step-by-step derivation
      1. expm1-log1p-u43.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
      2. expm1-udef34.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
    3. Applied egg-rr0.0%

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

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

    if -7.800000000000001e-48 < x.im < 9.5000000000000001e-97

    1. Initial program 88.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. Step-by-step derivation
      1. add-log-exp50.1%

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

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

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

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right)\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      5. add-log-exp88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -7.8 \cdot 10^{-48} \lor \neg \left(x.im \leq 9.5 \cdot 10^{-97}\right):\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 9: 71.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -7 \cdot 10^{+153} \lor \neg \left(x.re \leq 4.5 \cdot 10^{+149}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -7e+153) (not (<= x.re 4.5e+149)))
   (* x.re (* x.re x.im))
   (* x.im (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -7e+153) || !(x_46_re <= 4.5e+149)) {
		tmp = x_46_re * (x_46_re * x_46_im);
	} else {
		tmp = x_46_im * (x_46_im * -x_46_im);
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46re <= (-7d+153)) .or. (.not. (x_46re <= 4.5d+149))) then
        tmp = x_46re * (x_46re * x_46im)
    else
        tmp = x_46im * (x_46im * -x_46im)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -7e+153) || !(x_46_re <= 4.5e+149)) {
		tmp = x_46_re * (x_46_re * x_46_im);
	} else {
		tmp = x_46_im * (x_46_im * -x_46_im);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -7e+153) or not (x_46_re <= 4.5e+149):
		tmp = x_46_re * (x_46_re * x_46_im)
	else:
		tmp = x_46_im * (x_46_im * -x_46_im)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -7e+153) || !(x_46_re <= 4.5e+149))
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_im));
	else
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= -7e+153) || ~((x_46_re <= 4.5e+149)))
		tmp = x_46_re * (x_46_re * x_46_im);
	else
		tmp = x_46_im * (x_46_im * -x_46_im);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -7e+153], N[Not[LessEqual[x$46$re, 4.5e+149]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -7 \cdot 10^{+153} \lor \neg \left(x.re \leq 4.5 \cdot 10^{+149}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -6.9999999999999998e153 or 4.49999999999999982e149 < x.re

    1. Initial program 55.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. Step-by-step derivation
      1. expm1-log1p-u27.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
      2. expm1-udef27.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
    3. Applied egg-rr0.0%

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

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

      \[\leadsto x.im \cdot \color{blue}{{x.re}^{2}} \]
    6. Simplified70.6%

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot x.im} \]
    8. Simplified73.1%

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

    if -6.9999999999999998e153 < x.re < 4.49999999999999982e149

    1. Initial program 89.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. Step-by-step derivation
      1. expm1-log1p-u65.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
      2. expm1-udef42.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
    3. Applied egg-rr0.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -7 \cdot 10^{+153} \lor \neg \left(x.re \leq 4.5 \cdot 10^{+149}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \]

Alternative 10: 33.7% accurate, 3.8× speedup?

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

\\
x.im \cdot \left(x.re \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 81.3%

    \[\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. Step-by-step derivation
    1. expm1-log1p-u56.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
    2. expm1-udef38.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
  3. Applied egg-rr0.0%

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

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

    \[\leadsto x.im \cdot \color{blue}{{x.re}^{2}} \]
  6. Simplified34.1%

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

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

Alternative 11: 34.4% accurate, 3.8× speedup?

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

\\
x.re \cdot \left(x.re \cdot x.im\right)
\end{array}
Derivation
  1. Initial program 81.3%

    \[\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. Step-by-step derivation
    1. expm1-log1p-u56.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\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\right)\right)} \]
    2. expm1-udef38.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\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\right)} - 1} \]
  3. Applied egg-rr0.0%

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

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

    \[\leadsto x.im \cdot \color{blue}{{x.re}^{2}} \]
  6. Simplified34.1%

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

    \[\leadsto \color{blue}{{x.re}^{2} \cdot x.im} \]
  8. Simplified34.6%

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

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

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

  :herbie-target
  (+ (* (* 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)))