math.cube on complex, real part

Percentage Accurate: 82.8% → 96.5%
Time: 6.9s
Alternatives: 9
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 82.8% accurate, 1.0× speedup?

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

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

Alternative 1: 96.5% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*69.4%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--69.4%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*69.4%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
      16. metadata-eval69.4%

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

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

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

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

Alternative 2: 96.5% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot x.im\right) \cdot x.im + x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      12. sqr-neg38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 96.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 50.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8e153 < x.im < 4.80000000000000016e139

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*99.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--99.7%

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

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

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

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

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

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

    if 4.80000000000000016e139 < x.im

    1. Initial program 53.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \log \left(e^{x.re}\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      2. difference-of-squares35.5%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -8 \cdot 10^{+153}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \mathbf{elif}\;x.im \leq 4.8 \cdot 10^{+139}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(-x.im\right)\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\ \end{array} \]

Alternative 4: 96.7% accurate, 1.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -8e153 or 4.80000000000000016e139 < x.im

    1. Initial program 51.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative51.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8e153 < x.im < 4.80000000000000016e139

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
      13. associate-*l*99.7%

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
      14. distribute-rgt-out--99.7%

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

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

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

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

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

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

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

Alternative 5: 61.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.75 \cdot 10^{+177} \lor \neg \left(x.re \leq 5.5 \cdot 10^{+149}\right):\\
\;\;\;\;x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot 3\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -1.74999999999999996e177 or 5.49999999999999999e149 < x.re

    1. Initial program 47.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.74999999999999996e177 < x.re < 5.49999999999999999e149

    1. Initial program 89.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative89.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \log \left(e^{x.re}\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      2. difference-of-squares38.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 61.0% accurate, 1.7× speedup?

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

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

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

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


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

    1. Initial program 45.8%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative45.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55e174 < x.re < 6.19999999999999951e148

    1. Initial program 89.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Step-by-step derivation
      1. *-commutative89.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \log \left(e^{x.re}\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      2. difference-of-squares38.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.19999999999999951e148 < x.re

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 50.6% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right) \]
    13. associate-*l*88.5%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right) \]
    14. distribute-rgt-out--88.5%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
    15. associate-*r*88.5%

      \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right) \]
    16. metadata-eval88.5%

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

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

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

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

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

Alternative 8: 56.4% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 56.4% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Developer target: 88.5% accurate, 1.1× speedup?

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

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

Reproduce

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

  :herbie-target
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im))))

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