math.cube on complex, imaginary part

Percentage Accurate: 82.1% → 99.3%
Time: 8.2s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 82.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2.6 \cdot 10^{+121} \lor \neg \left(x.im \leq 10^{+86}\right):\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - {x.im}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -2.6e+121) (not (<= x.im 1e+86)))
   (* (- x.re x.im) (* x.im (+ x.im x.re)))
   (- (* x.re (* x.re (* x.im 3.0))) (pow x.im 3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -2.6e+121) || !(x_46_im <= 1e+86)) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else {
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - pow(x_46_im, 3.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) :: tmp
    if ((x_46im <= (-2.6d+121)) .or. (.not. (x_46im <= 1d+86))) then
        tmp = (x_46re - x_46im) * (x_46im * (x_46im + x_46re))
    else
        tmp = (x_46re * (x_46re * (x_46im * 3.0d0))) - (x_46im ** 3.0d0)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -2.6e+121) || !(x_46_im <= 1e+86)) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else {
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - Math.pow(x_46_im, 3.0);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -2.6e+121) or not (x_46_im <= 1e+86):
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re))
	else:
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - math.pow(x_46_im, 3.0)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= -2.6e+121) || !(x_46_im <= 1e+86))
		tmp = Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_im + x_46_re)));
	else
		tmp = Float64(Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0))) - (x_46_im ^ 3.0));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_im <= -2.6e+121) || ~((x_46_im <= 1e+86)))
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	else
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - (x_46_im ^ 3.0);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -2.6e+121], N[Not[LessEqual[x$46$im, 1e+86]], $MachinePrecision]], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2.6 \cdot 10^{+121} \lor \neg \left(x.im \leq 10^{+86}\right):\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -2.5999999999999999e121 or 1e86 < x.im

    1. Initial program 61.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. difference-of-squares71.1%

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

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

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

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

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

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

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

    if -2.5999999999999999e121 < x.im < 1e86

    1. Initial program 91.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. +-commutative91.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -2.6 \cdot 10^{+121} \lor \neg \left(x.im \leq 10^{+86}\right):\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - {x.im}^{3}\\ \end{array} \]

Alternative 2: 99.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2.6 \cdot 10^{+121} \lor \neg \left(x.im \leq 1.5 \cdot 10^{+87}\right):\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.im \cdot x.re\right)\right) - {x.im}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -2.6e+121) (not (<= x.im 1.5e+87)))
   (* (- x.re x.im) (* x.im (+ x.im x.re)))
   (- (* x.re (* 3.0 (* x.im x.re))) (pow x.im 3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -2.6e+121) || !(x_46_im <= 1.5e+87)) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else {
		tmp = (x_46_re * (3.0 * (x_46_im * x_46_re))) - pow(x_46_im, 3.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) :: tmp
    if ((x_46im <= (-2.6d+121)) .or. (.not. (x_46im <= 1.5d+87))) then
        tmp = (x_46re - x_46im) * (x_46im * (x_46im + x_46re))
    else
        tmp = (x_46re * (3.0d0 * (x_46im * x_46re))) - (x_46im ** 3.0d0)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -2.6e+121) || !(x_46_im <= 1.5e+87)) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else {
		tmp = (x_46_re * (3.0 * (x_46_im * x_46_re))) - Math.pow(x_46_im, 3.0);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -2.6e+121) or not (x_46_im <= 1.5e+87):
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re))
	else:
		tmp = (x_46_re * (3.0 * (x_46_im * x_46_re))) - math.pow(x_46_im, 3.0)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= -2.6e+121) || !(x_46_im <= 1.5e+87))
		tmp = Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_im + x_46_re)));
	else
		tmp = Float64(Float64(x_46_re * Float64(3.0 * Float64(x_46_im * x_46_re))) - (x_46_im ^ 3.0));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_im <= -2.6e+121) || ~((x_46_im <= 1.5e+87)))
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	else
		tmp = (x_46_re * (3.0 * (x_46_im * x_46_re))) - (x_46_im ^ 3.0);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -2.6e+121], N[Not[LessEqual[x$46$im, 1.5e+87]], $MachinePrecision]], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2.6 \cdot 10^{+121} \lor \neg \left(x.im \leq 1.5 \cdot 10^{+87}\right):\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -2.5999999999999999e121 or 1.4999999999999999e87 < x.im

    1. Initial program 61.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. difference-of-squares71.1%

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

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

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

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

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

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

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

    if -2.5999999999999999e121 < x.im < 1.4999999999999999e87

    1. Initial program 91.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. +-commutative91.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -2.6 \cdot 10^{+121} \lor \neg \left(x.im \leq 1.5 \cdot 10^{+87}\right):\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.im \cdot x.re\right)\right) - {x.im}^{3}\\ \end{array} \]

