math.cube on complex, imaginary part

Percentage Accurate: 82.0% → 97.5%
Time: 7.2s
Alternatives: 13
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 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.0% accurate, 1.0× speedup?

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

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

Alternative 1: 97.5% accurate, 0.2× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq -3.4 \cdot 10^{+234}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 1.22 \cdot 10^{+207}:\\ \;\;\;\;\mathsf{fma}\left(x.re, 2 \cdot \left(x.im \cdot x.re\right), \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-{x.im}^{3}\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -3.4e+234)
   (* x.re (* x.im x.im))
   (if (<= x.im 1.22e+207)
     (fma x.re (* 2.0 (* x.im x.re)) (* (+ x.im x.re) (* x.im (- x.re x.im))))
     (- (pow x.im 3.0)))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -3.4e+234) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else if (x_46_im <= 1.22e+207) {
		tmp = fma(x_46_re, (2.0 * (x_46_im * x_46_re)), ((x_46_im + x_46_re) * (x_46_im * (x_46_re - x_46_im))));
	} else {
		tmp = -pow(x_46_im, 3.0);
	}
	return tmp;
}
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -3.4e+234)
		tmp = Float64(x_46_re * Float64(x_46_im * x_46_im));
	elseif (x_46_im <= 1.22e+207)
		tmp = fma(x_46_re, Float64(2.0 * Float64(x_46_im * x_46_re)), Float64(Float64(x_46_im + x_46_re) * Float64(x_46_im * Float64(x_46_re - x_46_im))));
	else
		tmp = Float64(-(x_46_im ^ 3.0));
	end
	return tmp
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -3.4e+234], N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1.22e+207], N[(x$46$re * N[(2.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Power[x$46$im, 3.0], $MachinePrecision])]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -3.4 \cdot 10^{+234}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\

\mathbf{elif}\;x.im \leq 1.22 \cdot 10^{+207}:\\
\;\;\;\;\mathsf{fma}\left(x.re, 2 \cdot \left(x.im \cdot x.re\right), \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-{x.im}^{3}\\


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

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.im\right) \]
      9. difference-of-squares66.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
      10. sub-neg66.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      11. sub-neg66.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re + \left(-x.im\right)\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      12. difference-of-squares66.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
      13. sqr-neg66.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
      14. difference-of-squares66.7%

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \]
    5. Taylor expanded in x.re around 0 20.0%

      \[\leadsto \color{blue}{{x.im}^{2} \cdot x.re} \]
    6. Step-by-step derivation
      1. *-commutative20.0%

        \[\leadsto \color{blue}{x.re \cdot {x.im}^{2}} \]
      2. unpow220.0%

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

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

    if -3.4e234 < x.im < 1.21999999999999993e207

    1. Initial program 89.5%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(-x.re\right) \cdot \left(-x.re\right)} - x.im \cdot x.im\right) \cdot x.im\right) \]
      7. sqr-neg90.0%

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.im\right) \]
      9. difference-of-squares94.6%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
      10. sub-neg94.6%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      11. sub-neg94.6%

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
      13. sqr-neg90.0%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
      14. difference-of-squares94.6%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im\right) \]
      15. +-commutative94.6%

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

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

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

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

    if 1.21999999999999993e207 < x.im

    1. Initial program 76.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around 0 100.0%

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    3. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto \color{blue}{-{x.im}^{3}} \]
    4. Simplified100.0%

      \[\leadsto \color{blue}{-{x.im}^{3}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.7%

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

Alternative 2: 91.3% accurate, 0.2× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \leq 2.4 \cdot 10^{+112}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - {x.im}^{3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re, 2 \cdot \left(x.im \cdot x.re\right), \left(x.im + x.re\right) \cdot \left(x.im \cdot x.re\right)\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re 2.4e+112)
   (- (* x.re (* x.re (* x.im 3.0))) (pow x.im 3.0))
   (fma x.re (* 2.0 (* x.im x.re)) (* (+ x.im x.re) (* x.im x.re)))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= 2.4e+112) {
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - pow(x_46_im, 3.0);
	} else {
		tmp = fma(x_46_re, (2.0 * (x_46_im * x_46_re)), ((x_46_im + x_46_re) * (x_46_im * x_46_re)));
	}
	return tmp;
}
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= 2.4e+112)
		tmp = Float64(Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0))) - (x_46_im ^ 3.0));
	else
		tmp = fma(x_46_re, Float64(2.0 * Float64(x_46_im * x_46_re)), Float64(Float64(x_46_im + x_46_re) * Float64(x_46_im * x_46_re)));
	end
	return tmp
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 2.4e+112], N[(N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(2.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 2.4 \cdot 10^{+112}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - {x.im}^{3}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 2.4e112

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

    if 2.4e112 < x.re

    1. Initial program 60.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(-x.re\right) \cdot \left(-x.re\right)} - x.im \cdot x.im\right) \cdot x.im\right) \]
      7. sqr-neg63.4%

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
      10. sub-neg79.1%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      11. sub-neg79.1%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re + \left(-x.im\right)\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      12. difference-of-squares63.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
      13. sqr-neg63.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
      14. difference-of-squares79.1%

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)}\right) \]
      17. +-commutative93.6%

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

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

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

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

