
(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:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 1.15e+140) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (* x.im (* -3.0 (* x.im x.re)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.15e+140) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46im <= 1.15d+140) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = x_46im * ((-3.0d0) * (x_46im * x_46re))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.15e+140) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 1.15e+140: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 1.15e+140) tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * Float64(x_46_im * -3.0)))); else tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_im * x_46_re))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 1.15e+140) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 1.15e+140], N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(-3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.15 \cdot 10^{+140}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(-3 \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 1.14999999999999995e140Initial program 90.7%
*-commutative90.7%
distribute-lft-out90.7%
associate-*l*90.7%
*-commutative90.7%
distribute-rgt-out--96.3%
associate--l-96.3%
associate--l-96.3%
sub-neg96.3%
associate--l+96.3%
fma-udef96.3%
neg-mul-196.3%
count-296.3%
associate-*l*96.3%
distribute-rgt-out--96.3%
associate-*r*96.3%
metadata-eval96.3%
Simplified96.3%
fma-udef96.3%
Applied egg-rr96.3%
if 1.14999999999999995e140 < x.im Initial program 44.4%
*-commutative44.4%
distribute-lft-out44.4%
associate-*l*44.4%
*-commutative44.4%
distribute-rgt-out--44.4%
associate--l-44.4%
associate--l-44.4%
sub-neg44.4%
associate--l+44.4%
fma-udef59.4%
neg-mul-159.4%
count-259.4%
associate-*l*59.4%
distribute-rgt-out--59.4%
associate-*r*59.4%
metadata-eval59.4%
Simplified59.4%
Taylor expanded in x.re around 0 59.4%
associate-*r*59.4%
unpow259.4%
Simplified59.4%
add-sqr-sqrt30.5%
pow230.5%
*-commutative30.5%
sqrt-prod30.5%
sqrt-prod37.5%
add-sqr-sqrt37.5%
*-commutative37.5%
Applied egg-rr37.5%
unpow237.5%
*-commutative37.5%
*-commutative37.5%
swap-sqr30.5%
add-sqr-sqrt59.4%
*-commutative59.4%
associate-*r*59.4%
associate-*r*84.8%
associate-*r*84.9%
Applied egg-rr84.9%
Final simplification94.5%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 24000000000.0) (* x.re (* x.re x.re)) (* -3.0 (* x.re (* x.im x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 24000000000.0) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46im <= 24000000000.0d0) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 24000000000.0) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 24000000000.0: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 24000000000.0) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 24000000000.0) tmp = x_46_re * (x_46_re * x_46_re); else tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 24000000000.0], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 24000000000:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 2.4e10Initial program 92.3%
*-commutative92.3%
distribute-lft-out92.3%
associate-*l*92.3%
*-commutative92.3%
distribute-rgt-out--95.9%
associate--l-95.9%
associate--l-95.9%
sub-neg95.9%
associate--l+95.9%
fma-udef95.9%
neg-mul-195.9%
count-295.9%
associate-*l*95.9%
distribute-rgt-out--95.9%
associate-*r*95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in x.re around inf 69.6%
unpow269.6%
Simplified69.6%
if 2.4e10 < x.im Initial program 56.7%
*-commutative56.7%
distribute-lft-out56.7%
associate-*l*56.6%
*-commutative56.6%
distribute-rgt-out--64.6%
associate--l-64.6%
associate--l-64.6%
sub-neg64.6%
associate--l+64.6%
fma-udef74.1%
neg-mul-174.1%
count-274.1%
associate-*l*74.1%
distribute-rgt-out--74.1%
associate-*r*74.1%
metadata-eval74.1%
Simplified74.1%
fma-udef64.6%
Applied egg-rr64.6%
Taylor expanded in x.re around 0 63.0%
unpow263.0%
Simplified63.0%
Final simplification68.0%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 7500000000.0) (* x.re (* x.re x.re)) (* (* x.re -3.0) (* x.im x.im))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 7500000000.0) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = (x_46_re * -3.0) * (x_46_im * x_46_im);
}
return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46im <= 7500000000.0d0) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (x_46re * (-3.0d0)) * (x_46im * x_46im)
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 7500000000.0) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = (x_46_re * -3.0) * (x_46_im * x_46_im);
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 7500000000.0: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = (x_46_re * -3.0) * (x_46_im * x_46_im) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 7500000000.0) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(Float64(x_46_re * -3.0) * Float64(x_46_im * x_46_im)); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 7500000000.0) tmp = x_46_re * (x_46_re * x_46_re); else tmp = (x_46_re * -3.0) * (x_46_im * x_46_im); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 7500000000.0], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * -3.0), $MachinePrecision] * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 7500000000:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot -3\right) \cdot \left(x.im \cdot x.im\right)\\
\end{array}
\end{array}
if x.im < 7.5e9Initial program 92.3%
*-commutative92.3%
distribute-lft-out92.3%
associate-*l*92.3%
*-commutative92.3%
distribute-rgt-out--95.9%
associate--l-95.9%
associate--l-95.9%
sub-neg95.9%
associate--l+95.9%
fma-udef95.9%
neg-mul-195.9%
count-295.9%
associate-*l*95.9%
distribute-rgt-out--95.9%
associate-*r*95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in x.re around inf 69.6%
unpow269.6%
Simplified69.6%
if 7.5e9 < x.im Initial program 56.7%
*-commutative56.7%
distribute-lft-out56.7%
associate-*l*56.6%
*-commutative56.6%
distribute-rgt-out--64.6%
associate--l-64.6%
associate--l-64.6%
sub-neg64.6%
associate--l+64.6%
fma-udef74.1%
neg-mul-174.1%
count-274.1%
associate-*l*74.1%
distribute-rgt-out--74.1%
associate-*r*74.1%
metadata-eval74.1%
Simplified74.1%
Taylor expanded in x.re around 0 63.0%
associate-*r*63.0%
unpow263.0%
Simplified63.0%
Final simplification68.0%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 530000000000.0) (* x.re (* x.re x.re)) (* x.im (* -3.0 (* x.im x.re)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 530000000000.0) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46im <= 530000000000.0d0) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = x_46im * ((-3.0d0) * (x_46im * x_46re))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 530000000000.0) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 530000000000.0: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 530000000000.0) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_im * x_46_re))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 530000000000.0) tmp = x_46_re * (x_46_re * x_46_re); else tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 530000000000.0], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(-3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 530000000000:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(-3 \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 5.3e11Initial program 92.3%
*-commutative92.3%
distribute-lft-out92.3%
associate-*l*92.3%
*-commutative92.3%
distribute-rgt-out--95.9%
associate--l-95.9%
associate--l-95.9%
sub-neg95.9%
associate--l+95.9%
fma-udef95.9%
neg-mul-195.9%
count-295.9%
associate-*l*95.9%
distribute-rgt-out--95.9%
associate-*r*95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in x.re around inf 69.6%
unpow269.6%
Simplified69.6%
if 5.3e11 < x.im Initial program 56.7%
*-commutative56.7%
distribute-lft-out56.7%
associate-*l*56.6%
*-commutative56.6%
distribute-rgt-out--64.6%
associate--l-64.6%
associate--l-64.6%
sub-neg64.6%
associate--l+64.6%
fma-udef74.1%
neg-mul-174.1%
count-274.1%
associate-*l*74.1%
distribute-rgt-out--74.1%
associate-*r*74.1%
metadata-eval74.1%
Simplified74.1%
Taylor expanded in x.re around 0 63.0%
associate-*r*63.0%
unpow263.0%
Simplified63.0%
add-sqr-sqrt33.5%
pow233.5%
*-commutative33.5%
sqrt-prod33.5%
sqrt-prod37.8%
add-sqr-sqrt37.9%
*-commutative37.9%
Applied egg-rr37.9%
unpow237.9%
*-commutative37.9%
*-commutative37.9%
swap-sqr33.6%
add-sqr-sqrt63.0%
*-commutative63.0%
associate-*r*63.0%
associate-*r*79.1%
associate-*r*79.2%
Applied egg-rr79.2%
Final simplification72.0%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 7800000000.0) (* x.re (* x.re x.re)) (* x.im (* x.im (* x.re -3.0)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 7800000000.0) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46im <= 7800000000.0d0) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = x_46im * (x_46im * (x_46re * (-3.0d0)))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 7800000000.0) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 7800000000.0: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = x_46_im * (x_46_im * (x_46_re * -3.0)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 7800000000.0) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 7800000000.0) tmp = x_46_re * (x_46_re * x_46_re); else tmp = x_46_im * (x_46_im * (x_46_re * -3.0)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 7800000000.0], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 7800000000:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\
\end{array}
\end{array}
if x.im < 7.8e9Initial program 92.3%
*-commutative92.3%
distribute-lft-out92.3%
associate-*l*92.3%
*-commutative92.3%
distribute-rgt-out--95.9%
associate--l-95.9%
associate--l-95.9%
sub-neg95.9%
associate--l+95.9%
fma-udef95.9%
neg-mul-195.9%
count-295.9%
associate-*l*95.9%
distribute-rgt-out--95.9%
associate-*r*95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in x.re around inf 69.6%
unpow269.6%
Simplified69.6%
if 7.8e9 < x.im Initial program 56.7%
*-commutative56.7%
distribute-lft-out56.7%
associate-*l*56.6%
*-commutative56.6%
distribute-rgt-out--64.6%
associate--l-64.6%
associate--l-64.6%
sub-neg64.6%
associate--l+64.6%
fma-udef74.1%
neg-mul-174.1%
count-274.1%
associate-*l*74.1%
distribute-rgt-out--74.1%
associate-*r*74.1%
metadata-eval74.1%
Simplified74.1%
Taylor expanded in x.re around 0 63.0%
associate-*r*63.0%
unpow263.0%
Simplified63.0%
add-sqr-sqrt33.5%
pow233.5%
*-commutative33.5%
sqrt-prod33.5%
sqrt-prod37.8%
add-sqr-sqrt37.9%
*-commutative37.9%
Applied egg-rr37.9%
unpow237.9%
*-commutative37.9%
*-commutative37.9%
swap-sqr33.6%
add-sqr-sqrt63.0%
associate-*r*79.2%
Applied egg-rr79.2%
Final simplification72.0%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.re)))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_re);
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = x_46re * (x_46re * x_46re)
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_re);
}
x.im = abs(x.im) def code(x_46_re, x_46_im): return x_46_re * (x_46_re * x_46_re)
x.im = abs(x.im) function code(x_46_re, x_46_im) return Float64(x_46_re * Float64(x_46_re * x_46_re)) end
x.im = abs(x.im) function tmp = code(x_46_re, x_46_im) tmp = x_46_re * (x_46_re * x_46_re); end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im = |x.im|\\
\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Initial program 83.5%
*-commutative83.5%
distribute-lft-out83.5%
associate-*l*83.5%
*-commutative83.5%
distribute-rgt-out--88.2%
associate--l-88.2%
associate--l-88.2%
sub-neg88.2%
associate--l+88.2%
fma-udef90.5%
neg-mul-190.5%
count-290.5%
associate-*l*90.5%
distribute-rgt-out--90.5%
associate-*r*90.5%
metadata-eval90.5%
Simplified90.5%
Taylor expanded in x.re around inf 57.9%
unpow257.9%
Simplified57.9%
Final simplification57.9%
(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}
herbie shell --seed 2023188
(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)))