Alternative 3: 98.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ t_1 := x.re \cdot \left(x.im \cdot \left(x.re + x.re\right)\right) + x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \mathbf{if}\;x.im \leq -2.5 \cdot 10^{+90}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq -5.8 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.im \leq 1.3 \cdot 10^{-122}:\\ \;\;\;\;\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\\ \mathbf{elif}\;x.im \leq 2 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* (- x.re x.im) (* x.im (+ x.im x.re))))
        (t_1
         (+
          (* x.re (* x.im (+ x.re x.re)))
          (* x.im (* (- x.re x.im) (+ x.im x.re))))))
   (if (<= x.im -2.5e+90)
     t_0
     (if (<= x.im -5.8e-170)
       t_1
       (if (<= x.im 1.3e-122)
         (* (* x.re 3.0) (* x.im x.re))
         (if (<= x.im 2e+58) t_1 t_0))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	double t_1 = (x_46_re * (x_46_im * (x_46_re + x_46_re))) + (x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)));
	double tmp;
	if (x_46_im <= -2.5e+90) {
		tmp = t_0;
	} else if (x_46_im <= -5.8e-170) {
		tmp = t_1;
	} else if (x_46_im <= 1.3e-122) {
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	} else if (x_46_im <= 2e+58) {
		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 - x_46im) * (x_46im * (x_46im + x_46re))
    t_1 = (x_46re * (x_46im * (x_46re + x_46re))) + (x_46im * ((x_46re - x_46im) * (x_46im + x_46re)))
    if (x_46im <= (-2.5d+90)) then
        tmp = t_0
    else if (x_46im <= (-5.8d-170)) then
        tmp = t_1
    else if (x_46im <= 1.3d-122) then
        tmp = (x_46re * 3.0d0) * (x_46im * x_46re)
    else if (x_46im <= 2d+58) 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 - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	double t_1 = (x_46_re * (x_46_im * (x_46_re + x_46_re))) + (x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)));
	double tmp;
	if (x_46_im <= -2.5e+90) {
		tmp = t_0;
	} else if (x_46_im <= -5.8e-170) {
		tmp = t_1;
	} else if (x_46_im <= 1.3e-122) {
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	} else if (x_46_im <= 2e+58) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re))
	t_1 = (x_46_re * (x_46_im * (x_46_re + x_46_re))) + (x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)))
	tmp = 0
	if x_46_im <= -2.5e+90:
		tmp = t_0
	elif x_46_im <= -5.8e-170:
		tmp = t_1
	elif x_46_im <= 1.3e-122:
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re)
	elif x_46_im <= 2e+58:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_im + x_46_re)))
	t_1 = Float64(Float64(x_46_re * Float64(x_46_im * Float64(x_46_re + x_46_re))) + Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im + x_46_re))))
	tmp = 0.0
	if (x_46_im <= -2.5e+90)
		tmp = t_0;
	elseif (x_46_im <= -5.8e-170)
		tmp = t_1;
	elseif (x_46_im <= 1.3e-122)
		tmp = Float64(Float64(x_46_re * 3.0) * Float64(x_46_im * x_46_re));
	elseif (x_46_im <= 2e+58)
		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 - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	t_1 = (x_46_re * (x_46_im * (x_46_re + x_46_re))) + (x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)));
	tmp = 0.0;
	if (x_46_im <= -2.5e+90)
		tmp = t_0;
	elseif (x_46_im <= -5.8e-170)
		tmp = t_1;
	elseif (x_46_im <= 1.3e-122)
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	elseif (x_46_im <= 2e+58)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$re * N[(x$46$im * N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -2.5e+90], t$95$0, If[LessEqual[x$46$im, -5.8e-170], t$95$1, If[LessEqual[x$46$im, 1.3e-122], N[(N[(x$46$re * 3.0), $MachinePrecision] * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 2e+58], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x.im \leq -5.8 \cdot 10^{-170}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x.im \leq 2 \cdot 10^{+58}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -2.5000000000000002e90 or 1.99999999999999989e58 < x.im

    1. Initial program 67.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. difference-of-squares75.2%

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

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

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

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

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

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

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

    if -2.5000000000000002e90 < x.im < -5.8000000000000001e-170 or 1.29999999999999988e-122 < x.im < 1.99999999999999989e58

    1. Initial program 98.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. difference-of-squares98.7%

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

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

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

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

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

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

    if -5.8000000000000001e-170 < x.im < 1.29999999999999988e-122

    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. +-commutative81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot \left(x.im \cdot 3\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
      17. cube-unmult99.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -2.5 \cdot 10^{+90}:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{elif}\;x.im \leq -5.8 \cdot 10^{-170}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.re + x.re\right)\right) + x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 1.3 \cdot 10^{-122}:\\ \;\;\;\;\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\\ \mathbf{elif}\;x.im \leq 2 \cdot 10^{+58}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.re + x.re\right)\right) + x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \end{array} \]

