math.cube on complex, real part

Percentage Accurate: 82.9% → 96.4%
Time: 7.1s
Alternatives: 10
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 10 alternatives:

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

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

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -5 \cdot 10^{+195}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq -3.4 \cdot 10^{-106} \lor \neg \left(x.re \leq 5.2 \cdot 10^{-157}\right):\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re -5e+195)
   (* x.re (* x.re x.re))
   (if (or (<= x.re -3.4e-106) (not (<= x.re 5.2e-157)))
     (* x.re (fma x.re x.re (* x.im (* x.im -3.0))))
     (* x.im (* -3.0 (* x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= -5e+195) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else if ((x_46_re <= -3.4e-106) || !(x_46_re <= 5.2e-157)) {
		tmp = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
	} else {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= -5e+195)
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	elseif ((x_46_re <= -3.4e-106) || !(x_46_re <= 5.2e-157))
		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0))));
	else
		tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_re * x_46_im)));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -5e+195], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x$46$re, -3.4e-106], N[Not[LessEqual[x$46$re, 5.2e-157]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$re + N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(-3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x.re \leq -3.4 \cdot 10^{-106} \lor \neg \left(x.re \leq 5.2 \cdot 10^{-157}\right):\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\

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


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

    1. Initial program 41.4%

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

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

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

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

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

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

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

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

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

        \[\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-udef72.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-172.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-272.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*72.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--72.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*72.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-eval72.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. Simplified72.4%

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

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

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

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

    if -4.9999999999999998e195 < x.re < -3.39999999999999982e-106 or 5.19999999999999977e-157 < x.re

    1. Initial program 89.9%

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

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

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

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

        \[\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--95.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-95.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-95.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-neg95.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+95.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-udef98.5%

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

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

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

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

        \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right) \]
      15. associate-*r*98.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-eval98.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. Simplified98.4%

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

    if -3.39999999999999982e-106 < x.re < 5.19999999999999977e-157

    1. Initial program 86.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. *-commutative86.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. *-commutative86.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. *-commutative86.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-out86.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. Simplified86.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. Taylor expanded in x.im around inf 86.1%

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-1 \cdot x.re - 2 \cdot x.re}\right)}^{2} \]
      7. add-sqr-sqrt66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -5 \cdot 10^{+195}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq -3.4 \cdot 10^{-106} \lor \neg \left(x.re \leq 5.2 \cdot 10^{-157}\right):\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 2: 76.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -4.3 \cdot 10^{+39} \lor \neg \left(x.im \leq 600000\right) \land \left(x.im \leq 1.1 \cdot 10^{+95} \lor \neg \left(x.im \leq 3.6 \cdot 10^{+115}\right)\right):\\
\;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.3e39 or 6e5 < x.im < 1.0999999999999999e95 or 3.6000000000000001e115 < x.im

    1. Initial program 67.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. *-commutative67.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-out67.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*67.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. *-commutative67.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--76.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.3e39 < x.im < 6e5 or 1.0999999999999999e95 < x.im < 3.6000000000000001e115

    1. Initial program 95.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. *-commutative95.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-out95.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*95.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. *-commutative95.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--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. Taylor expanded in x.re around inf 89.5%

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified89.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -4.3 \cdot 10^{+39} \lor \neg \left(x.im \leq 600000\right) \land \left(x.im \leq 1.1 \cdot 10^{+95} \lor \neg \left(x.im \leq 3.6 \cdot 10^{+115}\right)\right):\\ \;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \]

Alternative 3: 82.5% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -4.4 \cdot 10^{+39} \lor \neg \left(x.im \leq 50000\right) \land \left(x.im \leq 5 \cdot 10^{+95} \lor \neg \left(x.im \leq 3.6 \cdot 10^{+115}\right)\right):\\
\;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.4000000000000003e39 or 5e4 < x.im < 5.00000000000000025e95 or 3.6000000000000001e115 < x.im

    1. Initial program 67.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. *-commutative67.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-1 \cdot x.re - 2 \cdot x.re}\right)}^{2} \]
      7. add-sqr-sqrt41.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.4000000000000003e39 < x.im < 5e4 or 5.00000000000000025e95 < x.im < 3.6000000000000001e115

    1. Initial program 95.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. *-commutative95.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-out95.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*95.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. *-commutative95.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--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. Taylor expanded in x.re around inf 89.5%

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified89.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -4.4 \cdot 10^{+39} \lor \neg \left(x.im \leq 50000\right) \land \left(x.im \leq 5 \cdot 10^{+95} \lor \neg \left(x.im \leq 3.6 \cdot 10^{+115}\right)\right):\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \]

