Average Error: 11.6 → 2.2
Time: 3.6s
Precision: binary64
\[\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 \]
\[\begin{array}{l} \mathbf{if}\;x.re \leq -2.6528090666816572 \cdot 10^{+163} \lor \neg \left(x.re \leq 3.1664951455267414 \cdot 10^{+196}\right):\\ \;\;\;\;{x.re}^{3}\\ \mathbf{else}:\\ \;\;\;\;\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 x.im + x.re \cdot x.im\right)\\ \end{array} \]
\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
\begin{array}{l}
\mathbf{if}\;x.re \leq -2.6528090666816572 \cdot 10^{+163} \lor \neg \left(x.re \leq 3.1664951455267414 \cdot 10^{+196}\right):\\
\;\;\;\;{x.re}^{3}\\

\mathbf{else}:\\
\;\;\;\;\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 x.im + x.re \cdot x.im\right)\\


\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)))
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -2.6528090666816572e+163)
         (not (<= x.re 3.1664951455267414e+196)))
   (pow x.re 3.0)
   (-
    (* (+ x.re x.im) (* x.re (- x.re x.im)))
    (* x.im (+ (* x.re x.im) (* x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	return (((x_46_re * x_46_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);
}
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -2.6528090666816572e+163) || !(x_46_re <= 3.1664951455267414e+196)) {
		tmp = pow(x_46_re, 3.0);
	} else {
		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_re * x_46_im)));
	}
	return tmp;
}

Error

Bits error versus x.re

Bits error versus x.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.6
Target8.1
Herbie2.2
\[\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) \]

Derivation

  1. Split input into 2 regimes
  2. if x.re < -2.6528090666816572e163 or 3.1664951455267414e196 < x.re

    1. Initial program 29.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. Simplified10.1

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

      \[\leadsto \color{blue}{{x.re}^{3}} \]

    if -2.6528090666816572e163 < x.re < 3.1664951455267414e196

    1. Initial program 7.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. Applied difference-of-squares_binary646.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.6528090666816572 \cdot 10^{+163} \lor \neg \left(x.re \leq 3.1664951455267414 \cdot 10^{+196}\right):\\ \;\;\;\;{x.re}^{3}\\ \mathbf{else}:\\ \;\;\;\;\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 x.im + x.re \cdot x.im\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022067 
(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)))