Alternative 4: 99.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2 \cdot 10^{+90} \lor \neg \left(x.im \leq 10^{+59}\right):\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot \left(x.im \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right)\right) + x.re \cdot \left(x.im \cdot \left(x.re + x.re\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -2e+90) (not (<= x.im 1e+59)))
   (* (- x.re x.im) (* x.im (+ x.im x.re)))
   (+
    (- (* x.re (* x.im x.re)) (* x.im (* x.im x.im)))
    (* x.re (* x.im (+ x.re x.re))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -2e+90) || !(x_46_im <= 1e+59)) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else {
		tmp = ((x_46_re * (x_46_im * x_46_re)) - (x_46_im * (x_46_im * x_46_im))) + (x_46_re * (x_46_im * (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_46im <= (-2d+90)) .or. (.not. (x_46im <= 1d+59))) then
        tmp = (x_46re - x_46im) * (x_46im * (x_46im + x_46re))
    else
        tmp = ((x_46re * (x_46im * x_46re)) - (x_46im * (x_46im * x_46im))) + (x_46re * (x_46im * (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_im <= -2e+90) || !(x_46_im <= 1e+59)) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else {
		tmp = ((x_46_re * (x_46_im * x_46_re)) - (x_46_im * (x_46_im * x_46_im))) + (x_46_re * (x_46_im * (x_46_re + x_46_re)));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -2e+90) or not (x_46_im <= 1e+59):
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re))
	else:
		tmp = ((x_46_re * (x_46_im * x_46_re)) - (x_46_im * (x_46_im * x_46_im))) + (x_46_re * (x_46_im * (x_46_re + x_46_re)))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= -2e+90) || !(x_46_im <= 1e+59))
		tmp = Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_im + x_46_re)));
	else
		tmp = Float64(Float64(Float64(x_46_re * Float64(x_46_im * x_46_re)) - Float64(x_46_im * Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(x_46_im * 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_im <= -2e+90) || ~((x_46_im <= 1e+59)))
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	else
		tmp = ((x_46_re * (x_46_im * x_46_re)) - (x_46_im * (x_46_im * x_46_im))) + (x_46_re * (x_46_im * (x_46_re + x_46_re)));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -2e+90], N[Not[LessEqual[x$46$im, 1e+59]], $MachinePrecision]], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(x$46$im * N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2 \cdot 10^{+90} \lor \neg \left(x.im \leq 10^{+59}\right):\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.99999999999999993e90 or 9.99999999999999972e58 < x.im

    1. Initial program 67.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. difference-of-squares75.2%

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

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

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

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

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

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

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

    if -1.99999999999999993e90 < x.im < 9.99999999999999972e58

    1. Initial program 90.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. difference-of-squares90.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 92.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -3.8 \cdot 10^{-58} \lor \neg \left(x.im \leq 5 \cdot 10^{-84}\right):\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -3.8e-58) (not (<= x.im 5e-84)))
   (* (- x.re x.im) (* x.im (+ x.im x.re)))
   (* (* x.re 3.0) (* x.im x.re))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -3.8e-58) || !(x_46_im <= 5e-84)) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else {
		tmp = (x_46_re * 3.0) * (x_46_im * 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_46im <= (-3.8d-58)) .or. (.not. (x_46im <= 5d-84))) then
        tmp = (x_46re - x_46im) * (x_46im * (x_46im + x_46re))
    else
        tmp = (x_46re * 3.0d0) * (x_46im * 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_im <= -3.8e-58) || !(x_46_im <= 5e-84)) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else {
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -3.8e-58) or not (x_46_im <= 5e-84):
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re))
	else:
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= -3.8e-58) || !(x_46_im <= 5e-84))
		tmp = Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_im + x_46_re)));
	else
		tmp = Float64(Float64(x_46_re * 3.0) * Float64(x_46_im * x_46_re));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_im <= -3.8e-58) || ~((x_46_im <= 5e-84)))
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	else
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -3.8e-58], N[Not[LessEqual[x$46$im, 5e-84]], $MachinePrecision]], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * 3.0), $MachinePrecision] * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -3.8 \cdot 10^{-58} \lor \neg \left(x.im \leq 5 \cdot 10^{-84}\right):\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.7999999999999997e-58 or 5.0000000000000002e-84 < x.im

    1. Initial program 79.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. difference-of-squares84.5%

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

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

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

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

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

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

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

    if -3.7999999999999997e-58 < x.im < 5.0000000000000002e-84

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3.8 \cdot 10^{-58} \lor \neg \left(x.im \leq 5 \cdot 10^{-84}\right):\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\\ \end{array} \]

