math.cube on complex, real part

Percentage Accurate: 82.5% → 95.9%
Time: 5.0s
Alternatives: 5
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 5 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.5% 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: 95.9% accurate, 1.3× speedup?

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

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

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

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


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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re} \]
      5. distribute-rgt-out--64.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-64.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-64.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-neg64.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+64.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-udef73.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-173.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-273.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*73.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--73.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*73.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-eval73.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. Simplified73.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.05000000000000002e133 < x.im < 7.59999999999999933e153

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.59999999999999933e153 < 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 \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-out53.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*53.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. *-commutative53.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--53.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-53.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-53.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-neg53.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+53.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-udef66.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-166.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-266.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*66.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--66.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*66.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-eval66.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. Simplified66.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 0 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 74.9% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2.4 \cdot 10^{+109} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-57}\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 -2.4e+109) (not (<= x.im 1.4e-57)))
   (* -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 <= -2.4e+109) || !(x_46_im <= 1.4e-57)) {
		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 <= (-2.4d+109)) .or. (.not. (x_46im <= 1.4d-57))) 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 <= -2.4e+109) || !(x_46_im <= 1.4e-57)) {
		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 <= -2.4e+109) or not (x_46_im <= 1.4e-57):
		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 <= -2.4e+109) || !(x_46_im <= 1.4e-57))
		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 <= -2.4e+109) || ~((x_46_im <= 1.4e-57)))
		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, -2.4e+109], N[Not[LessEqual[x$46$im, 1.4e-57]], $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 -2.4 \cdot 10^{+109} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-57}\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 < -2.39999999999999987e109 or 1.4e-57 < x.im

    1. Initial program 70.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. *-commutative70.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-out70.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*70.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. *-commutative70.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--77.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-77.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-77.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-neg77.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+77.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-udef83.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-183.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-283.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*83.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--83.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*83.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-eval83.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. Simplified83.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 0 73.2%

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

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

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

    if -2.39999999999999987e109 < x.im < 1.4e-57

    1. Initial program 94.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. *-commutative94.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-out94.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*94.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. *-commutative94.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--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.9%

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

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

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. 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 simplification82.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -2.4 \cdot 10^{+109} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-57}\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: 80.1% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -4 \cdot 10^{+109} \lor \neg \left(x.im \leq 5.2 \cdot 10^{-58}\right):\\ \;\;\;\;x.im \cdot \left(\left(x.im \cdot x.re\right) \cdot -3\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 -4e+109) (not (<= x.im 5.2e-58)))
   (* x.im (* (* x.im x.re) -3.0))
   (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -4e+109) || !(x_46_im <= 5.2e-58)) {
		tmp = x_46_im * ((x_46_im * x_46_re) * -3.0);
	} 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 <= (-4d+109)) .or. (.not. (x_46im <= 5.2d-58))) then
        tmp = x_46im * ((x_46im * x_46re) * (-3.0d0))
    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 <= -4e+109) || !(x_46_im <= 5.2e-58)) {
		tmp = x_46_im * ((x_46_im * x_46_re) * -3.0);
	} 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 <= -4e+109) or not (x_46_im <= 5.2e-58):
		tmp = x_46_im * ((x_46_im * x_46_re) * -3.0)
	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 <= -4e+109) || !(x_46_im <= 5.2e-58))
		tmp = Float64(x_46_im * Float64(Float64(x_46_im * x_46_re) * -3.0));
	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 <= -4e+109) || ~((x_46_im <= 5.2e-58)))
		tmp = x_46_im * ((x_46_im * x_46_re) * -3.0);
	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, -4e+109], N[Not[LessEqual[x$46$im, 5.2e-58]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$im * x$46$re), $MachinePrecision] * -3.0), $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 \cdot 10^{+109} \lor \neg \left(x.im \leq 5.2 \cdot 10^{-58}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.im \cdot x.re\right) \cdot -3\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.99999999999999993e109 or 5.20000000000000013e-58 < x.im

    1. Initial program 70.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. *-commutative70.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-out70.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*70.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. *-commutative70.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--77.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-77.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-77.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-neg77.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+77.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-udef83.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-183.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-283.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*83.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--83.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*83.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-eval83.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. Simplified83.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 0 73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{\left(-{x.im}^{2} \cdot x.re\right)} \]
      19. distribute-lft-neg-in73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.99999999999999993e109 < x.im < 5.20000000000000013e-58

    1. Initial program 94.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. *-commutative94.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-out94.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*94.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. *-commutative94.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--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.9%

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

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

      \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)} \]
    4. 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 simplification87.1%

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

Alternative 4: 80.1% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2 \cdot 10^{+109} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-57}\right):\\ \;\;\;\;\left(x.im \cdot \left(x.im \cdot x.re\right)\right) \cdot -3\\ \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 -2e+109) (not (<= x.im 1.4e-57)))
   (* (* x.im (* x.im x.re)) -3.0)
   (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -2e+109) || !(x_46_im <= 1.4e-57)) {
		tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0;
	} 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 <= (-2d+109)) .or. (.not. (x_46im <= 1.4d-57))) then
        tmp = (x_46im * (x_46im * x_46re)) * (-3.0d0)
    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 <= -2e+109) || !(x_46_im <= 1.4e-57)) {
		tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0;
	} 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 <= -2e+109) or not (x_46_im <= 1.4e-57):
		tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0
	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 <= -2e+109) || !(x_46_im <= 1.4e-57))
		tmp = Float64(Float64(x_46_im * Float64(x_46_im * x_46_re)) * -3.0);
	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 <= -2e+109) || ~((x_46_im <= 1.4e-57)))
		tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0;
	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, -2e+109], N[Not[LessEqual[x$46$im, 1.4e-57]], $MachinePrecision]], N[(N[(x$46$im * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * -3.0), $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 -2 \cdot 10^{+109} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-57}\right):\\
\;\;\;\;\left(x.im \cdot \left(x.im \cdot x.re\right)\right) \cdot -3\\

\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 < -1.99999999999999996e109 or 1.4e-57 < x.im

    1. Initial program 70.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. *-commutative70.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-out70.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*70.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. *-commutative70.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--77.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-77.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-77.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-neg77.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+77.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-udef83.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-183.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-283.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*83.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--83.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*83.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-eval83.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. Simplified83.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 0 73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{\left(-{x.im}^{2} \cdot x.re\right)} \]
      19. distribute-lft-neg-in73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999996e109 < x.im < 1.4e-57

    1. Initial program 94.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. *-commutative94.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-out94.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*94.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. *-commutative94.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--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.9%

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

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

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

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

Alternative 5: 59.1% 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.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. *-commutative83.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-out83.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*83.8%

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

      \[\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.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-89.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-89.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-neg89.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+89.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-udef92.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-192.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-292.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*92.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--92.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*92.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-eval92.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. Simplified92.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 57.8%

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

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

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

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

Developer target: 86.8% 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 2023178 
(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)))