Alternative 4: 82.3% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;x.im \leq 95000000:\\
\;\;\;\;t_1\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -6.00000000000000033e43 or 3.6000000000000001e115 < x.im

    1. Initial program 64.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. *-commutative64.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-1 \cdot x.re - 2 \cdot x.re}\right)}^{2} \]
      7. add-sqr-sqrt43.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.00000000000000033e43 < x.im < 9.5e7 or 5.4e95 < x.im < 3.6000000000000001e115

    1. Initial program 95.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. *-commutative95.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-out95.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*95.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. *-commutative95.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--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. Taylor expanded in x.re around inf 89.5%

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified89.5%

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

    if 9.5e7 < x.im < 5.4e95

    1. Initial program 84.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. *-commutative84.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-out84.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*84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -6 \cdot 10^{+43}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.im \leq 95000000:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.im \leq 5.4 \cdot 10^{+95}:\\ \;\;\;\;\left(x.re \cdot -3\right) \cdot \left(x.im \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 3.6 \cdot 10^{+115}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 5: 82.5% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;x.im \leq 25:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x.im \leq 3.8 \cdot 10^{+115}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x.im < -3.59999999999999984e39

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.59999999999999984e39 < x.im < 25 or 5.4e95 < x.im < 3.8000000000000001e115

    1. Initial program 95.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. *-commutative95.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-out95.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*95.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. *-commutative95.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--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. Taylor expanded in x.re around inf 89.5%

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified89.5%

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

    if 25 < x.im < 5.4e95

    1. Initial program 84.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. *-commutative84.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-out84.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*84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8000000000000001e115 < x.im

    1. Initial program 59.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-1 \cdot x.re - 2 \cdot x.re}\right)}^{2} \]
      7. add-sqr-sqrt45.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3.6 \cdot 10^{+39}:\\ \;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 25:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.im \leq 5.4 \cdot 10^{+95}:\\ \;\;\;\;\left(x.re \cdot -3\right) \cdot \left(x.im \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 3.8 \cdot 10^{+115}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 6: 82.4% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;x.im \leq 2.4:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x.im \leq 3.6 \cdot 10^{+115}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x.im < -4.1000000000000004e41

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.1000000000000004e41 < x.im < 2.39999999999999991 or 5.00000000000000025e95 < x.im < 3.6000000000000001e115

    1. Initial program 95.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. *-commutative95.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-out95.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*95.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. *-commutative95.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--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. Taylor expanded in x.re around inf 89.5%

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified89.5%

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

    if 2.39999999999999991 < x.im < 5.00000000000000025e95

    1. Initial program 84.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. *-commutative84.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-out84.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*84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.6000000000000001e115 < x.im

    1. Initial program 59.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-1 \cdot x.re - 2 \cdot x.re}\right)}^{2} \]
      7. add-sqr-sqrt45.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -4.1 \cdot 10^{+41}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{elif}\;x.im \leq 2.4:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.im \leq 5 \cdot 10^{+95}:\\ \;\;\;\;\left(x.re \cdot -3\right) \cdot \left(x.im \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 3.6 \cdot 10^{+115}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 7: 96.4% accurate, 1.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -7.50000000000000065e153 or 1.8000000000000001e142 < x.im

    1. Initial program 53.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. *-commutative53.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. *-commutative53.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. *-commutative53.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-out53.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. Simplified53.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. Taylor expanded in x.im around inf 64.2%

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \sqrt{-1 \cdot x.re - 2 \cdot x.re}\right)}^{2} \]
      7. add-sqr-sqrt45.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.50000000000000065e153 < x.im < 1.8000000000000001e142

    1. Initial program 91.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. *-commutative91.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-out91.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*91.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. *-commutative91.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--99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -7.5 \cdot 10^{+153} \lor \neg \left(x.im \leq 1.8 \cdot 10^{+142}\right):\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\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 8: 70.6% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -6 \cdot 10^{+191} \lor \neg \left(x.im \leq 1.35 \cdot 10^{+116}\right):\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5.9999999999999995e191 or 1.35e116 < x.im

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}}, x.im \cdot x.im, -x.im \cdot \left(x.re \cdot x.im\right)\right) - x.im \cdot \left(x.re \cdot x.im\right) \]
      5. sqr-neg38.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.9999999999999995e191 < x.im < 1.35e116

    1. Initial program 89.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. *-commutative89.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-out89.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*89.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. *-commutative89.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--97.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-97.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-97.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-neg97.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+97.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.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified73.1%

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

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

Alternative 9: 71.1% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.7999999999999998e191 or 8.50000000000000057e115 < x.im

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}}, x.im \cdot x.im, -x.im \cdot \left(x.re \cdot x.im\right)\right) - x.im \cdot \left(x.re \cdot x.im\right) \]
      5. sqr-neg38.6%

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

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

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

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

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

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

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

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

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

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

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

    if -3.7999999999999998e191 < x.im < 8.50000000000000057e115

    1. Initial program 89.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. *-commutative89.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-out89.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*89.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. *-commutative89.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--97.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-97.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-97.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-neg97.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+97.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.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    6. Simplified73.1%

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

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

Alternative 10: 58.8% accurate, 3.8× speedup?

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

\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 83.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. *-commutative83.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-out83.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*83.2%

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

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

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

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

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

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

      \[\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-udef91.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-191.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-291.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*91.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--91.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*91.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-eval91.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. Simplified91.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. Taylor expanded in x.re around inf 59.2%

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

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

    \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
  7. Final simplification59.2%

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

Developer target: 87.4% 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 2023174 
(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)))