Alternative 6: 92.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -6.5 \cdot 10^{-58}:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 6.8 \cdot 10^{-84}:\\ \;\;\;\;\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -6.5e-58)
   (* (- x.re x.im) (* x.im (+ x.im x.re)))
   (if (<= x.im 6.8e-84)
     (* (* x.re 3.0) (* x.im x.re))
     (* x.im (* (- x.re x.im) (+ x.im x.re))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -6.5e-58) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else if (x_46_im <= 6.8e-84) {
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	} else {
		tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + 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_46im <= (-6.5d-58)) then
        tmp = (x_46re - x_46im) * (x_46im * (x_46im + x_46re))
    else if (x_46im <= 6.8d-84) then
        tmp = (x_46re * 3.0d0) * (x_46im * x_46re)
    else
        tmp = x_46im * ((x_46re - x_46im) * (x_46im + 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_im <= -6.5e-58) {
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	} else if (x_46_im <= 6.8e-84) {
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	} else {
		tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -6.5e-58:
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re))
	elif x_46_im <= 6.8e-84:
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re)
	else:
		tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -6.5e-58)
		tmp = Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_im + x_46_re)));
	elseif (x_46_im <= 6.8e-84)
		tmp = Float64(Float64(x_46_re * 3.0) * Float64(x_46_im * x_46_re));
	else
		tmp = Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im + x_46_re)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= -6.5e-58)
		tmp = (x_46_re - x_46_im) * (x_46_im * (x_46_im + x_46_re));
	elseif (x_46_im <= 6.8e-84)
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	else
		tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -6.5e-58], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 6.8e-84], N[(N[(x$46$re * 3.0), $MachinePrecision] * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 83.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. difference-of-squares86.5%

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

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

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

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

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

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

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

    if -6.49999999999999964e-58 < x.im < 6.80000000000000042e-84

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.80000000000000042e-84 < x.im

    1. Initial program 77.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. difference-of-squares83.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + x.re \cdot \left(x.im \cdot \left(x.re + \color{blue}{\sqrt{-x.re} \cdot \sqrt{-x.re}}\right)\right) \]
      8. add-sqr-sqrt95.8%

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + x.re \cdot \color{blue}{\left(x.re - x.re\right)} \]
      15. distribute-lft-out--65.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -6.5 \cdot 10^{-58}:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.im + x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 6.8 \cdot 10^{-84}:\\ \;\;\;\;\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \end{array} \]

