math.cube on complex, real part

Percentage Accurate: 81.8% → 96.1%
Time: 6.3s
Alternatives: 6
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 6 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: 81.8% accurate, 1.0× speedup?

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

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

Alternative 1: 96.1% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -6.8 \cdot 10^{+141} \lor \neg \left(x.im \leq 2.7 \cdot 10^{+135}\right):\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -6.7999999999999996e141 or 2.69999999999999985e135 < x.im

    1. Initial program 50.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.7999999999999996e141 < x.im < 2.69999999999999985e135

    1. Initial program 90.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (-
       (* x.re (- (* x.re x.re) (* x.im x.im)))
       (* x.im (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (- (* (+ x.re x.im) (* x.re (- x.re x.im))) (* x.im (* x.re (+ x.im x.im))))
   (* x.re (fma x.re x.re (* x.im (* x.im -3.0))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = ((x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))) - (x_46_im * (x_46_re * (x_46_im + x_46_im)));
	} else {
		tmp = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = Float64(Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re * Float64(x_46_re - x_46_im))) - Float64(x_46_im * Float64(x_46_re * Float64(x_46_im + x_46_im))));
	else
		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0))));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re + N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 91.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 96.5% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 91.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 72.6% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -6.6 \lor \neg \left(x.re \leq 1.02 \cdot 10^{+26}\right) \land \left(x.re \leq 2.2 \cdot 10^{+78} \lor \neg \left(x.re \leq 4.9 \cdot 10^{+113}\right)\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -6.5999999999999996 or 1.0200000000000001e26 < x.re < 2.20000000000000014e78 or 4.90000000000000021e113 < x.re

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.5999999999999996 < x.re < 1.0200000000000001e26 or 2.20000000000000014e78 < x.re < 4.90000000000000021e113

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -6.6 \lor \neg \left(x.re \leq 1.02 \cdot 10^{+26}\right) \land \left(x.re \leq 2.2 \cdot 10^{+78} \lor \neg \left(x.re \leq 4.9 \cdot 10^{+113}\right)\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)\\ \end{array} \]

Alternative 5: 79.2% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{if}\;x.re \leq -15.2:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x.re \leq 2.2 \cdot 10^{+78} \lor \neg \left(x.re \leq 1.95 \cdot 10^{+108}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -15.199999999999999 or 7.9999999999999999e24 < x.re < 2.20000000000000014e78 or 1.94999999999999992e108 < x.re

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -15.199999999999999 < x.re < 7.9999999999999999e24

    1. Initial program 84.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.20000000000000014e78 < x.re < 1.94999999999999992e108

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -15.2:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq 8 \cdot 10^{+24}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{elif}\;x.re \leq 2.2 \cdot 10^{+78} \lor \neg \left(x.re \leq 1.95 \cdot 10^{+108}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)\\ \end{array} \]

Alternative 6: 58.6% accurate, 3.8× speedup?

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

\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Developer target: 86.8% accurate, 1.1× speedup?

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

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

Reproduce

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

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

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