Alternative 3: 90.2% accurate, 0.2× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} t_0 := x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \mathbf{if}\;x.re \leq 8.6 \cdot 10^{+61}:\\ \;\;\;\;t_0 - {x.im}^{3}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.re (* x.re (* x.im 3.0)))))
   (if (<= x.re 8.6e+61) (- t_0 (pow x.im 3.0)) t_0)))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (x_46_re * (x_46_im * 3.0));
	double tmp;
	if (x_46_re <= 8.6e+61) {
		tmp = t_0 - pow(x_46_im, 3.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
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_46im * 3.0d0))
    if (x_46re <= 8.6d+61) then
        tmp = t_0 - (x_46im ** 3.0d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * (x_46_re * (x_46_im * 3.0));
	double tmp;
	if (x_46_re <= 8.6e+61) {
		tmp = t_0 - Math.pow(x_46_im, 3.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	t_0 = x_46_re * (x_46_re * (x_46_im * 3.0))
	tmp = 0
	if x_46_re <= 8.6e+61:
		tmp = t_0 - math.pow(x_46_im, 3.0)
	else:
		tmp = t_0
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0)))
	tmp = 0.0
	if (x_46_re <= 8.6e+61)
		tmp = Float64(t_0 - (x_46_im ^ 3.0));
	else
		tmp = t_0;
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_re * (x_46_re * (x_46_im * 3.0));
	tmp = 0.0;
	if (x_46_re <= 8.6e+61)
		tmp = t_0 - (x_46_im ^ 3.0);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, 8.6e+61], N[(t$95$0 - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\
\mathbf{if}\;x.re \leq 8.6 \cdot 10^{+61}:\\
\;\;\;\;t_0 - {x.im}^{3}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 8.6000000000000003e61

    1. Initial program 90.7%

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

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

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

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

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

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

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

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

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

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

    if 8.6000000000000003e61 < x.re

    1. Initial program 65.6%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around inf 78.2%

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

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

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

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

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

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

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

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

Alternative 4: 90.8% accurate, 0.9× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \leq 1.8 \cdot 10^{+78}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re 1.8e+78)
   (+
    (* x.im (- (* x.re x.re) (* x.im x.im)))
    (* x.re (+ (* x.im x.re) (* x.im x.re))))
   (* x.re (* x.re (* x.im 3.0)))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= 1.8e+78) {
		tmp = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re)));
	} else {
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re <= 1.8d+78) then
        tmp = (x_46im * ((x_46re * x_46re) - (x_46im * x_46im))) + (x_46re * ((x_46im * x_46re) + (x_46im * x_46re)))
    else
        tmp = x_46re * (x_46re * (x_46im * 3.0d0))
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= 1.8e+78) {
		tmp = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re)));
	} else {
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_re <= 1.8e+78:
		tmp = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re)))
	else:
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0))
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= 1.8e+78)
		tmp = Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_im * x_46_re) + Float64(x_46_im * x_46_re))));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0)));
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_re <= 1.8e+78)
		tmp = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re)));
	else
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 1.8e+78], N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 1.8 \cdot 10^{+78}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 1.8000000000000001e78

    1. Initial program 90.8%

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

    if 1.8000000000000001e78 < x.re

    1. Initial program 64.7%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around inf 77.6%

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

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

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

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

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

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

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

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

