math.cube on complex, real part

Percentage Accurate: 83.2% → 95.8%
Time: 10.3s
Alternatives: 8
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 83.2% accurate, 1.0× speedup?

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

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

Alternative 1: 95.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq 7.2 \cdot 10^{+206}:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot \left(x.im + x.im\right), -x.im, \left(x.re \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - 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 7.2e+206)
   (fma
    (* x.re (+ x.im x.im))
    (- x.im)
    (* (* x.re (+ x.re x.im)) (- x.re x.im)))
   (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= 7.2e+206) {
		tmp = fma((x_46_re * (x_46_im + x_46_im)), -x_46_im, ((x_46_re * (x_46_re + x_46_im)) * (x_46_re - x_46_im)));
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= 7.2e+206)
		tmp = fma(Float64(x_46_re * Float64(x_46_im + x_46_im)), Float64(-x_46_im), Float64(Float64(x_46_re * Float64(x_46_re + x_46_im)) * Float64(x_46_re - x_46_im)));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 7.2e+206], N[(N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision] * (-x$46$im) + N[(N[(x$46$re * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 7.2 \cdot 10^{+206}:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot \left(x.im + x.im\right), -x.im, \left(x.re \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)\right)\\

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


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

    1. Initial program 90.3%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Applied egg-rr99.8%

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

    if 7.20000000000000057e206 < x.re

    1. Initial program 66.7%

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

      \[\leadsto \color{blue}{{x.re}^{3}} \]
    4. Step-by-step derivation
      1. cube-multN/A

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

        \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{x.re \cdot {x.re}^{2}} \]
      4. unpow2N/A

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
      5. lower-*.f64100.0

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

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

Alternative 2: 59.2% accurate, 0.7× 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 -1 \cdot 10^{-323}:\\ \;\;\;\;\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\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))))
      -1e-323)
   (* (* x.re x.im) (* x.im -3.0))
   (* 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)))) <= -1e-323) {
		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (((x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))) <= (-1d-323)) then
        tmp = (x_46re * x_46im) * (x_46im * (-3.0d0))
    else
        tmp = x_46re * (x_46re * x_46re)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_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)))) <= -1e-323) {
		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_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)))) <= -1e-323:
		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0)
	else:
		tmp = x_46_re * (x_46_re * x_46_re)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (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)))) <= -1e-323)
		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_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)))) <= -1e-323)
		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
	else
		tmp = x_46_re * (x_46_re * x_46_re);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[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], -1e-323], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.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 -1 \cdot 10^{-323}:\\
\;\;\;\;\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\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)) < -9.88131e-324

    1. Initial program 92.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. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto x.re \cdot \color{blue}{\left({x.im}^{2} \cdot \left(-1 - 2\right)\right)} \]
      3. lower-*.f64N/A

        \[\leadsto x.re \cdot \color{blue}{\left({x.im}^{2} \cdot \left(-1 - 2\right)\right)} \]
      4. unpow2N/A

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(-1 - 2\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(-1 - 2\right)\right) \]
      6. metadata-eval41.0

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

      \[\leadsto \color{blue}{x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto x.re \cdot \color{blue}{\left(x.im \cdot \left(x.im \cdot -3\right)\right)} \]
      2. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot \left(x.im \cdot -3\right) \]
      5. lower-*.f64N/A

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

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

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

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

    if -9.88131e-324 < (-.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 86.2%

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

      \[\leadsto \color{blue}{{x.re}^{3}} \]
    4. Step-by-step derivation
      1. cube-multN/A

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

        \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{x.re \cdot {x.re}^{2}} \]
      4. unpow2N/A

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
      5. lower-*.f6463.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq -1 \cdot 10^{-323}:\\ \;\;\;\;\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\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 59.2% accurate, 0.7× 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 -1 \cdot 10^{-323}:\\ \;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (-
       (* x.re (- (* x.re x.re) (* x.im x.im)))
       (* x.im (+ (* x.re x.im) (* x.re x.im))))
      -1e-323)
   (* -3.0 (* x.im (* x.re x.im)))
   (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_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)))) <= -1e-323) {
		tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (((x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))) <= (-1d-323)) then
        tmp = (-3.0d0) * (x_46im * (x_46re * x_46im))
    else
        tmp = x_46re * (x_46re * x_46re)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_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)))) <= -1e-323) {
		tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_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)))) <= -1e-323:
		tmp = -3.0 * (x_46_im * (x_46_re * x_46_im))
	else:
		tmp = x_46_re * (x_46_re * x_46_re)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (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)))) <= -1e-323)
		tmp = Float64(-3.0 * Float64(x_46_im * Float64(x_46_re * x_46_im)));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_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)))) <= -1e-323)
		tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
	else
		tmp = x_46_re * (x_46_re * x_46_re);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[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], -1e-323], N[(-3.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.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 -1 \cdot 10^{-323}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.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)) < -9.88131e-324

    1. Initial program 92.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. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto x.re \cdot \color{blue}{\left({x.im}^{2} \cdot \left(-1 - 2\right)\right)} \]
      3. lower-*.f64N/A

        \[\leadsto x.re \cdot \color{blue}{\left({x.im}^{2} \cdot \left(-1 - 2\right)\right)} \]
      4. unpow2N/A

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(-1 - 2\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(-1 - 2\right)\right) \]
      6. metadata-eval41.0

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

      \[\leadsto \color{blue}{x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(x.re \cdot \left(x.im \cdot x.im\right)\right) \cdot -3} \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(x.re \cdot \left(x.im \cdot x.im\right)\right) \cdot -3} \]
      5. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\left(x.im \cdot x.im\right) \cdot x.re\right)} \cdot -3 \]
      7. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(x.im \cdot \left(x.im \cdot x.re\right)\right)} \cdot -3 \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x.im \cdot \left(x.im \cdot x.re\right)\right)} \cdot -3 \]
      10. *-commutativeN/A

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

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

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

    if -9.88131e-324 < (-.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 86.2%

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

      \[\leadsto \color{blue}{{x.re}^{3}} \]
    4. Step-by-step derivation
      1. cube-multN/A

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

        \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{x.re \cdot {x.re}^{2}} \]
      4. unpow2N/A

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
      5. lower-*.f6463.5

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

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

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

