math.cube on complex, real part

Percentage Accurate: 83.1% → 96.1%
Time: 5.8s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 83.1% 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.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.im \cdot -3\right)\\ \mathbf{if}\;x.re \leq -2 \cdot 10^{+152}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re - t_0\right)\\ \mathbf{elif}\;x.re \leq 7.5 \cdot 10^{-59}:\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - x.im \cdot \left(x.im \cdot \left(x.re + x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, t_0\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.im (* x.im -3.0))))
   (if (<= x.re -2e+152)
     (* x.re (- (* x.re x.re) t_0))
     (if (<= x.re 7.5e-59)
       (-
        (* (+ x.re x.im) (* x.re (- x.re x.im)))
        (* x.im (* x.im (+ x.re x.re))))
       (* x.re (fma x.re x.re t_0))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_im * -3.0);
	double tmp;
	if (x_46_re <= -2e+152) {
		tmp = x_46_re * ((x_46_re * x_46_re) - t_0);
	} else if (x_46_re <= 7.5e-59) {
		tmp = ((x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))) - (x_46_im * (x_46_im * (x_46_re + x_46_re)));
	} else {
		tmp = x_46_re * fma(x_46_re, x_46_re, t_0);
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_im * Float64(x_46_im * -3.0))
	tmp = 0.0
	if (x_46_re <= -2e+152)
		tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - t_0));
	elseif (x_46_re <= 7.5e-59)
		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_im * Float64(x_46_re + x_46_re))));
	else
		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, t_0));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -2e+152], N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 7.5e-59], 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$im * N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re + t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{else}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, t_0\right)\\


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

    1. Initial program 61.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. *-commutative61.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-out61.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*61.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. *-commutative61.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--80.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-80.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-80.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-neg80.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+80.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-udef83.9%

        \[\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-183.9%

        \[\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-283.9%

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

        \[\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--83.9%

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

        \[\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-eval83.9%

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

      \[\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-udef80.6%

        \[\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-rr80.6%

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

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

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

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

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

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

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

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

    if -2.0000000000000001e152 < x.re < 7.50000000000000019e-59

    1. Initial program 86.7%

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

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

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

        \[\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-out86.7%

        \[\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. Simplified86.7%

      \[\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. sub-neg86.7%

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

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

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

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

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

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

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

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

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

    if 7.50000000000000019e-59 < x.re

    1. Initial program 80.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. *-commutative80.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-out80.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*80.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. *-commutative80.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--89.2%

        \[\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-89.2%

        \[\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-89.2%

        \[\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-neg89.2%

        \[\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+89.2%

        \[\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-udef97.1%

        \[\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-197.1%

        \[\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-297.1%

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

        \[\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--97.1%

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

        \[\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-eval97.1%

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

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

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

Alternative 2: 96.4% 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.im \cdot \left(x.re + x.re\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 (<=
      (-
       (* 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.im (+ x.re x.re))))
   (* 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_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_im * (x_46_re + x_46_re)));
	} else {
		tmp = x_46_re * ((x_46_re * 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_im * (x_46_re + x_46_re)));
	} 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_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_im * (x_46_re + x_46_re)))
	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 (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_im * Float64(x_46_re + x_46_re))));
	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_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_im * (x_46_re + x_46_re)));
	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[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$im * N[(x$46$re + x$46$re), $MachinePrecision]), $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.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.im \cdot \left(x.re + x.re\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 (-.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 91.2%

      \[\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.2%

        \[\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. *-commutative91.2%

        \[\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. *-commutative91.2%

        \[\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-out91.2%

        \[\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. Simplified91.2%

      \[\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. sub-neg91.2%

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

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

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

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

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

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

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

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

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

        \[\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-48.1%

        \[\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-48.1%

        \[\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-neg48.1%

        \[\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+48.1%

        \[\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-udef74.1%

        \[\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-174.1%

        \[\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-274.1%

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

        \[\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--74.1%

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

        \[\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-eval74.1%

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

      \[\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-udef48.1%

        \[\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-rr48.1%

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

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

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

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

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

        \[\leadsto x.re \cdot \left(x.re \cdot x.re + \color{blue}{\left(-x.im\right)} \cdot \left(x.im \cdot -3\right)\right) \]
      6. cancel-sign-sub-inv74.1%

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

      \[\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 simplification97.1%

    \[\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.im \cdot \left(x.re + x.re\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 3: 96.6% accurate, 1.3× speedup?

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

\mathbf{elif}\;x.im \leq 7.8 \cdot 10^{+153}:\\
\;\;\;\;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.im \cdot \left(x.re \cdot -3\right)\right)\\


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

    1. Initial program 43.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. *-commutative43.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. *-commutative43.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. *-commutative43.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-out43.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. Simplified43.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. sub-neg43.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.49999999999999997e147 < x.im < 7.79999999999999966e153

    1. Initial program 93.2%

      \[\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. *-commutative93.2%

        \[\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-out93.2%

        \[\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*93.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. *-commutative93.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--99.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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.8%

      \[\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.8%

        \[\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.8%

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

    if 7.79999999999999966e153 < x.im

    1. Initial program 45.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. *-commutative45.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. *-commutative45.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. *-commutative45.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-out45.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. Simplified45.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. sub-neg45.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1.5 \cdot 10^{+147}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{elif}\;x.im \leq 7.8 \cdot 10^{+153}:\\ \;\;\;\;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.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \]

Alternative 4: 60.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -4.6 \cdot 10^{+147} \lor \neg \left(x.re \leq 5.7 \cdot 10^{+145}\right) \land x.re \leq 5.8 \cdot 10^{+281}:\\ \;\;\;\;3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\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 -4.6e+147) (and (not (<= x.re 5.7e+145)) (<= x.re 5.8e+281)))
   (* 3.0 (* x.re (* x.im x.im)))
   (* x.im (* x.im (* x.re -3.0)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -4.6e+147) || (!(x_46_re <= 5.7e+145) && (x_46_re <= 5.8e+281))) {
		tmp = 3.0 * (x_46_re * (x_46_im * x_46_im));
	} 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 <= (-4.6d+147)) .or. (.not. (x_46re <= 5.7d+145)) .and. (x_46re <= 5.8d+281)) then
        tmp = 3.0d0 * (x_46re * (x_46im * x_46im))
    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 <= -4.6e+147) || (!(x_46_re <= 5.7e+145) && (x_46_re <= 5.8e+281))) {
		tmp = 3.0 * (x_46_re * (x_46_im * x_46_im));
	} 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 <= -4.6e+147) or (not (x_46_re <= 5.7e+145) and (x_46_re <= 5.8e+281)):
		tmp = 3.0 * (x_46_re * (x_46_im * x_46_im))
	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 <= -4.6e+147) || (!(x_46_re <= 5.7e+145) && (x_46_re <= 5.8e+281)))
		tmp = Float64(3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im)));
	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 <= -4.6e+147) || (~((x_46_re <= 5.7e+145)) && (x_46_re <= 5.8e+281)))
		tmp = 3.0 * (x_46_re * (x_46_im * x_46_im));
	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, -4.6e+147], And[N[Not[LessEqual[x$46$re, 5.7e+145]], $MachinePrecision], LessEqual[x$46$re, 5.8e+281]]], N[(3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $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 -4.6 \cdot 10^{+147} \lor \neg \left(x.re \leq 5.7 \cdot 10^{+145}\right) \land x.re \leq 5.8 \cdot 10^{+281}:\\
\;\;\;\;3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\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 < -4.5999999999999998e147 or 5.6999999999999999e145 < x.re < 5.80000000000000019e281

    1. Initial program 62.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. *-commutative62.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-out62.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*62.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. *-commutative62.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--81.2%

        \[\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-81.2%

        \[\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-81.2%

        \[\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-neg81.2%

        \[\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+81.2%

        \[\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-udef89.9%

        \[\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-189.9%

        \[\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-289.9%

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

        \[\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--89.9%

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

        \[\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-eval89.9%

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

      \[\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-udef81.2%

        \[\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-rr81.2%

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

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

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

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

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

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

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

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

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

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

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

    if -4.5999999999999998e147 < x.re < 5.6999999999999999e145 or 5.80000000000000019e281 < x.re

    1. Initial program 88.7%

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

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

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

        \[\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-out88.7%

        \[\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. Simplified88.7%

      \[\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. sub-neg88.7%

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

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

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) + \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot \left(-x.im\right) \]
    5. 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) + \left(x.im \cdot \left(x.re + x.re\right)\right) \cdot \left(-x.im\right)} \]
    6. Taylor expanded in x.re around 0 65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -4.6 \cdot 10^{+147} \lor \neg \left(x.re \leq 5.7 \cdot 10^{+145}\right) \land x.re \leq 5.8 \cdot 10^{+281}:\\ \;\;\;\;3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \]

Alternative 5: 60.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -2.4 \cdot 10^{+151} \lor \neg \left(x.re \leq 10^{+144}\right) \land x.re \leq 5.8 \cdot 10^{+281}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\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 -2.4e+151) (and (not (<= x.re 1e+144)) (<= x.re 5.8e+281)))
   (* 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 <= -2.4e+151) || (!(x_46_re <= 1e+144) && (x_46_re <= 5.8e+281))) {
		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 <= (-2.4d+151)) .or. (.not. (x_46re <= 1d+144)) .and. (x_46re <= 5.8d+281)) 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 <= -2.4e+151) || (!(x_46_re <= 1e+144) && (x_46_re <= 5.8e+281))) {
		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 <= -2.4e+151) or (not (x_46_re <= 1e+144) and (x_46_re <= 5.8e+281)):
		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 <= -2.4e+151) || (!(x_46_re <= 1e+144) && (x_46_re <= 5.8e+281)))
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * 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 <= -2.4e+151) || (~((x_46_re <= 1e+144)) && (x_46_re <= 5.8e+281)))
		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[Or[LessEqual[x$46$re, -2.4e+151], And[N[Not[LessEqual[x$46$re, 1e+144]], $MachinePrecision], LessEqual[x$46$re, 5.8e+281]]], N[(x$46$im * N[(x$46$im * N[(x$46$re * 3.0), $MachinePrecision]), $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 -2.4 \cdot 10^{+151} \lor \neg \left(x.re \leq 10^{+144}\right) \land x.re \leq 5.8 \cdot 10^{+281}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\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 < -2.4000000000000001e151 or 1.00000000000000002e144 < x.re < 5.80000000000000019e281

    1. Initial program 62.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. *-commutative62.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. *-commutative62.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. *-commutative62.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-out62.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. Simplified62.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. sub-neg62.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \sqrt{\color{blue}{\left(x.re \cdot x.re\right) \cdot \left(-3 \cdot -3\right)}}\right)} - 1\right) \]
      6. metadata-eval17.5%

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \sqrt{\left(x.re \cdot x.re\right) \cdot \color{blue}{9}}\right)} - 1\right) \]
      7. metadata-eval17.5%

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

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

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \color{blue}{\left(\sqrt{x.re \cdot 3} \cdot \sqrt{x.re \cdot 3}\right)}\right)} - 1\right) \]
      10. add-sqr-sqrt17.0%

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

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

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

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

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

    if -2.4000000000000001e151 < x.re < 1.00000000000000002e144 or 5.80000000000000019e281 < x.re

    1. Initial program 88.7%

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

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

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

        \[\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-out88.7%

        \[\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. Simplified88.7%

      \[\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. sub-neg88.7%

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

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

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) + \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot \left(-x.im\right) \]
    5. 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) + \left(x.im \cdot \left(x.re + x.re\right)\right) \cdot \left(-x.im\right)} \]
    6. Taylor expanded in x.re around 0 65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.4 \cdot 10^{+151} \lor \neg \left(x.re \leq 10^{+144}\right) \land x.re \leq 5.8 \cdot 10^{+281}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \]

Alternative 6: 60.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{if}\;x.re \leq -1.9 \cdot 10^{+151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.re \leq 4.6 \cdot 10^{+142}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.re \leq 5.8 \cdot 10^{+281}:\\ \;\;\;\;t_0\\ \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
 (let* ((t_0 (* x.im (* x.im (* x.re 3.0)))))
   (if (<= x.re -1.9e+151)
     t_0
     (if (<= x.re 4.6e+142)
       (* x.im (* -3.0 (* x.re x.im)))
       (if (<= x.re 5.8e+281) t_0 (* x.im (* x.im (* x.re -3.0))))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_im * (x_46_re * 3.0));
	double tmp;
	if (x_46_re <= -1.9e+151) {
		tmp = t_0;
	} else if (x_46_re <= 4.6e+142) {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	} else if (x_46_re <= 5.8e+281) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = x_46im * (x_46im * (x_46re * 3.0d0))
    if (x_46re <= (-1.9d+151)) then
        tmp = t_0
    else if (x_46re <= 4.6d+142) then
        tmp = x_46im * ((-3.0d0) * (x_46re * x_46im))
    else if (x_46re <= 5.8d+281) then
        tmp = t_0
    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 t_0 = x_46_im * (x_46_im * (x_46_re * 3.0));
	double tmp;
	if (x_46_re <= -1.9e+151) {
		tmp = t_0;
	} else if (x_46_re <= 4.6e+142) {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	} else if (x_46_re <= 5.8e+281) {
		tmp = t_0;
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = x_46_im * (x_46_im * (x_46_re * 3.0))
	tmp = 0
	if x_46_re <= -1.9e+151:
		tmp = t_0
	elif x_46_re <= 4.6e+142:
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im))
	elif x_46_re <= 5.8e+281:
		tmp = t_0
	else:
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * 3.0)))
	tmp = 0.0
	if (x_46_re <= -1.9e+151)
		tmp = t_0;
	elseif (x_46_re <= 4.6e+142)
		tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_re * x_46_im)));
	elseif (x_46_re <= 5.8e+281)
		tmp = t_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)
	t_0 = x_46_im * (x_46_im * (x_46_re * 3.0));
	tmp = 0.0;
	if (x_46_re <= -1.9e+151)
		tmp = t_0;
	elseif (x_46_re <= 4.6e+142)
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	elseif (x_46_re <= 5.8e+281)
		tmp = t_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_] := Block[{t$95$0 = N[(x$46$im * N[(x$46$im * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -1.9e+151], t$95$0, If[LessEqual[x$46$re, 4.6e+142], N[(x$46$im * N[(-3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 5.8e+281], t$95$0, N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x.re \leq 5.8 \cdot 10^{+281}:\\
\;\;\;\;t_0\\

\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 3 regimes
  2. if x.re < -1.9e151 or 4.60000000000000004e142 < x.re < 5.80000000000000019e281

    1. Initial program 62.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. *-commutative62.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. *-commutative62.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. *-commutative62.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-out62.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. Simplified62.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. sub-neg62.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \sqrt{\color{blue}{\left(x.re \cdot x.re\right) \cdot \left(-3 \cdot -3\right)}}\right)} - 1\right) \]
      6. metadata-eval17.5%

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \sqrt{\left(x.re \cdot x.re\right) \cdot \color{blue}{9}}\right)} - 1\right) \]
      7. metadata-eval17.5%

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

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

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \color{blue}{\left(\sqrt{x.re \cdot 3} \cdot \sqrt{x.re \cdot 3}\right)}\right)} - 1\right) \]
      10. add-sqr-sqrt17.0%

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

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

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

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

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

    if -1.9e151 < x.re < 4.60000000000000004e142

    1. Initial program 89.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. *-commutative89.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. *-commutative89.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. *-commutative89.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-out89.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. Simplified89.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. sub-neg89.1%

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

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

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) + \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot \left(-x.im\right) \]
    5. 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) + \left(x.im \cdot \left(x.re + x.re\right)\right) \cdot \left(-x.im\right)} \]
    6. Taylor expanded in x.re around 0 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.80000000000000019e281 < x.re

    1. Initial program 66.7%

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

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

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

        \[\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-out66.7%

        \[\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. Simplified66.7%

      \[\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. sub-neg66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -1.9 \cdot 10^{+151}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{elif}\;x.re \leq 4.6 \cdot 10^{+142}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.re \leq 5.8 \cdot 10^{+281}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \]

Alternative 7: 60.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{if}\;x.re \leq -9 \cdot 10^{+151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.re \leq 1.25 \cdot 10^{+140}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.re \leq 5.8 \cdot 10^{+281}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.im \cdot -3\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.im (* x.im (* x.re 3.0)))))
   (if (<= x.re -9e+151)
     t_0
     (if (<= x.re 1.25e+140)
       (* x.im (* -3.0 (* x.re x.im)))
       (if (<= x.re 5.8e+281) t_0 (* x.re (* x.im (* x.im -3.0))))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_im * (x_46_re * 3.0));
	double tmp;
	if (x_46_re <= -9e+151) {
		tmp = t_0;
	} else if (x_46_re <= 1.25e+140) {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	} else if (x_46_re <= 5.8e+281) {
		tmp = t_0;
	} else {
		tmp = 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) :: t_0
    real(8) :: tmp
    t_0 = x_46im * (x_46im * (x_46re * 3.0d0))
    if (x_46re <= (-9d+151)) then
        tmp = t_0
    else if (x_46re <= 1.25d+140) then
        tmp = x_46im * ((-3.0d0) * (x_46re * x_46im))
    else if (x_46re <= 5.8d+281) then
        tmp = t_0
    else
        tmp = 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 t_0 = x_46_im * (x_46_im * (x_46_re * 3.0));
	double tmp;
	if (x_46_re <= -9e+151) {
		tmp = t_0;
	} else if (x_46_re <= 1.25e+140) {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	} else if (x_46_re <= 5.8e+281) {
		tmp = t_0;
	} else {
		tmp = x_46_re * (x_46_im * (x_46_im * -3.0));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = x_46_im * (x_46_im * (x_46_re * 3.0))
	tmp = 0
	if x_46_re <= -9e+151:
		tmp = t_0
	elif x_46_re <= 1.25e+140:
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im))
	elif x_46_re <= 5.8e+281:
		tmp = t_0
	else:
		tmp = x_46_re * (x_46_im * (x_46_im * -3.0))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * 3.0)))
	tmp = 0.0
	if (x_46_re <= -9e+151)
		tmp = t_0;
	elseif (x_46_re <= 1.25e+140)
		tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_re * x_46_im)));
	elseif (x_46_re <= 5.8e+281)
		tmp = t_0;
	else
		tmp = Float64(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)
	t_0 = x_46_im * (x_46_im * (x_46_re * 3.0));
	tmp = 0.0;
	if (x_46_re <= -9e+151)
		tmp = t_0;
	elseif (x_46_re <= 1.25e+140)
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	elseif (x_46_re <= 5.8e+281)
		tmp = t_0;
	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_] := Block[{t$95$0 = N[(x$46$im * N[(x$46$im * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -9e+151], t$95$0, If[LessEqual[x$46$re, 1.25e+140], N[(x$46$im * N[(-3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 5.8e+281], t$95$0, N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x.re \leq 5.8 \cdot 10^{+281}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -8.9999999999999997e151 or 1.25000000000000002e140 < x.re < 5.80000000000000019e281

    1. Initial program 62.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. *-commutative62.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. *-commutative62.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. *-commutative62.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-out62.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. Simplified62.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. sub-neg62.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \sqrt{\color{blue}{\left(x.re \cdot x.re\right) \cdot \left(-3 \cdot -3\right)}}\right)} - 1\right) \]
      6. metadata-eval17.5%

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \sqrt{\left(x.re \cdot x.re\right) \cdot \color{blue}{9}}\right)} - 1\right) \]
      7. metadata-eval17.5%

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

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

        \[\leadsto x.im \cdot \left(e^{\mathsf{log1p}\left(x.im \cdot \color{blue}{\left(\sqrt{x.re \cdot 3} \cdot \sqrt{x.re \cdot 3}\right)}\right)} - 1\right) \]
      10. add-sqr-sqrt17.0%

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

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

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

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

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

    if -8.9999999999999997e151 < x.re < 1.25000000000000002e140

    1. Initial program 89.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. *-commutative89.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. *-commutative89.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. *-commutative89.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-out89.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. Simplified89.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. sub-neg89.1%

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

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

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) + \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot \left(-x.im\right) \]
    5. 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) + \left(x.im \cdot \left(x.re + x.re\right)\right) \cdot \left(-x.im\right)} \]
    6. Taylor expanded in x.re around 0 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.80000000000000019e281 < x.re

    1. Initial program 66.7%

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

        \[\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-out66.7%

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

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

        \[\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--66.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-66.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-66.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-neg66.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+66.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-udef100.0%

        \[\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-1100.0%

        \[\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-2100.0%

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

        \[\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--100.0%

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

        \[\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-eval100.0%

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

      \[\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-udef66.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-rr66.7%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -9 \cdot 10^{+151}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{elif}\;x.re \leq 1.25 \cdot 10^{+140}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.re \leq 5.8 \cdot 10^{+281}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot 3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.im \cdot -3\right)\right)\\ \end{array} \]

Alternative 8: 23.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 81.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. *-commutative81.6%

      \[\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-out81.6%

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

      \[\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. *-commutative81.6%

      \[\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--86.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-86.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-86.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-neg86.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+86.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-udef89.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-189.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-289.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*89.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--89.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*89.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-eval89.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. Simplified89.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. Step-by-step derivation
    1. fma-udef86.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-rr86.7%

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

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

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

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

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

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

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

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

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

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

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

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

Developer target: 86.7% 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 2023182 
(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)))