Alternative 5: 83.2% accurate, 1.3× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \leq 26000:\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.re + x.re\right)\right) - x.im \cdot \left(x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re 26000.0)
   (- (* x.re (* x.im (+ x.re x.re))) (* x.im (* x.im x.im)))
   (* x.re (* x.re (* x.im 3.0)))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= 26000.0) {
		tmp = (x_46_re * (x_46_im * (x_46_re + x_46_re))) - (x_46_im * (x_46_im * x_46_im));
	} else {
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46re <= 26000.0d0) then
        tmp = (x_46re * (x_46im * (x_46re + x_46re))) - (x_46im * (x_46im * x_46im))
    else
        tmp = x_46re * (x_46re * (x_46im * 3.0d0))
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= 26000.0) {
		tmp = (x_46_re * (x_46_im * (x_46_re + x_46_re))) - (x_46_im * (x_46_im * x_46_im));
	} else {
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_re <= 26000.0:
		tmp = (x_46_re * (x_46_im * (x_46_re + x_46_re))) - (x_46_im * (x_46_im * x_46_im))
	else:
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0))
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= 26000.0)
		tmp = Float64(Float64(x_46_re * Float64(x_46_im * Float64(x_46_re + x_46_re))) - Float64(x_46_im * Float64(x_46_im * x_46_im)));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0)));
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_re <= 26000.0)
		tmp = (x_46_re * (x_46_im * (x_46_re + x_46_re))) - (x_46_im * (x_46_im * x_46_im));
	else
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 26000.0], N[(N[(x$46$re * N[(x$46$im * N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 26000:\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(x.re + x.re\right)\right) - x.im \cdot \left(x.im \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 26000

    1. Initial program 90.4%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around 0 75.1%

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

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

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

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

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

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

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

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

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

    if 26000 < x.re

    1. Initial program 71.3%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around inf 77.6%

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

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

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

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

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

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

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

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

Alternative 6: 58.8% accurate, 2.1× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq -4.2 \cdot 10^{+162}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re \cdot 3\right)\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -4.2e+162)
   (* x.re (* x.im x.im))
   (* x.im (* x.re (* x.re 3.0)))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -4.2e+162) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else {
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
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.2d+162)) then
        tmp = x_46re * (x_46im * x_46im)
    else
        tmp = x_46im * (x_46re * (x_46re * 3.0d0))
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -4.2e+162) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else {
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -4.2e+162:
		tmp = x_46_re * (x_46_im * x_46_im)
	else:
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0))
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -4.2e+162)
		tmp = Float64(x_46_re * Float64(x_46_im * x_46_im));
	else
		tmp = Float64(x_46_im * Float64(x_46_re * Float64(x_46_re * 3.0)));
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= -4.2e+162)
		tmp = x_46_re * (x_46_im * x_46_im);
	else
		tmp = x_46_im * (x_46_re * (x_46_re * 3.0));
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -4.2e+162], N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$re * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -4.2 \cdot 10^{+162}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.2000000000000001e162

    1. Initial program 61.8%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.im\right) \]
      9. difference-of-squares82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
      10. sub-neg82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      11. sub-neg82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re + \left(-x.im\right)\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      12. difference-of-squares64.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
      13. sqr-neg64.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
      14. difference-of-squares82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im\right) \]
      15. +-commutative82.4%

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)}\right) \]
      17. +-commutative82.4%

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

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

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \]
    5. Taylor expanded in x.re around 0 23.5%

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

        \[\leadsto \color{blue}{x.re \cdot {x.im}^{2}} \]
      2. unpow223.5%

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

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

    if -4.2000000000000001e162 < x.im

    1. Initial program 90.6%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot x.im + x.im \cdot x.re, \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im\right)} \]
      4. *-commutative90.7%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.im\right) \]
      9. difference-of-squares92.5%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
      10. sub-neg92.5%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      11. sub-neg92.5%

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
      13. sqr-neg90.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
      14. difference-of-squares92.5%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im\right) \]
      15. +-commutative92.5%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. add-cbrt-cube_binary6475.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \sqrt[3]{\left(\left(\left(x.re - x.im\right) \cdot x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)}\right)} \]
    5. Applied rewrite-once75.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 58.8% accurate, 2.1× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq -4.2 \cdot 10^{+162}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -4.2e+162)
   (* x.re (* x.im x.im))
   (* x.im (* 3.0 (* x.re x.re)))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -4.2e+162) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else {
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
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.2d+162)) then
        tmp = x_46re * (x_46im * x_46im)
    else
        tmp = x_46im * (3.0d0 * (x_46re * x_46re))
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -4.2e+162) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else {
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -4.2e+162:
		tmp = x_46_re * (x_46_im * x_46_im)
	else:
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re))
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -4.2e+162)
		tmp = Float64(x_46_re * Float64(x_46_im * x_46_im));
	else
		tmp = Float64(x_46_im * Float64(3.0 * Float64(x_46_re * x_46_re)));
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= -4.2e+162)
		tmp = x_46_re * (x_46_im * x_46_im);
	else
		tmp = x_46_im * (3.0 * (x_46_re * x_46_re));
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -4.2e+162], N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(3.0 * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -4.2 \cdot 10^{+162}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.2000000000000001e162

    1. Initial program 61.8%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.im\right) \]
      9. difference-of-squares82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
      10. sub-neg82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      11. sub-neg82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re + \left(-x.im\right)\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      12. difference-of-squares64.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
      13. sqr-neg64.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
      14. difference-of-squares82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im\right) \]
      15. +-commutative82.4%

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)}\right) \]
      17. +-commutative82.4%

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

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

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \]
    5. Taylor expanded in x.re around 0 23.5%

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

        \[\leadsto \color{blue}{x.re \cdot {x.im}^{2}} \]
      2. unpow223.5%

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

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

    if -4.2000000000000001e162 < x.im

    1. Initial program 90.6%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around inf 56.5%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 64.4% accurate, 2.1× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq -4.2 \cdot 10^{+162}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.im \cdot x.re\right)\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -4.2e+162)
   (* x.re (* x.im x.im))
   (* x.re (* 3.0 (* x.im x.re)))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -4.2e+162) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else {
		tmp = x_46_re * (3.0 * (x_46_im * x_46_re));
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
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.2d+162)) then
        tmp = x_46re * (x_46im * x_46im)
    else
        tmp = x_46re * (3.0d0 * (x_46im * x_46re))
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -4.2e+162) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else {
		tmp = x_46_re * (3.0 * (x_46_im * x_46_re));
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -4.2e+162:
		tmp = x_46_re * (x_46_im * x_46_im)
	else:
		tmp = x_46_re * (3.0 * (x_46_im * x_46_re))
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -4.2e+162)
		tmp = Float64(x_46_re * Float64(x_46_im * x_46_im));
	else
		tmp = Float64(x_46_re * Float64(3.0 * Float64(x_46_im * x_46_re)));
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= -4.2e+162)
		tmp = x_46_re * (x_46_im * x_46_im);
	else
		tmp = x_46_re * (3.0 * (x_46_im * x_46_re));
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -4.2e+162], N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -4.2 \cdot 10^{+162}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.2000000000000001e162

    1. Initial program 61.8%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.im\right) \]
      9. difference-of-squares82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
      10. sub-neg82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      11. sub-neg82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re + \left(-x.im\right)\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      12. difference-of-squares64.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
      13. sqr-neg64.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
      14. difference-of-squares82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im\right) \]
      15. +-commutative82.4%

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)}\right) \]
      17. +-commutative82.4%

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

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

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \]
    5. Taylor expanded in x.re around 0 23.5%

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

        \[\leadsto \color{blue}{x.re \cdot {x.im}^{2}} \]
      2. unpow223.5%

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

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

    if -4.2000000000000001e162 < x.im

    1. Initial program 90.6%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around inf 56.5%

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

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

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

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

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

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

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

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

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