Alternative 7: 61.6% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -3.7 \cdot 10^{+147}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -3.7e+147)
   (* x.re (* x.im (- x.re)))
   (if (<= x.im 5e+132) (* x.im (* x.re (* x.re 3.0))) (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -3.7e+147) {
		tmp = x_46_re * (x_46_im * -x_46_re);
	} else if (x_46_im <= 5e+132) {
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	} else {
		tmp = 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_46im <= (-3.7d+147)) then
        tmp = x_46re * (x_46im * -x_46re)
    else if (x_46im <= 5d+132) then
        tmp = x_46im * (x_46re * (x_46re * 3.0d0))
    else
        tmp = 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_im <= -3.7e+147) {
		tmp = x_46_re * (x_46_im * -x_46_re);
	} else if (x_46_im <= 5e+132) {
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	} else {
		tmp = x_46_im * -x_46_im;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -3.7e+147:
		tmp = x_46_re * (x_46_im * -x_46_re)
	elif x_46_im <= 5e+132:
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0))
	else:
		tmp = x_46_im * -x_46_im
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -3.7e+147)
		tmp = Float64(x_46_re * Float64(x_46_im * Float64(-x_46_re)));
	elseif (x_46_im <= 5e+132)
		tmp = Float64(x_46_im * Float64(x_46_re * Float64(x_46_re * 3.0)));
	else
		tmp = 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 <= -3.7e+147)
		tmp = x_46_re * (x_46_im * -x_46_re);
	elseif (x_46_im <= 5e+132)
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	else
		tmp = x_46_im * -x_46_im;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -3.7e+147], N[(x$46$re * N[(x$46$im * (-x$46$re)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 5e+132], N[(x$46$im * N[(x$46$re * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * (-x$46$im)), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re \cdot 3\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -3.7e147

    1. Initial program 56.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. +-commutative56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\left(\color{blue}{\left(x.re \cdot x.re\right)} \cdot x.im\right) \cdot 3\right)} - 1 \]
      5. associate-*l*0.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right)} \cdot 3\right)} - 1 \]
    6. Applied egg-rr0.4%

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

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

    if -3.7e147 < x.im < 5.0000000000000001e132

    1. Initial program 92.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. difference-of-squares92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e132 < x.im

    1. Initial program 50.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. difference-of-squares63.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    5. Simplified76.4%

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

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

Alternative 8: 61.6% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2.6 \cdot 10^{+148}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\ \;\;\;\;\left(x.im \cdot 3\right) \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -2.6e+148)
   (* x.re (* x.im (- x.re)))
   (if (<= x.im 5e+132) (* (* x.im 3.0) (* x.re x.re)) (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -2.6e+148) {
		tmp = x_46_re * (x_46_im * -x_46_re);
	} else if (x_46_im <= 5e+132) {
		tmp = (x_46_im * 3.0) * (x_46_re * x_46_re);
	} else {
		tmp = 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_46im <= (-2.6d+148)) then
        tmp = x_46re * (x_46im * -x_46re)
    else if (x_46im <= 5d+132) then
        tmp = (x_46im * 3.0d0) * (x_46re * x_46re)
    else
        tmp = 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_im <= -2.6e+148) {
		tmp = x_46_re * (x_46_im * -x_46_re);
	} else if (x_46_im <= 5e+132) {
		tmp = (x_46_im * 3.0) * (x_46_re * x_46_re);
	} else {
		tmp = x_46_im * -x_46_im;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -2.6e+148:
		tmp = x_46_re * (x_46_im * -x_46_re)
	elif x_46_im <= 5e+132:
		tmp = (x_46_im * 3.0) * (x_46_re * x_46_re)
	else:
		tmp = x_46_im * -x_46_im
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -2.6e+148)
		tmp = Float64(x_46_re * Float64(x_46_im * Float64(-x_46_re)));
	elseif (x_46_im <= 5e+132)
		tmp = Float64(Float64(x_46_im * 3.0) * Float64(x_46_re * x_46_re));
	else
		tmp = 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 <= -2.6e+148)
		tmp = x_46_re * (x_46_im * -x_46_re);
	elseif (x_46_im <= 5e+132)
		tmp = (x_46_im * 3.0) * (x_46_re * x_46_re);
	else
		tmp = x_46_im * -x_46_im;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -2.6e+148], N[(x$46$re * N[(x$46$im * (-x$46$re)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 5e+132], N[(N[(x$46$im * 3.0), $MachinePrecision] * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * (-x$46$im)), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\
\;\;\;\;\left(x.im \cdot 3\right) \cdot \left(x.re \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -2.6e148

    1. Initial program 56.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. +-commutative56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\left(\color{blue}{\left(x.re \cdot x.re\right)} \cdot x.im\right) \cdot 3\right)} - 1 \]
      5. associate-*l*0.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right)} \cdot 3\right)} - 1 \]
    6. Applied egg-rr0.4%

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

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

    if -2.6e148 < x.im < 5.0000000000000001e132

    1. Initial program 92.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. difference-of-squares92.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e132 < x.im

    1. Initial program 50.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. difference-of-squares63.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    5. Simplified76.4%

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

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

