
(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 17 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 (* (cos re) (+ (* 0.5 (exp im)) (* 0.5 (/ 1.0 (exp im))))))
double code(double re, double im) {
return cos(re) * ((0.5 * exp(im)) + (0.5 * (1.0 / exp(im))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re) * ((0.5d0 * exp(im)) + (0.5d0 * (1.0d0 / exp(im))))
end function
public static double code(double re, double im) {
return Math.cos(re) * ((0.5 * Math.exp(im)) + (0.5 * (1.0 / Math.exp(im))));
}
def code(re, im): return math.cos(re) * ((0.5 * math.exp(im)) + (0.5 * (1.0 / math.exp(im))))
function code(re, im) return Float64(cos(re) * Float64(Float64(0.5 * exp(im)) + Float64(0.5 * Float64(1.0 / exp(im))))) end
function tmp = code(re, im) tmp = cos(re) * ((0.5 * exp(im)) + (0.5 * (1.0 / exp(im)))); end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (* (* (cos re) 0.5) (+ (exp im) (exp (- im)))))
double code(double re, double im) {
return (cos(re) * 0.5) * (exp(im) + exp(-im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (cos(re) * 0.5d0) * (exp(im) + exp(-im))
end function
public static double code(double re, double im) {
return (Math.cos(re) * 0.5) * (Math.exp(im) + Math.exp(-im));
}
def code(re, im): return (math.cos(re) * 0.5) * (math.exp(im) + math.exp(-im))
function code(re, im) return Float64(Float64(cos(re) * 0.5) * Float64(exp(im) + exp(Float64(-im)))) end
function tmp = code(re, im) tmp = (cos(re) * 0.5) * (exp(im) + exp(-im)); end
code[re_, im_] := N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\cos re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (<= im 1.55e-5)
(cos re)
(if (<= im 1.4e+102)
(* 0.5 (+ (exp im) (exp (- im))))
(*
(/ 1.0 (cos re))
(+ 1.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.55e-5) {
tmp = cos(re);
} else if (im <= 1.4e+102) {
tmp = 0.5 * (exp(im) + exp(-im));
} else {
tmp = (1.0 / cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.55d-5) then
tmp = cos(re)
else if (im <= 1.4d+102) then
tmp = 0.5d0 * (exp(im) + exp(-im))
else
tmp = (1.0d0 / cos(re)) * (1.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.55e-5) {
tmp = Math.cos(re);
} else if (im <= 1.4e+102) {
tmp = 0.5 * (Math.exp(im) + Math.exp(-im));
} else {
tmp = (1.0 / Math.cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.55e-5: tmp = math.cos(re) elif im <= 1.4e+102: tmp = 0.5 * (math.exp(im) + math.exp(-im)) else: tmp = (1.0 / math.cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.55e-5) tmp = cos(re); elseif (im <= 1.4e+102) tmp = Float64(0.5 * Float64(exp(im) + exp(Float64(-im)))); else tmp = Float64(Float64(1.0 / cos(re)) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.55e-5) tmp = cos(re); elseif (im <= 1.4e+102) tmp = 0.5 * (exp(im) + exp(-im)); else tmp = (1.0 / cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.55e-5], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.4e+102], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.55 \cdot 10^{-5}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\cos re} \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.55000000000000007e-5Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 66.0%
if 1.55000000000000007e-5 < im < 1.40000000000000009e102Initial program 99.9%
Taylor expanded in re around 0 82.0%
if 1.40000000000000009e102 < im Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Applied egg-rr100.0%
unpow-15.6%
Simplified100.0%
Final simplification73.5%
(FPCore (re im) :precision binary64 (* (cos re) (+ 0.5 (* 0.5 (exp im)))))
double code(double re, double im) {
return cos(re) * (0.5 + (0.5 * exp(im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re) * (0.5d0 + (0.5d0 * exp(im)))
end function
public static double code(double re, double im) {
return Math.cos(re) * (0.5 + (0.5 * Math.exp(im)));
}
def code(re, im): return math.cos(re) * (0.5 + (0.5 * math.exp(im)))
function code(re, im) return Float64(cos(re) * Float64(0.5 + Float64(0.5 * exp(im)))) end
function tmp = code(re, im) tmp = cos(re) * (0.5 + (0.5 * exp(im))); end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 73.9%
Taylor expanded in re around inf 73.9%
Final simplification73.9%
(FPCore (re im)
:precision binary64
(if (<= im 1.5e-5)
(cos re)
(if (<= im 1.4e+102)
(+
(* 0.5 (exp im))
(*
0.5
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(*
(/ 1.0 (cos re))
(+ 1.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.5e-5) {
tmp = cos(re);
} else if (im <= 1.4e+102) {
tmp = (0.5 * exp(im)) + (0.5 * (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = (1.0 / cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.5d-5) then
tmp = cos(re)
else if (im <= 1.4d+102) then
tmp = (0.5d0 * exp(im)) + (0.5d0 * (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = (1.0d0 / cos(re)) * (1.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.5e-5) {
tmp = Math.cos(re);
} else if (im <= 1.4e+102) {
tmp = (0.5 * Math.exp(im)) + (0.5 * (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = (1.0 / Math.cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.5e-5: tmp = math.cos(re) elif im <= 1.4e+102: tmp = (0.5 * math.exp(im)) + (0.5 * (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = (1.0 / math.cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.5e-5) tmp = cos(re); elseif (im <= 1.4e+102) tmp = Float64(Float64(0.5 * exp(im)) + Float64(0.5 * Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(Float64(1.0 / cos(re)) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.5e-5) tmp = cos(re); elseif (im <= 1.4e+102) tmp = (0.5 * exp(im)) + (0.5 * (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = (1.0 / cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.5e-5], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.4e+102], N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.5 \cdot 10^{-5}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot e^{im} + 0.5 \cdot \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\cos re} \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.50000000000000004e-5Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 66.0%
if 1.50000000000000004e-5 < im < 1.40000000000000009e102Initial program 99.9%
cos-neg99.9%
*-commutative99.9%
associate-*l*99.9%
+-commutative99.9%
distribute-rgt-in99.9%
cancel-sign-sub99.9%
distribute-lft-neg-in99.9%
cos-neg99.9%
*-commutative99.9%
fma-neg99.9%
remove-double-neg99.9%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 82.1%
Taylor expanded in im around 0 79.0%
if 1.40000000000000009e102 < im Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Applied egg-rr100.0%
unpow-15.6%
Simplified100.0%
Final simplification73.1%
(FPCore (re im)
:precision binary64
(if (<= im 1.2)
(cos re)
(if (<= im 1.4e+102)
(+ 0.5 (* 0.5 (exp im)))
(*
(/ 1.0 (cos re))
(+ 1.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = cos(re);
} else if (im <= 1.4e+102) {
tmp = 0.5 + (0.5 * exp(im));
} else {
tmp = (1.0 / cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.2d0) then
tmp = cos(re)
else if (im <= 1.4d+102) then
tmp = 0.5d0 + (0.5d0 * exp(im))
else
tmp = (1.0d0 / cos(re)) * (1.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = Math.cos(re);
} else if (im <= 1.4e+102) {
tmp = 0.5 + (0.5 * Math.exp(im));
} else {
tmp = (1.0 / Math.cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.2: tmp = math.cos(re) elif im <= 1.4e+102: tmp = 0.5 + (0.5 * math.exp(im)) else: tmp = (1.0 / math.cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.2) tmp = cos(re); elseif (im <= 1.4e+102) tmp = Float64(0.5 + Float64(0.5 * exp(im))); else tmp = Float64(Float64(1.0 / cos(re)) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.2) tmp = cos(re); elseif (im <= 1.4e+102) tmp = 0.5 + (0.5 * exp(im)); else tmp = (1.0 / cos(re)) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.2], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.4e+102], N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.2:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{+102}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\cos re} \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.19999999999999996Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 65.7%
if 1.19999999999999996 < im < 1.40000000000000009e102Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 80.0%
if 1.40000000000000009e102 < im Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Applied egg-rr100.0%
unpow-15.6%
Simplified100.0%
Final simplification72.8%
(FPCore (re im)
:precision binary64
(if (<= im 1.2)
(cos re)
(if (<= im 1.4e+102)
(+ 0.5 (* 0.5 (exp im)))
(*
(cos re)
(+ 1.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = cos(re);
} else if (im <= 1.4e+102) {
tmp = 0.5 + (0.5 * exp(im));
} else {
tmp = cos(re) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.2d0) then
tmp = cos(re)
else if (im <= 1.4d+102) then
tmp = 0.5d0 + (0.5d0 * exp(im))
else
tmp = cos(re) * (1.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = Math.cos(re);
} else if (im <= 1.4e+102) {
tmp = 0.5 + (0.5 * Math.exp(im));
} else {
tmp = Math.cos(re) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.2: tmp = math.cos(re) elif im <= 1.4e+102: tmp = 0.5 + (0.5 * math.exp(im)) else: tmp = math.cos(re) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.2) tmp = cos(re); elseif (im <= 1.4e+102) tmp = Float64(0.5 + Float64(0.5 * exp(im))); else tmp = Float64(cos(re) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.2) tmp = cos(re); elseif (im <= 1.4e+102) tmp = 0.5 + (0.5 * exp(im)); else tmp = cos(re) * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.2], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.4e+102], N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.2:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{+102}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.19999999999999996Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 65.7%
if 1.19999999999999996 < im < 1.40000000000000009e102Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 80.0%
if 1.40000000000000009e102 < im Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification72.8%
(FPCore (re im)
:precision binary64
(if (<= im 1.2)
(cos re)
(if (<= im 1.2e+154)
(+ 0.5 (* 0.5 (exp im)))
(* (cos re) (+ 1.0 (* im (+ 0.5 (* im 0.25))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = cos(re);
} else if (im <= 1.2e+154) {
tmp = 0.5 + (0.5 * exp(im));
} else {
tmp = cos(re) * (1.0 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.2d0) then
tmp = cos(re)
else if (im <= 1.2d+154) then
tmp = 0.5d0 + (0.5d0 * exp(im))
else
tmp = cos(re) * (1.0d0 + (im * (0.5d0 + (im * 0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = Math.cos(re);
} else if (im <= 1.2e+154) {
tmp = 0.5 + (0.5 * Math.exp(im));
} else {
tmp = Math.cos(re) * (1.0 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.2: tmp = math.cos(re) elif im <= 1.2e+154: tmp = 0.5 + (0.5 * math.exp(im)) else: tmp = math.cos(re) * (1.0 + (im * (0.5 + (im * 0.25)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.2) tmp = cos(re); elseif (im <= 1.2e+154) tmp = Float64(0.5 + Float64(0.5 * exp(im))); else tmp = Float64(cos(re) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.25))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.2) tmp = cos(re); elseif (im <= 1.2e+154) tmp = 0.5 + (0.5 * exp(im)); else tmp = cos(re) * (1.0 + (im * (0.5 + (im * 0.25)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.2], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.2e+154], N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.2:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+154}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 1.19999999999999996Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 65.7%
if 1.19999999999999996 < im < 1.20000000000000007e154Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 76.9%
if 1.20000000000000007e154 < im Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification71.3%
(FPCore (re im) :precision binary64 (if (<= im 1.2) (cos re) (+ 0.5 (* 0.5 (exp im)))))
double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = cos(re);
} else {
tmp = 0.5 + (0.5 * exp(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.2d0) then
tmp = cos(re)
else
tmp = 0.5d0 + (0.5d0 * exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = Math.cos(re);
} else {
tmp = 0.5 + (0.5 * Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.2: tmp = math.cos(re) else: tmp = 0.5 + (0.5 * math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.2) tmp = cos(re); else tmp = Float64(0.5 + Float64(0.5 * exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.2) tmp = cos(re); else tmp = 0.5 + (0.5 * exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.2], N[Cos[re], $MachinePrecision], N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.2:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\
\end{array}
\end{array}
if im < 1.19999999999999996Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 65.7%
if 1.19999999999999996 < im Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 75.0%
Final simplification68.2%
(FPCore (re im) :precision binary64 (if (<= im 1.2) (cos re) (+ 1.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = cos(re);
} else {
tmp = 1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.2d0) then
tmp = cos(re)
else
tmp = 1.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = Math.cos(re);
} else {
tmp = 1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.2: tmp = math.cos(re) else: tmp = 1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.2) tmp = cos(re); else tmp = Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333)))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.2) tmp = cos(re); else tmp = 1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.2], N[Cos[re], $MachinePrecision], N[(1.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.2:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\\
\end{array}
\end{array}
if im < 1.19999999999999996Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 65.7%
if 1.19999999999999996 < im Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 65.3%
*-commutative65.3%
Simplified65.3%
Taylor expanded in re around 0 47.1%
Final simplification60.8%
(FPCore (re im) :precision binary64 (+ 1.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333)))))))
double code(double re, double im) {
return 1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0)))))
end function
public static double code(double re, double im) {
return 1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
def code(re, im): return 1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))
function code(re, im) return Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333)))))) end
function tmp = code(re, im) tmp = 1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))); end
code[re_, im_] := N[(1.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 73.9%
Taylor expanded in im around 0 64.0%
*-commutative64.0%
Simplified64.0%
Taylor expanded in re around 0 44.9%
Final simplification44.9%
(FPCore (re im) :precision binary64 (+ 1.0 (* 0.5 im)))
double code(double re, double im) {
return 1.0 + (0.5 * im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + (0.5d0 * im)
end function
public static double code(double re, double im) {
return 1.0 + (0.5 * im);
}
def code(re, im): return 1.0 + (0.5 * im)
function code(re, im) return Float64(1.0 + Float64(0.5 * im)) end
function tmp = code(re, im) tmp = 1.0 + (0.5 * im); end
code[re_, im_] := N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 0.5 \cdot im
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 73.9%
Taylor expanded in im around 0 47.9%
Applied egg-rr30.7%
unpow-130.7%
Simplified30.7%
Taylor expanded in re around 0 28.7%
Final simplification28.7%
(FPCore (re im) :precision binary64 -2.0)
double code(double re, double im) {
return -2.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -2.0d0
end function
public static double code(double re, double im) {
return -2.0;
}
def code(re, im): return -2.0
function code(re, im) return -2.0 end
function tmp = code(re, im) tmp = -2.0; end
code[re_, im_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 66.6%
Applied egg-rr3.4%
Final simplification3.4%
(FPCore (re im) :precision binary64 -1.0)
double code(double re, double im) {
return -1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -1.0d0
end function
public static double code(double re, double im) {
return -1.0;
}
def code(re, im): return -1.0
function code(re, im) return -1.0 end
function tmp = code(re, im) tmp = -1.0; end
code[re_, im_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 66.6%
Applied egg-rr3.9%
Final simplification3.9%
(FPCore (re im) :precision binary64 0.25)
double code(double re, double im) {
return 0.25;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.25d0
end function
public static double code(double re, double im) {
return 0.25;
}
def code(re, im): return 0.25
function code(re, im) return 0.25 end
function tmp = code(re, im) tmp = 0.25; end
code[re_, im_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 66.6%
Applied egg-rr7.9%
Final simplification7.9%
(FPCore (re im) :precision binary64 0.5)
double code(double re, double im) {
return 0.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0
end function
public static double code(double re, double im) {
return 0.5;
}
def code(re, im): return 0.5
function code(re, im) return 0.5 end
function tmp = code(re, im) tmp = 0.5; end
code[re_, im_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 66.6%
Applied egg-rr8.4%
Final simplification8.4%
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
return 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0
end function
public static double code(double re, double im) {
return 1.0;
}
def code(re, im): return 1.0
function code(re, im) return 1.0 end
function tmp = code(re, im) tmp = 1.0; end
code[re_, im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
cos-neg100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
cos-neg100.0%
*-commutative100.0%
fma-neg100.0%
remove-double-neg100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 66.6%
Taylor expanded in im around 0 28.9%
Final simplification28.9%
herbie shell --seed 2024050
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))