
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Initial program 100.0%
(FPCore (re im) :precision binary64 (if (<= im 360.0) (* (cos re) (+ 1.0 (* 0.5 (pow im 2.0)))) (* im (log1p (expm1 (* (cos re) (* 0.5 im)))))))
double code(double re, double im) {
double tmp;
if (im <= 360.0) {
tmp = cos(re) * (1.0 + (0.5 * pow(im, 2.0)));
} else {
tmp = im * log1p(expm1((cos(re) * (0.5 * im))));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 360.0) {
tmp = Math.cos(re) * (1.0 + (0.5 * Math.pow(im, 2.0)));
} else {
tmp = im * Math.log1p(Math.expm1((Math.cos(re) * (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 360.0: tmp = math.cos(re) * (1.0 + (0.5 * math.pow(im, 2.0))) else: tmp = im * math.log1p(math.expm1((math.cos(re) * (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 360.0) tmp = Float64(cos(re) * Float64(1.0 + Float64(0.5 * (im ^ 2.0)))); else tmp = Float64(im * log1p(expm1(Float64(cos(re) * Float64(0.5 * im))))); end return tmp end
code[re_, im_] := If[LessEqual[im, 360.0], N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[Log[1 + N[(Exp[N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 360:\\
\;\;\;\;\cos re \cdot \left(1 + 0.5 \cdot {im}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos re \cdot \left(0.5 \cdot im\right)\right)\right)\\
\end{array}
\end{array}
if im < 360Initial program 100.0%
Taylor expanded in im around 0 86.3%
associate-*r*86.3%
distribute-rgt1-in86.3%
*-commutative86.3%
fma-define86.3%
Simplified86.3%
Taylor expanded in re around inf 86.3%
if 360 < im Initial program 100.0%
Taylor expanded in im around 0 51.2%
associate-*r*51.2%
distribute-rgt1-in51.2%
*-commutative51.2%
fma-define51.2%
Simplified51.2%
Taylor expanded in im around inf 51.2%
associate-*r*51.2%
*-commutative51.2%
associate-*r*51.2%
Simplified51.2%
*-commutative51.2%
unpow251.2%
associate-*r*51.2%
*-commutative51.2%
Applied egg-rr51.2%
log1p-expm1-u100.0%
associate-*l*100.0%
Applied egg-rr100.0%
Final simplification89.6%
(FPCore (re im)
:precision binary64
(if (<= im 250.0)
(* (cos re) (+ 1.0 (* 0.5 (pow im 2.0))))
(if (<= im 2.2e+154)
(* 0.5 (+ (exp (- im)) (exp im)))
(* im (* (* 0.5 (cos re)) im)))))
double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = cos(re) * (1.0 + (0.5 * pow(im, 2.0)));
} else if (im <= 2.2e+154) {
tmp = 0.5 * (exp(-im) + exp(im));
} else {
tmp = im * ((0.5 * cos(re)) * im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 250.0d0) then
tmp = cos(re) * (1.0d0 + (0.5d0 * (im ** 2.0d0)))
else if (im <= 2.2d+154) then
tmp = 0.5d0 * (exp(-im) + exp(im))
else
tmp = im * ((0.5d0 * cos(re)) * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = Math.cos(re) * (1.0 + (0.5 * Math.pow(im, 2.0)));
} else if (im <= 2.2e+154) {
tmp = 0.5 * (Math.exp(-im) + Math.exp(im));
} else {
tmp = im * ((0.5 * Math.cos(re)) * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 250.0: tmp = math.cos(re) * (1.0 + (0.5 * math.pow(im, 2.0))) elif im <= 2.2e+154: tmp = 0.5 * (math.exp(-im) + math.exp(im)) else: tmp = im * ((0.5 * math.cos(re)) * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 250.0) tmp = Float64(cos(re) * Float64(1.0 + Float64(0.5 * (im ^ 2.0)))); elseif (im <= 2.2e+154) tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(im * Float64(Float64(0.5 * cos(re)) * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 250.0) tmp = cos(re) * (1.0 + (0.5 * (im ^ 2.0))); elseif (im <= 2.2e+154) tmp = 0.5 * (exp(-im) + exp(im)); else tmp = im * ((0.5 * cos(re)) * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 250.0], N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.2e+154], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 250:\\
\;\;\;\;\cos re \cdot \left(1 + 0.5 \cdot {im}^{2}\right)\\
\mathbf{elif}\;im \leq 2.2 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(0.5 \cdot \cos re\right) \cdot im\right)\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 86.3%
associate-*r*86.3%
distribute-rgt1-in86.3%
*-commutative86.3%
fma-define86.3%
Simplified86.3%
Taylor expanded in re around inf 86.3%
if 250 < im < 2.2000000000000001e154Initial program 100.0%
Taylor expanded in re around 0 81.3%
if 2.2000000000000001e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification87.3%
(FPCore (re im)
:precision binary64
(if (<= im 250.0)
(cos re)
(if (<= im 2.1e+154)
(* 0.5 (+ (exp (- im)) (exp im)))
(* im (* (* 0.5 (cos re)) im)))))
double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = cos(re);
} else if (im <= 2.1e+154) {
tmp = 0.5 * (exp(-im) + exp(im));
} else {
tmp = im * ((0.5 * cos(re)) * im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 250.0d0) then
tmp = cos(re)
else if (im <= 2.1d+154) then
tmp = 0.5d0 * (exp(-im) + exp(im))
else
tmp = im * ((0.5d0 * cos(re)) * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = Math.cos(re);
} else if (im <= 2.1e+154) {
tmp = 0.5 * (Math.exp(-im) + Math.exp(im));
} else {
tmp = im * ((0.5 * Math.cos(re)) * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 250.0: tmp = math.cos(re) elif im <= 2.1e+154: tmp = 0.5 * (math.exp(-im) + math.exp(im)) else: tmp = im * ((0.5 * math.cos(re)) * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 250.0) tmp = cos(re); elseif (im <= 2.1e+154) tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(im * Float64(Float64(0.5 * cos(re)) * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 250.0) tmp = cos(re); elseif (im <= 2.1e+154) tmp = 0.5 * (exp(-im) + exp(im)); else tmp = im * ((0.5 * cos(re)) * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 250.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.1e+154], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 250:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.1 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(0.5 \cdot \cos re\right) \cdot im\right)\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 67.1%
if 250 < im < 2.09999999999999994e154Initial program 100.0%
Taylor expanded in re around 0 81.3%
if 2.09999999999999994e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification72.8%
(FPCore (re im)
:precision binary64
(if (<= im 2.2e+14)
(cos re)
(if (<= im 2.8e+153)
(* im (+ (* 0.5 im) (* -0.25 (* im (pow re 2.0)))))
(* im (* (* 0.5 (cos re)) im)))))
double code(double re, double im) {
double tmp;
if (im <= 2.2e+14) {
tmp = cos(re);
} else if (im <= 2.8e+153) {
tmp = im * ((0.5 * im) + (-0.25 * (im * pow(re, 2.0))));
} else {
tmp = im * ((0.5 * cos(re)) * im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.2d+14) then
tmp = cos(re)
else if (im <= 2.8d+153) then
tmp = im * ((0.5d0 * im) + ((-0.25d0) * (im * (re ** 2.0d0))))
else
tmp = im * ((0.5d0 * cos(re)) * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.2e+14) {
tmp = Math.cos(re);
} else if (im <= 2.8e+153) {
tmp = im * ((0.5 * im) + (-0.25 * (im * Math.pow(re, 2.0))));
} else {
tmp = im * ((0.5 * Math.cos(re)) * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.2e+14: tmp = math.cos(re) elif im <= 2.8e+153: tmp = im * ((0.5 * im) + (-0.25 * (im * math.pow(re, 2.0)))) else: tmp = im * ((0.5 * math.cos(re)) * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.2e+14) tmp = cos(re); elseif (im <= 2.8e+153) tmp = Float64(im * Float64(Float64(0.5 * im) + Float64(-0.25 * Float64(im * (re ^ 2.0))))); else tmp = Float64(im * Float64(Float64(0.5 * cos(re)) * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.2e+14) tmp = cos(re); elseif (im <= 2.8e+153) tmp = im * ((0.5 * im) + (-0.25 * (im * (re ^ 2.0)))); else tmp = im * ((0.5 * cos(re)) * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.2e+14], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.8e+153], N[(im * N[(N[(0.5 * im), $MachinePrecision] + N[(-0.25 * N[(im * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.2 \cdot 10^{+14}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.8 \cdot 10^{+153}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im + -0.25 \cdot \left(im \cdot {re}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(0.5 \cdot \cos re\right) \cdot im\right)\\
\end{array}
\end{array}
if im < 2.2e14Initial program 100.0%
Taylor expanded in im around 0 66.5%
if 2.2e14 < im < 2.79999999999999985e153Initial program 100.0%
Taylor expanded in im around 0 5.2%
associate-*r*5.2%
distribute-rgt1-in5.2%
*-commutative5.2%
fma-define5.2%
Simplified5.2%
Taylor expanded in im around inf 5.2%
associate-*r*5.2%
*-commutative5.2%
associate-*r*5.2%
Simplified5.2%
*-commutative5.2%
unpow25.2%
associate-*r*5.2%
*-commutative5.2%
Applied egg-rr5.2%
Taylor expanded in re around 0 21.0%
if 2.79999999999999985e153 < im Initial program 100.0%
Taylor expanded in im around 0 97.2%
associate-*r*97.2%
distribute-rgt1-in97.2%
*-commutative97.2%
fma-define97.2%
Simplified97.2%
Taylor expanded in im around inf 97.2%
associate-*r*97.2%
*-commutative97.2%
associate-*r*97.2%
Simplified97.2%
*-commutative97.2%
unpow297.2%
associate-*r*97.2%
*-commutative97.2%
Applied egg-rr97.2%
Final simplification65.1%
(FPCore (re im) :precision binary64 (if (<= im 1.4) (cos re) (* im (* (* 0.5 (cos re)) im))))
double code(double re, double im) {
double tmp;
if (im <= 1.4) {
tmp = cos(re);
} else {
tmp = im * ((0.5 * cos(re)) * im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.4d0) then
tmp = cos(re)
else
tmp = im * ((0.5d0 * cos(re)) * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.4) {
tmp = Math.cos(re);
} else {
tmp = im * ((0.5 * Math.cos(re)) * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.4: tmp = math.cos(re) else: tmp = im * ((0.5 * math.cos(re)) * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.4) tmp = cos(re); else tmp = Float64(im * Float64(Float64(0.5 * cos(re)) * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.4) tmp = cos(re); else tmp = im * ((0.5 * cos(re)) * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.4], N[Cos[re], $MachinePrecision], N[(im * N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.4:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(0.5 \cdot \cos re\right) \cdot im\right)\\
\end{array}
\end{array}
if im < 1.3999999999999999Initial program 100.0%
Taylor expanded in im around 0 67.5%
if 1.3999999999999999 < im Initial program 100.0%
Taylor expanded in im around 0 50.4%
associate-*r*50.4%
distribute-rgt1-in50.4%
*-commutative50.4%
fma-define50.4%
Simplified50.4%
Taylor expanded in im around inf 50.4%
associate-*r*50.4%
*-commutative50.4%
associate-*r*50.4%
Simplified50.4%
*-commutative50.4%
unpow250.4%
associate-*r*50.4%
*-commutative50.4%
Applied egg-rr50.4%
Final simplification63.3%
(FPCore (re im) :precision binary64 (if (<= im 2.2e+38) (cos re) (* im (* 0.5 im))))
double code(double re, double im) {
double tmp;
if (im <= 2.2e+38) {
tmp = cos(re);
} else {
tmp = im * (0.5 * im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.2d+38) then
tmp = cos(re)
else
tmp = im * (0.5d0 * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.2e+38) {
tmp = Math.cos(re);
} else {
tmp = im * (0.5 * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.2e+38: tmp = math.cos(re) else: tmp = im * (0.5 * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.2e+38) tmp = cos(re); else tmp = Float64(im * Float64(0.5 * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.2e+38) tmp = cos(re); else tmp = im * (0.5 * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.2e+38], N[Cos[re], $MachinePrecision], N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.2 \cdot 10^{+38}:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\end{array}
\end{array}
if im < 2.20000000000000006e38Initial program 100.0%
Taylor expanded in im around 0 64.3%
if 2.20000000000000006e38 < im Initial program 100.0%
Taylor expanded in im around 0 59.3%
associate-*r*59.3%
distribute-rgt1-in59.3%
*-commutative59.3%
fma-define59.3%
Simplified59.3%
Taylor expanded in im around inf 59.3%
associate-*r*59.3%
*-commutative59.3%
associate-*r*59.3%
Simplified59.3%
*-commutative59.3%
unpow259.3%
associate-*r*59.3%
*-commutative59.3%
Applied egg-rr59.3%
Taylor expanded in re around 0 41.9%
Final simplification59.7%
(FPCore (re im) :precision binary64 (* im (* 0.5 im)))
double code(double re, double im) {
return im * (0.5 * im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (0.5d0 * im)
end function
public static double code(double re, double im) {
return im * (0.5 * im);
}
def code(re, im): return im * (0.5 * im)
function code(re, im) return Float64(im * Float64(0.5 * im)) end
function tmp = code(re, im) tmp = im * (0.5 * im); end
code[re_, im_] := N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(0.5 \cdot im\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 77.8%
associate-*r*77.8%
distribute-rgt1-in77.8%
*-commutative77.8%
fma-define77.8%
Simplified77.8%
Taylor expanded in im around inf 29.5%
associate-*r*29.5%
*-commutative29.5%
associate-*r*29.5%
Simplified29.5%
*-commutative29.5%
unpow229.5%
associate-*r*29.5%
*-commutative29.5%
Applied egg-rr29.5%
Taylor expanded in re around 0 20.5%
Final simplification20.5%
herbie shell --seed 2024096
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))