Alternative 9: 67.6% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2.8 \cdot 10^{+148}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\ \;\;\;\;\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -2.8e+148)
   (* x.re (* x.im (- x.re)))
   (if (<= x.im 5e+132) (* (* x.re 3.0) (* x.im x.re)) (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -2.8e+148) {
		tmp = x_46_re * (x_46_im * -x_46_re);
	} else if (x_46_im <= 5e+132) {
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	} else {
		tmp = 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_46im <= (-2.8d+148)) then
        tmp = x_46re * (x_46im * -x_46re)
    else if (x_46im <= 5d+132) then
        tmp = (x_46re * 3.0d0) * (x_46im * x_46re)
    else
        tmp = 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_im <= -2.8e+148) {
		tmp = x_46_re * (x_46_im * -x_46_re);
	} else if (x_46_im <= 5e+132) {
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	} else {
		tmp = x_46_im * -x_46_im;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -2.8e+148:
		tmp = x_46_re * (x_46_im * -x_46_re)
	elif x_46_im <= 5e+132:
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re)
	else:
		tmp = x_46_im * -x_46_im
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -2.8e+148)
		tmp = Float64(x_46_re * Float64(x_46_im * Float64(-x_46_re)));
	elseif (x_46_im <= 5e+132)
		tmp = Float64(Float64(x_46_re * 3.0) * Float64(x_46_im * x_46_re));
	else
		tmp = 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 <= -2.8e+148)
		tmp = x_46_re * (x_46_im * -x_46_re);
	elseif (x_46_im <= 5e+132)
		tmp = (x_46_re * 3.0) * (x_46_im * x_46_re);
	else
		tmp = x_46_im * -x_46_im;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -2.8e+148], N[(x$46$re * N[(x$46$im * (-x$46$re)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 5e+132], N[(N[(x$46$re * 3.0), $MachinePrecision] * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * (-x$46$im)), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\
\;\;\;\;\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -2.7999999999999998e148

    1. Initial program 56.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. +-commutative56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\left(\color{blue}{\left(x.re \cdot x.re\right)} \cdot x.im\right) \cdot 3\right)} - 1 \]
      5. associate-*l*0.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right)} \cdot 3\right)} - 1 \]
    6. Applied egg-rr0.4%

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

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

    if -2.7999999999999998e148 < x.im < 5.0000000000000001e132

    1. Initial program 92.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. +-commutative92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e132 < x.im

    1. Initial program 50.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. difference-of-squares63.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    5. Simplified76.4%

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

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