Alternative 9: 64.4% accurate, 2.1× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq -5 \cdot 10^{+162}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -5e+162) (* x.re (* x.im x.im)) (* x.re (* x.re (* x.im 3.0)))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -5e+162) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else {
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46im <= (-5d+162)) then
        tmp = x_46re * (x_46im * x_46im)
    else
        tmp = x_46re * (x_46re * (x_46im * 3.0d0))
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -5e+162) {
		tmp = x_46_re * (x_46_im * x_46_im);
	} else {
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -5e+162:
		tmp = x_46_re * (x_46_im * x_46_im)
	else:
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0))
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -5e+162)
		tmp = Float64(x_46_re * Float64(x_46_im * x_46_im));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0)));
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= -5e+162)
		tmp = x_46_re * (x_46_im * x_46_im);
	else
		tmp = x_46_re * (x_46_re * (x_46_im * 3.0));
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -5e+162], N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -5 \cdot 10^{+162}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.9999999999999997e162

    1. Initial program 61.8%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.im\right) \]
      9. difference-of-squares82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
      10. sub-neg82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      11. sub-neg82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re + \left(-x.im\right)\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
      12. difference-of-squares64.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
      13. sqr-neg64.7%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
      14. difference-of-squares82.4%

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im\right) \]
      15. +-commutative82.4%

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

        \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)}\right) \]
      17. +-commutative82.4%

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

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

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \]
    5. Taylor expanded in x.re around 0 23.5%

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

        \[\leadsto \color{blue}{x.re \cdot {x.im}^{2}} \]
      2. unpow223.5%

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

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

    if -4.9999999999999997e162 < x.im

    1. Initial program 90.6%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around inf 56.5%

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

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

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

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

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

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

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

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