Alternative 4: 59.2% accurate, 0.7× 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 -1 \cdot 10^{-323}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\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))))
      -1e-323)
   (* x.im (* x.im (* x.re -3.0)))
   (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_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)))) <= -1e-323) {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (((x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))) <= (-1d-323)) then
        tmp = x_46im * (x_46im * (x_46re * (-3.0d0)))
    else
        tmp = x_46re * (x_46re * x_46re)
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_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)))) <= -1e-323) {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	} else {
		tmp = x_46_re * (x_46_re * x_46_re);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_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)))) <= -1e-323:
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0))
	else:
		tmp = x_46_re * (x_46_re * x_46_re)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (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)))) <= -1e-323)
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0)));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_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)))) <= -1e-323)
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	else
		tmp = x_46_re * (x_46_re * x_46_re);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[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], -1e-323], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $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 -1 \cdot 10^{-323}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\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)) < -9.88131e-324

    1. Initial program 92.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. Add Preprocessing
    3. Applied egg-rr99.8%

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

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

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

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

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

      if -9.88131e-324 < (-.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 86.2%

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

        \[\leadsto \color{blue}{{x.re}^{3}} \]
      4. Step-by-step derivation
        1. cube-multN/A

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

          \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
        3. lower-*.f64N/A

          \[\leadsto \color{blue}{x.re \cdot {x.re}^{2}} \]
        4. unpow2N/A

          \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
        5. lower-*.f6463.5

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

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

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

    Alternative 5: 92.4% accurate, 1.2× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq 2.25 \cdot 10^{-86}:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot x.im, x.im \cdot -3, x.re \cdot \left(x.re \cdot x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\ \end{array} \end{array} \]
    (FPCore (x.re x.im)
     :precision binary64
     (if (<= x.re 2.25e-86)
       (fma (* x.re x.im) (* x.im -3.0) (* x.re (* x.re x.re)))
       (* x.re (fma x.im (* x.im -3.0) (* x.re x.re)))))
    double code(double x_46_re, double x_46_im) {
    	double tmp;
    	if (x_46_re <= 2.25e-86) {
    		tmp = fma((x_46_re * x_46_im), (x_46_im * -3.0), (x_46_re * (x_46_re * x_46_re)));
    	} else {
    		tmp = x_46_re * fma(x_46_im, (x_46_im * -3.0), (x_46_re * x_46_re));
    	}
    	return tmp;
    }
    
    function code(x_46_re, x_46_im)
    	tmp = 0.0
    	if (x_46_re <= 2.25e-86)
    		tmp = fma(Float64(x_46_re * x_46_im), Float64(x_46_im * -3.0), Float64(x_46_re * Float64(x_46_re * x_46_re)));
    	else
    		tmp = Float64(x_46_re * fma(x_46_im, Float64(x_46_im * -3.0), Float64(x_46_re * x_46_re)));
    	end
    	return tmp
    end
    
    code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 2.25e-86], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x.re \leq 2.25 \cdot 10^{-86}:\\
    \;\;\;\;\mathsf{fma}\left(x.re \cdot x.im, x.im \cdot -3, x.re \cdot \left(x.re \cdot x.re\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x.re < 2.2499999999999999e-86

      1. Initial program 89.3%

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

        \[\leadsto \color{blue}{x.re \cdot \left(\left(-1 \cdot {x.im}^{2} + {x.re}^{2}\right) - 2 \cdot {x.im}^{2}\right)} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

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

          \[\leadsto x.re \cdot \left(\color{blue}{\left({x.re}^{2} + -1 \cdot {x.im}^{2}\right)} - 2 \cdot {x.im}^{2}\right) \]
        3. associate--l+N/A

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

          \[\leadsto x.re \cdot \left(\color{blue}{x.re \cdot x.re} + \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)\right) \]
        5. lower-fma.f64N/A

          \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, -1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
        6. distribute-rgt-out--N/A

          \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{{x.im}^{2} \cdot \left(-1 - 2\right)}\right) \]
        7. lower-*.f64N/A

          \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{{x.im}^{2} \cdot \left(-1 - 2\right)}\right) \]
        8. unpow2N/A

          \[\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) \]
        9. lower-*.f64N/A

          \[\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) \]
        10. metadata-eval91.0

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

        \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, \left(x.im \cdot x.im\right) \cdot -3\right)} \]
      6. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto x.re \cdot \left(x.re \cdot x.re + \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3\right) \]
        2. lift-*.f64N/A

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

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

          \[\leadsto x.re \cdot \color{blue}{\left(\left(x.im \cdot x.im\right) \cdot -3 + x.re \cdot x.re\right)} \]
        5. distribute-lft-inN/A

          \[\leadsto \color{blue}{x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right) + x.re \cdot \left(x.re \cdot x.re\right)} \]
        6. lift-*.f64N/A

          \[\leadsto x.re \cdot \color{blue}{\left(\left(x.im \cdot x.im\right) \cdot -3\right)} + x.re \cdot \left(x.re \cdot x.re\right) \]
        7. lift-*.f64N/A

          \[\leadsto x.re \cdot \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot -3\right) + x.re \cdot \left(x.re \cdot x.re\right) \]
        8. associate-*l*N/A

          \[\leadsto x.re \cdot \color{blue}{\left(x.im \cdot \left(x.im \cdot -3\right)\right)} + x.re \cdot \left(x.re \cdot x.re\right) \]
        9. associate-*r*N/A

          \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)} + x.re \cdot \left(x.re \cdot x.re\right) \]
        10. lift-*.f64N/A

          \[\leadsto \left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right) + \color{blue}{x.re \cdot \left(x.re \cdot x.re\right)} \]
        11. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(x.re \cdot x.im, x.im \cdot -3, x.re \cdot \left(x.re \cdot x.re\right)\right)} \]
        12. lower-*.f64N/A

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

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

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

      if 2.2499999999999999e-86 < x.re

      1. Initial program 88.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. Add Preprocessing
      3. Taylor expanded in x.re around 0

        \[\leadsto \color{blue}{x.re \cdot \left(\left(-1 \cdot {x.im}^{2} + {x.re}^{2}\right) - 2 \cdot {x.im}^{2}\right)} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

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

          \[\leadsto x.re \cdot \left(\color{blue}{\left({x.re}^{2} + -1 \cdot {x.im}^{2}\right)} - 2 \cdot {x.im}^{2}\right) \]
        3. associate--l+N/A

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

          \[\leadsto x.re \cdot \left(\color{blue}{x.re \cdot x.re} + \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)\right) \]
        5. lower-fma.f64N/A

          \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, -1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
        6. distribute-rgt-out--N/A

          \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{{x.im}^{2} \cdot \left(-1 - 2\right)}\right) \]
        7. lower-*.f64N/A

          \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{{x.im}^{2} \cdot \left(-1 - 2\right)}\right) \]
        8. unpow2N/A

          \[\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) \]
        9. lower-*.f64N/A

          \[\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) \]
        10. metadata-eval97.2

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

        \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, \left(x.im \cdot x.im\right) \cdot -3\right)} \]
      6. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto x.re \cdot \left(x.re \cdot x.re + \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3\right) \]
        2. lift-*.f64N/A

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

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

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

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

          \[\leadsto \color{blue}{\left(x.re \cdot x.re + \left(x.im \cdot x.im\right) \cdot -3\right)} \cdot x.re \]
        7. lift-*.f64N/A

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

          \[\leadsto \color{blue}{\left(\left(x.im \cdot x.im\right) \cdot -3 + x.re \cdot x.re\right)} \cdot x.re \]
        9. lift-*.f64N/A

          \[\leadsto \left(\color{blue}{\left(x.im \cdot x.im\right) \cdot -3} + x.re \cdot x.re\right) \cdot x.re \]
        10. lift-*.f64N/A

          \[\leadsto \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot -3 + x.re \cdot x.re\right) \cdot x.re \]
        11. associate-*l*N/A

          \[\leadsto \left(\color{blue}{x.im \cdot \left(x.im \cdot -3\right)} + x.re \cdot x.re\right) \cdot x.re \]
        12. lower-fma.f64N/A

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq 2.25 \cdot 10^{-86}:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot x.im, x.im \cdot -3, x.re \cdot \left(x.re \cdot x.re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 6: 75.1% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq 6 \cdot 10^{-119}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\ \end{array} \end{array} \]
    (FPCore (x.re x.im)
     :precision binary64
     (if (<= x.re 6e-119)
       (* (* x.re x.im) (* x.im -3.0))
       (* x.re (fma x.im (* x.im -3.0) (* x.re x.re)))))
    double code(double x_46_re, double x_46_im) {
    	double tmp;
    	if (x_46_re <= 6e-119) {
    		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
    	} else {
    		tmp = x_46_re * fma(x_46_im, (x_46_im * -3.0), (x_46_re * x_46_re));
    	}
    	return tmp;
    }
    
    function code(x_46_re, x_46_im)
    	tmp = 0.0
    	if (x_46_re <= 6e-119)
    		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0));
    	else
    		tmp = Float64(x_46_re * fma(x_46_im, Float64(x_46_im * -3.0), Float64(x_46_re * x_46_re)));
    	end
    	return tmp
    end
    
    code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 6e-119], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x.re \leq 6 \cdot 10^{-119}:\\
    \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x.re < 6.0000000000000004e-119

      1. Initial program 88.9%

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

        \[\leadsto \color{blue}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

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

          \[\leadsto x.re \cdot \color{blue}{\left({x.im}^{2} \cdot \left(-1 - 2\right)\right)} \]
        3. lower-*.f64N/A

          \[\leadsto x.re \cdot \color{blue}{\left({x.im}^{2} \cdot \left(-1 - 2\right)\right)} \]
        4. unpow2N/A

          \[\leadsto x.re \cdot \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(-1 - 2\right)\right) \]
        5. lower-*.f64N/A

          \[\leadsto x.re \cdot \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(-1 - 2\right)\right) \]
        6. metadata-eval56.9

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

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)} \]
      6. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto x.re \cdot \color{blue}{\left(x.im \cdot \left(x.im \cdot -3\right)\right)} \]
        2. lift-*.f64N/A

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

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

          \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot \left(x.im \cdot -3\right) \]
        5. lower-*.f64N/A

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

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

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

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

      if 6.0000000000000004e-119 < x.re

      1. Initial program 89.1%

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

        \[\leadsto \color{blue}{x.re \cdot \left(\left(-1 \cdot {x.im}^{2} + {x.re}^{2}\right) - 2 \cdot {x.im}^{2}\right)} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

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

          \[\leadsto x.re \cdot \left(\color{blue}{\left({x.re}^{2} + -1 \cdot {x.im}^{2}\right)} - 2 \cdot {x.im}^{2}\right) \]
        3. associate--l+N/A

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

          \[\leadsto x.re \cdot \left(\color{blue}{x.re \cdot x.re} + \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)\right) \]
        5. lower-fma.f64N/A

          \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, -1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
        6. distribute-rgt-out--N/A

          \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{{x.im}^{2} \cdot \left(-1 - 2\right)}\right) \]
        7. lower-*.f64N/A

          \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{{x.im}^{2} \cdot \left(-1 - 2\right)}\right) \]
        8. unpow2N/A

          \[\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) \]
        9. lower-*.f64N/A

          \[\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) \]
        10. metadata-eval97.5

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

        \[\leadsto \color{blue}{x.re \cdot \mathsf{fma}\left(x.re, x.re, \left(x.im \cdot x.im\right) \cdot -3\right)} \]
      6. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto x.re \cdot \left(x.re \cdot x.re + \color{blue}{\left(x.im \cdot x.im\right)} \cdot -3\right) \]
        2. lift-*.f64N/A

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

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

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

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

          \[\leadsto \color{blue}{\left(x.re \cdot x.re + \left(x.im \cdot x.im\right) \cdot -3\right)} \cdot x.re \]
        7. lift-*.f64N/A

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

          \[\leadsto \color{blue}{\left(\left(x.im \cdot x.im\right) \cdot -3 + x.re \cdot x.re\right)} \cdot x.re \]
        9. lift-*.f64N/A

          \[\leadsto \left(\color{blue}{\left(x.im \cdot x.im\right) \cdot -3} + x.re \cdot x.re\right) \cdot x.re \]
        10. lift-*.f64N/A

          \[\leadsto \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot -3 + x.re \cdot x.re\right) \cdot x.re \]
        11. associate-*l*N/A

          \[\leadsto \left(\color{blue}{x.im \cdot \left(x.im \cdot -3\right)} + x.re \cdot x.re\right) \cdot x.re \]
        12. lower-fma.f64N/A

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq 6 \cdot 10^{-119}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 7: 75.0% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq 7 \cdot 10^{-107}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, -3 \cdot \left(x.im \cdot x.im\right)\right)\\ \end{array} \end{array} \]
    (FPCore (x.re x.im)
     :precision binary64
     (if (<= x.re 7e-107)
       (* (* x.re x.im) (* x.im -3.0))
       (* x.re (fma x.re x.re (* -3.0 (* x.im x.im))))))
    double code(double x_46_re, double x_46_im) {
    	double tmp;
    	if (x_46_re <= 7e-107) {
    		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
    	} else {
    		tmp = x_46_re * fma(x_46_re, x_46_re, (-3.0 * (x_46_im * x_46_im)));
    	}
    	return tmp;
    }
    
    function code(x_46_re, x_46_im)
    	tmp = 0.0
    	if (x_46_re <= 7e-107)
    		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0));
    	else
    		tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(-3.0 * Float64(x_46_im * x_46_im))));
    	end
    	return tmp
    end
    
    code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 7e-107], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re + N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x.re \leq 7 \cdot 10^{-107}:\\
    \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, -3 \cdot \left(x.im \cdot x.im\right)\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x.re < 6.99999999999999971e-107

      1. Initial program 89.1%

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

        \[\leadsto \color{blue}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

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

          \[\leadsto x.re \cdot \color{blue}{\left({x.im}^{2} \cdot \left(-1 - 2\right)\right)} \]
        3. lower-*.f64N/A

          \[\leadsto x.re \cdot \color{blue}{\left({x.im}^{2} \cdot \left(-1 - 2\right)\right)} \]
        4. unpow2N/A

          \[\leadsto x.re \cdot \left(\color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(-1 - 2\right)\right) \]
        5. lower-*.f64N/A

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

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

        \[\leadsto \color{blue}{x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)} \]
      6. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto x.re \cdot \color{blue}{\left(x.im \cdot \left(x.im \cdot -3\right)\right)} \]
        2. lift-*.f64N/A

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

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

          \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot \left(x.im \cdot -3\right) \]
        5. lower-*.f64N/A

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

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

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

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

      if 6.99999999999999971e-107 < x.re

      1. Initial program 88.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. Add Preprocessing
      3. Taylor expanded in x.re around 0

        \[\leadsto \color{blue}{x.re \cdot \left(\left(-1 \cdot {x.im}^{2} + {x.re}^{2}\right) - 2 \cdot {x.im}^{2}\right)} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

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

          \[\leadsto x.re \cdot \left(\color{blue}{\left({x.re}^{2} + -1 \cdot {x.im}^{2}\right)} - 2 \cdot {x.im}^{2}\right) \]
        3. associate--l+N/A

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

          \[\leadsto x.re \cdot \left(\color{blue}{x.re \cdot x.re} + \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)\right) \]
        5. lower-fma.f64N/A

          \[\leadsto x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, -1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
        6. distribute-rgt-out--N/A

          \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{{x.im}^{2} \cdot \left(-1 - 2\right)}\right) \]
        7. lower-*.f64N/A

          \[\leadsto x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{{x.im}^{2} \cdot \left(-1 - 2\right)}\right) \]
        8. unpow2N/A

          \[\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) \]
        9. lower-*.f64N/A

          \[\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) \]
        10. metadata-eval97.3

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq 7 \cdot 10^{-107}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, -3 \cdot \left(x.im \cdot x.im\right)\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 8: 59.5% accurate, 3.6× 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 88.9%

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

      \[\leadsto \color{blue}{{x.re}^{3}} \]
    4. Step-by-step derivation
      1. cube-multN/A

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

        \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{x.re \cdot {x.re}^{2}} \]
      4. unpow2N/A

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
      5. lower-*.f6459.5

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

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

    Developer Target 1: 87.3% 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 2024207 
    (FPCore (x.re x.im)
      :name "math.cube on complex, real part"
      :precision binary64
    
      :alt
      (! :herbie-platform default (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3 x.im)))))
    
      (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))