Alternative 10: 46.8% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -1.05 \cdot 10^{+148}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -1.05e+148)
   (* x.re (* x.im (- x.re)))
   (if (<= x.im 5e+132) (* x.re (* x.im x.re)) (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -1.05e+148) {
		tmp = x_46_re * (x_46_im * -x_46_re);
	} else if (x_46_im <= 5e+132) {
		tmp = x_46_re * (x_46_im * x_46_re);
	} else {
		tmp = 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_46im <= (-1.05d+148)) then
        tmp = x_46re * (x_46im * -x_46re)
    else if (x_46im <= 5d+132) then
        tmp = x_46re * (x_46im * x_46re)
    else
        tmp = 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_im <= -1.05e+148) {
		tmp = x_46_re * (x_46_im * -x_46_re);
	} else if (x_46_im <= 5e+132) {
		tmp = x_46_re * (x_46_im * x_46_re);
	} else {
		tmp = x_46_im * -x_46_im;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -1.05e+148:
		tmp = x_46_re * (x_46_im * -x_46_re)
	elif x_46_im <= 5e+132:
		tmp = x_46_re * (x_46_im * x_46_re)
	else:
		tmp = x_46_im * -x_46_im
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -1.05e+148)
		tmp = Float64(x_46_re * Float64(x_46_im * Float64(-x_46_re)));
	elseif (x_46_im <= 5e+132)
		tmp = Float64(x_46_re * Float64(x_46_im * x_46_re));
	else
		tmp = 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 <= -1.05e+148)
		tmp = x_46_re * (x_46_im * -x_46_re);
	elseif (x_46_im <= 5e+132)
		tmp = x_46_re * (x_46_im * x_46_re);
	else
		tmp = x_46_im * -x_46_im;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -1.05e+148], N[(x$46$re * N[(x$46$im * (-x$46$re)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 5e+132], N[(x$46$re * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * (-x$46$im)), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -1.04999999999999999e148

    1. Initial program 56.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. +-commutative56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\left(\color{blue}{\left(x.re \cdot x.re\right)} \cdot x.im\right) \cdot 3\right)} - 1 \]
      5. associate-*l*0.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right)} \cdot 3\right)} - 1 \]
    6. Applied egg-rr0.4%

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

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

    if -1.04999999999999999e148 < x.im < 5.0000000000000001e132

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}}} \]
      20. flip-+16.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{\frac{1}{\frac{x.re - x.re}{\color{blue}{x.re \cdot x.re - x.re \cdot x.re}}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      9. clear-num0.0%

        \[\leadsto \log \left(e^{\color{blue}{\frac{x.re \cdot x.re - x.re \cdot x.re}{x.re - x.re}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      10. flip-+30.9%

        \[\leadsto \log \left(e^{\color{blue}{x.re + x.re}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      11. add-sqr-sqrt16.4%

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

        \[\leadsto \log \left(e^{x.re + \color{blue}{\sqrt{x.re \cdot x.re}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      13. sqr-neg35.9%

        \[\leadsto \log \left(e^{x.re + \sqrt{\color{blue}{\left(-x.re\right) \cdot \left(-x.re\right)}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      14. sqrt-unprod18.9%

        \[\leadsto \log \left(e^{x.re + \color{blue}{\sqrt{-x.re} \cdot \sqrt{-x.re}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      15. add-sqr-sqrt40.1%

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

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

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

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

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

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

    if 5.0000000000000001e132 < x.im

    1. Initial program 50.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. difference-of-squares63.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    5. Simplified76.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1.05 \cdot 10^{+148}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 5 \cdot 10^{+132}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-x.im\right)\\ \end{array} \]

Alternative 11: 43.8% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq 5 \cdot 10^{+132}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 5e+132) (* x.re (* x.im x.re)) (* x.im (- x.im))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 5e+132) {
		tmp = x_46_re * (x_46_im * x_46_re);
	} else {
		tmp = 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_46im <= 5d+132) then
        tmp = x_46re * (x_46im * x_46re)
    else
        tmp = 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_im <= 5e+132) {
		tmp = x_46_re * (x_46_im * x_46_re);
	} else {
		tmp = x_46_im * -x_46_im;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= 5e+132:
		tmp = x_46_re * (x_46_im * x_46_re)
	else:
		tmp = x_46_im * -x_46_im
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= 5e+132)
		tmp = Float64(x_46_re * Float64(x_46_im * x_46_re));
	else
		tmp = 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 <= 5e+132)
		tmp = x_46_re * (x_46_im * x_46_re);
	else
		tmp = x_46_im * -x_46_im;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 5e+132], N[(x$46$re * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * (-x$46$im)), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 88.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.re around inf 55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}}} \]
      20. flip-+15.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{\frac{1}{\frac{x.re - x.re}{\color{blue}{x.re \cdot x.re - x.re \cdot x.re}}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      9. clear-num0.0%

        \[\leadsto \log \left(e^{\color{blue}{\frac{x.re \cdot x.re - x.re \cdot x.re}{x.re - x.re}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      10. flip-+27.6%

        \[\leadsto \log \left(e^{\color{blue}{x.re + x.re}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      11. add-sqr-sqrt14.7%

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

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

        \[\leadsto \log \left(e^{x.re + \sqrt{\color{blue}{\left(-x.re\right) \cdot \left(-x.re\right)}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      14. sqrt-unprod16.9%

        \[\leadsto \log \left(e^{x.re + \color{blue}{\sqrt{-x.re} \cdot \sqrt{-x.re}}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      15. add-sqr-sqrt36.7%

        \[\leadsto \log \left(e^{x.re + \color{blue}{\left(-x.re\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      16. sub-neg36.7%

        \[\leadsto \log \left(e^{\color{blue}{x.re - x.re}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      17. +-inverses36.7%

        \[\leadsto \log \left(e^{\color{blue}{0}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      18. 1-exp36.7%

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

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

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

    if 5.0000000000000001e132 < x.im

    1. Initial program 50.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. difference-of-squares63.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    5. Simplified76.4%

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

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

Alternative 12: 31.8% accurate, 3.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2.8 \cdot 10^{-187}:\\ \;\;\;\;x.re \cdot \left(-x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -2.8e-187) (* x.re (- x.re)) (* x.im (- x.im))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -2.8e-187) {
		tmp = x_46_re * -x_46_re;
	} else {
		tmp = 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_46im <= (-2.8d-187)) then
        tmp = x_46re * -x_46re
    else
        tmp = 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_im <= -2.8e-187) {
		tmp = x_46_re * -x_46_re;
	} else {
		tmp = x_46_im * -x_46_im;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -2.8e-187:
		tmp = x_46_re * -x_46_re
	else:
		tmp = x_46_im * -x_46_im
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -2.8e-187)
		tmp = Float64(x_46_re * Float64(-x_46_re));
	else
		tmp = 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 <= -2.8e-187)
		tmp = x_46_re * -x_46_re;
	else
		tmp = x_46_im * -x_46_im;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -2.8e-187], N[(x$46$re * (-x$46$re)), $MachinePrecision], N[(x$46$im * (-x$46$im)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2.8 \cdot 10^{-187}:\\
\;\;\;\;x.re \cdot \left(-x.re\right)\\

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


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

    1. Initial program 86.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. difference-of-squares88.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.re}^{2}} \]
    8. Step-by-step derivation
      1. unpow219.6%

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

        \[\leadsto \color{blue}{-x.re \cdot x.re} \]
      3. distribute-rgt-neg-in19.6%

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

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

    if -2.8e-187 < x.im

    1. Initial program 79.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. difference-of-squares83.1%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    5. Simplified40.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -2.8 \cdot 10^{-187}:\\ \;\;\;\;x.re \cdot \left(-x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-x.im\right)\\ \end{array} \]

Alternative 13: 25.4% accurate, 4.8× speedup?

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

\\
x.im \cdot \left(-x.im\right)
\end{array}
Derivation
  1. Initial program 81.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. difference-of-squares85.0%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
  5. Simplified28.8%

    \[\leadsto \color{blue}{x.im \cdot \left(-x.im\right)} \]
  6. Final simplification28.8%

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

Alternative 14: 4.5% accurate, 6.3× speedup?

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

\\
x.im \cdot -3
\end{array}
Derivation
  1. Initial program 81.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. *-commutative81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-3 \cdot x.im} \]
  7. Step-by-step derivation
    1. *-commutative4.8%

      \[\leadsto \color{blue}{x.im \cdot -3} \]
  8. Simplified4.8%

    \[\leadsto \color{blue}{x.im \cdot -3} \]
  9. Final simplification4.8%

    \[\leadsto x.im \cdot -3 \]

Alternative 15: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} \\ -10 \end{array} \]
(FPCore (x.re x.im) :precision binary64 -10.0)
double code(double x_46_re, double x_46_im) {
	return -10.0;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = -10.0d0
end function
public static double code(double x_46_re, double x_46_im) {
	return -10.0;
}
def code(x_46_re, x_46_im):
	return -10.0
function code(x_46_re, x_46_im)
	return -10.0
end
function tmp = code(x_46_re, x_46_im)
	tmp = -10.0;
end
code[x$46$re_, x$46$im_] := -10.0
\begin{array}{l}

\\
-10
\end{array}
Derivation
  1. Initial program 81.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. +-commutative81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot \left(x.im \cdot 3\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
    17. cube-unmult84.7%

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

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

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

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

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

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

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

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

      \[\leadsto \left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot \color{blue}{9} - {x.im}^{3} \cdot {x.im}^{3}\right) \cdot \frac{1}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3 + {x.im}^{3}} \]
    8. pow-prod-up21.7%

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

      \[\leadsto \left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{\color{blue}{6}}\right) \cdot \frac{1}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3 + {x.im}^{3}} \]
    10. associate-*l*21.6%

      \[\leadsto \left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{6}\right) \cdot \frac{1}{\color{blue}{x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right)} + {x.im}^{3}} \]
    11. associate-*r*21.6%

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

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

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

    \[\leadsto \color{blue}{-10} \]
  7. Final simplification2.9%

    \[\leadsto -10 \]

Developer target: 91.1% 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 2023194 
(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)))