Alternative 10: 27.7% accurate, 3.8× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ x.im \cdot \left(x.im \cdot x.re\right) \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* x.im (* x.im x.re)))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return x_46_im * (x_46_im * x_46_re);
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = x_46im * (x_46im * x_46re)
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return x_46_im * (x_46_im * x_46_re);
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return x_46_im * (x_46_im * x_46_re)
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return Float64(x_46_im * Float64(x_46_im * x_46_re))
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = x_46_im * (x_46_im * x_46_re);
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(x$46$im * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.re = |x.re|\\
\\
x.im \cdot \left(x.im \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
    10. sub-neg91.1%

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
    11. sub-neg91.1%

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re + \left(-x.im\right)\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
    12. difference-of-squares87.2%

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
    13. sqr-neg87.2%

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
    14. difference-of-squares91.1%

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \]
  5. Taylor expanded in x.re around 0 27.4%

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

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

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

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

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

Alternative 11: 30.6% accurate, 3.8× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ x.re \cdot \left(x.im \cdot x.im\right) \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.im x.im)))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_im * x_46_im);
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = x_46re * (x_46im * x_46im)
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_im * x_46_im);
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return x_46_re * (x_46_im * x_46_im)
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return Float64(x_46_re * Float64(x_46_im * x_46_im))
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = x_46_re * (x_46_im * x_46_im);
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.re = |x.re|\\
\\
x.re \cdot \left(x.im \cdot x.im\right)
\end{array}
Derivation
  1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(\left(x.re + \left(-x.im\right)\right) \cdot \left(x.re - \left(-x.im\right)\right)\right)} \cdot x.im\right) \]
    10. sub-neg91.1%

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
    11. sub-neg91.1%

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(\color{blue}{\left(x.re + \left(-x.im\right)\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.im\right) \]
    12. difference-of-squares87.2%

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \color{blue}{\left(x.re \cdot x.re - \left(-x.im\right) \cdot \left(-x.im\right)\right)} \cdot x.im\right) \]
    13. sqr-neg87.2%

      \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im\right) \]
    14. difference-of-squares91.1%

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(x.re, 2 \cdot \left(x.re \cdot x.im\right), \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \]
  5. Taylor expanded in x.re around 0 27.4%

    \[\leadsto \color{blue}{{x.im}^{2} \cdot x.re} \]
  6. Step-by-step derivation
    1. *-commutative27.4%

      \[\leadsto \color{blue}{x.re \cdot {x.im}^{2}} \]
    2. unpow227.4%

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

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

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

Alternative 12: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ -1 \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 -1.0)
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return -1.0;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = -1.0d0
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return -1.0;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return -1.0
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return -1.0
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = -1.0;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := -1.0
\begin{array}{l}
x.re = |x.re|\\
\\
-1
\end{array}
Derivation
  1. Initial program 86.8%

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
  2. Taylor expanded in x.re around 0 67.1%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Alternative 13: 15.1% accurate, 19.0× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ 0 \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 0.0)
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return 0.0;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = 0.0d0
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return 0.0;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return 0.0
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return 0.0
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = 0.0;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := 0.0
\begin{array}{l}
x.re = |x.re|\\
\\
0
\end{array}
Derivation
  1. Initial program 86.8%

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
  2. Taylor expanded in x.re around 0 67.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  9. Final simplification15.2%

    \[\leadsto 0 \]

Developer target: 91.0% accurate, 1.1× speedup?

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

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

Reproduce

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

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

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