
(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 9 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%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (or (<= im 11.2) (not (<= im 1.15e+77)))
(*
(* 0.5 (cos re))
(+ (+ 2.0 (* im im)) (* 0.08333333333333333 (pow im 4.0))))
(* 0.5 (* (exp im) 2.0))))
double code(double re, double im) {
double tmp;
if ((im <= 11.2) || !(im <= 1.15e+77)) {
tmp = (0.5 * cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * pow(im, 4.0)));
} else {
tmp = 0.5 * (exp(im) * 2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 11.2d0) .or. (.not. (im <= 1.15d+77))) then
tmp = (0.5d0 * cos(re)) * ((2.0d0 + (im * im)) + (0.08333333333333333d0 * (im ** 4.0d0)))
else
tmp = 0.5d0 * (exp(im) * 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 11.2) || !(im <= 1.15e+77)) {
tmp = (0.5 * Math.cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * Math.pow(im, 4.0)));
} else {
tmp = 0.5 * (Math.exp(im) * 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 11.2) or not (im <= 1.15e+77): tmp = (0.5 * math.cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * math.pow(im, 4.0))) else: tmp = 0.5 * (math.exp(im) * 2.0) return tmp
function code(re, im) tmp = 0.0 if ((im <= 11.2) || !(im <= 1.15e+77)) tmp = Float64(Float64(0.5 * cos(re)) * Float64(Float64(2.0 + Float64(im * im)) + Float64(0.08333333333333333 * (im ^ 4.0)))); else tmp = Float64(0.5 * Float64(exp(im) * 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 11.2) || ~((im <= 1.15e+77))) tmp = (0.5 * cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * (im ^ 4.0))); else tmp = 0.5 * (exp(im) * 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 11.2], N[Not[LessEqual[im, 1.15e+77]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] + N[(0.08333333333333333 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[im], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 11.2 \lor \neg \left(im \leq 1.15 \cdot 10^{+77}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(\left(2 + im \cdot im\right) + 0.08333333333333333 \cdot {im}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{im} \cdot 2\right)\\
\end{array}
\end{array}
if im < 11.199999999999999 or 1.14999999999999997e77 < im Initial program 100.0%
Taylor expanded in im around 0 92.1%
associate-+r+92.1%
unpow292.1%
Simplified92.1%
if 11.199999999999999 < im < 1.14999999999999997e77Initial program 100.0%
Taylor expanded in re around 0 88.9%
*-commutative88.9%
Simplified88.9%
*-un-lft-identity88.9%
fma-def88.9%
add-sqr-sqrt0.0%
sqrt-unprod88.9%
sqr-neg88.9%
sqrt-prod88.9%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
fma-udef88.9%
distribute-lft1-in88.9%
metadata-eval88.9%
Simplified88.9%
Final simplification91.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= im 6.0)
(+ (cos re) (* t_0 (* im im)))
(if (<= im 1.35e+154)
(* 0.5 (* (exp im) 2.0))
(* t_0 (+ 2.0 (* im im)))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double tmp;
if (im <= 6.0) {
tmp = cos(re) + (t_0 * (im * im));
} else if (im <= 1.35e+154) {
tmp = 0.5 * (exp(im) * 2.0);
} else {
tmp = t_0 * (2.0 + (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * cos(re)
if (im <= 6.0d0) then
tmp = cos(re) + (t_0 * (im * im))
else if (im <= 1.35d+154) then
tmp = 0.5d0 * (exp(im) * 2.0d0)
else
tmp = t_0 * (2.0d0 + (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double tmp;
if (im <= 6.0) {
tmp = Math.cos(re) + (t_0 * (im * im));
} else if (im <= 1.35e+154) {
tmp = 0.5 * (Math.exp(im) * 2.0);
} else {
tmp = t_0 * (2.0 + (im * im));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) tmp = 0 if im <= 6.0: tmp = math.cos(re) + (t_0 * (im * im)) elif im <= 1.35e+154: tmp = 0.5 * (math.exp(im) * 2.0) else: tmp = t_0 * (2.0 + (im * im)) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) tmp = 0.0 if (im <= 6.0) tmp = Float64(cos(re) + Float64(t_0 * Float64(im * im))); elseif (im <= 1.35e+154) tmp = Float64(0.5 * Float64(exp(im) * 2.0)); else tmp = Float64(t_0 * Float64(2.0 + Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); tmp = 0.0; if (im <= 6.0) tmp = cos(re) + (t_0 * (im * im)); elseif (im <= 1.35e+154) tmp = 0.5 * (exp(im) * 2.0); else tmp = t_0 * (2.0 + (im * im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 6.0], N[(N[Cos[re], $MachinePrecision] + N[(t$95$0 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(0.5 * N[(N[Exp[im], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathbf{if}\;im \leq 6:\\
\;\;\;\;\cos re + t_0 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(e^{im} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(2 + im \cdot im\right)\\
\end{array}
\end{array}
if im < 6Initial program 100.0%
Taylor expanded in im around 0 81.1%
associate-*r*81.1%
*-commutative81.1%
fma-def81.1%
unpow281.1%
Simplified81.1%
fma-udef81.1%
*-commutative81.1%
Applied egg-rr81.1%
if 6 < im < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in re around 0 79.5%
*-commutative79.5%
Simplified79.5%
*-un-lft-identity79.5%
fma-def79.5%
add-sqr-sqrt0.0%
sqrt-unprod79.5%
sqr-neg79.5%
sqrt-prod79.5%
add-sqr-sqrt79.5%
Applied egg-rr79.5%
fma-udef79.5%
distribute-lft1-in79.5%
metadata-eval79.5%
Simplified79.5%
if 1.35000000000000003e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification83.9%
(FPCore (re im) :precision binary64 (if (or (<= im 7.2) (not (<= im 1.35e+154))) (* (* 0.5 (cos re)) (+ 2.0 (* im im))) (* 0.5 (* (exp im) 2.0))))
double code(double re, double im) {
double tmp;
if ((im <= 7.2) || !(im <= 1.35e+154)) {
tmp = (0.5 * cos(re)) * (2.0 + (im * im));
} else {
tmp = 0.5 * (exp(im) * 2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 7.2d0) .or. (.not. (im <= 1.35d+154))) then
tmp = (0.5d0 * cos(re)) * (2.0d0 + (im * im))
else
tmp = 0.5d0 * (exp(im) * 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 7.2) || !(im <= 1.35e+154)) {
tmp = (0.5 * Math.cos(re)) * (2.0 + (im * im));
} else {
tmp = 0.5 * (Math.exp(im) * 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 7.2) or not (im <= 1.35e+154): tmp = (0.5 * math.cos(re)) * (2.0 + (im * im)) else: tmp = 0.5 * (math.exp(im) * 2.0) return tmp
function code(re, im) tmp = 0.0 if ((im <= 7.2) || !(im <= 1.35e+154)) tmp = Float64(Float64(0.5 * cos(re)) * Float64(2.0 + Float64(im * im))); else tmp = Float64(0.5 * Float64(exp(im) * 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 7.2) || ~((im <= 1.35e+154))) tmp = (0.5 * cos(re)) * (2.0 + (im * im)); else tmp = 0.5 * (exp(im) * 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 7.2], N[Not[LessEqual[im, 1.35e+154]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[im], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 7.2 \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{im} \cdot 2\right)\\
\end{array}
\end{array}
if im < 7.20000000000000018 or 1.35000000000000003e154 < im Initial program 100.0%
Taylor expanded in im around 0 84.7%
unpow284.7%
Simplified84.7%
if 7.20000000000000018 < im < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in re around 0 79.5%
*-commutative79.5%
Simplified79.5%
*-un-lft-identity79.5%
fma-def79.5%
add-sqr-sqrt0.0%
sqrt-unprod79.5%
sqr-neg79.5%
sqrt-prod79.5%
add-sqr-sqrt79.5%
Applied egg-rr79.5%
fma-udef79.5%
distribute-lft1-in79.5%
metadata-eval79.5%
Simplified79.5%
Final simplification83.9%
(FPCore (re im) :precision binary64 (if (<= im 3.7) (+ (cos re) (* im (* 0.5 im))) (* 0.5 (* (exp im) 2.0))))
double code(double re, double im) {
double tmp;
if (im <= 3.7) {
tmp = cos(re) + (im * (0.5 * im));
} else {
tmp = 0.5 * (exp(im) * 2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3.7d0) then
tmp = cos(re) + (im * (0.5d0 * im))
else
tmp = 0.5d0 * (exp(im) * 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.7) {
tmp = Math.cos(re) + (im * (0.5 * im));
} else {
tmp = 0.5 * (Math.exp(im) * 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.7: tmp = math.cos(re) + (im * (0.5 * im)) else: tmp = 0.5 * (math.exp(im) * 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.7) tmp = Float64(cos(re) + Float64(im * Float64(0.5 * im))); else tmp = Float64(0.5 * Float64(exp(im) * 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.7) tmp = cos(re) + (im * (0.5 * im)); else tmp = 0.5 * (exp(im) * 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.7], N[(N[Cos[re], $MachinePrecision] + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[im], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.7:\\
\;\;\;\;\cos re + im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{im} \cdot 2\right)\\
\end{array}
\end{array}
if im < 3.7000000000000002Initial program 100.0%
Taylor expanded in im around 0 81.1%
associate-*r*81.1%
*-commutative81.1%
fma-def81.1%
unpow281.1%
Simplified81.1%
fma-udef81.1%
*-commutative81.1%
Applied egg-rr81.1%
Taylor expanded in re around 0 77.9%
unpow277.9%
associate-*r*77.9%
Simplified77.9%
if 3.7000000000000002 < im Initial program 100.0%
Taylor expanded in re around 0 76.3%
*-commutative76.3%
Simplified76.3%
*-un-lft-identity76.3%
fma-def76.3%
add-sqr-sqrt0.0%
sqrt-unprod76.3%
sqr-neg76.3%
sqrt-prod76.3%
add-sqr-sqrt76.3%
Applied egg-rr76.3%
fma-udef76.3%
distribute-lft1-in76.3%
metadata-eval76.3%
Simplified76.3%
Final simplification77.4%
(FPCore (re im) :precision binary64 (if (<= im 3.6) (cos re) (* 0.5 (* (exp im) 2.0))))
double code(double re, double im) {
double tmp;
if (im <= 3.6) {
tmp = cos(re);
} else {
tmp = 0.5 * (exp(im) * 2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3.6d0) then
tmp = cos(re)
else
tmp = 0.5d0 * (exp(im) * 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.6) {
tmp = Math.cos(re);
} else {
tmp = 0.5 * (Math.exp(im) * 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.6: tmp = math.cos(re) else: tmp = 0.5 * (math.exp(im) * 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.6) tmp = cos(re); else tmp = Float64(0.5 * Float64(exp(im) * 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.6) tmp = cos(re); else tmp = 0.5 * (exp(im) * 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.6], N[Cos[re], $MachinePrecision], N[(0.5 * N[(N[Exp[im], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.6:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{im} \cdot 2\right)\\
\end{array}
\end{array}
if im < 3.60000000000000009Initial program 100.0%
Taylor expanded in im around 0 62.2%
if 3.60000000000000009 < im Initial program 100.0%
Taylor expanded in re around 0 76.3%
*-commutative76.3%
Simplified76.3%
*-un-lft-identity76.3%
fma-def76.3%
add-sqr-sqrt0.0%
sqrt-unprod76.3%
sqr-neg76.3%
sqrt-prod76.3%
add-sqr-sqrt76.3%
Applied egg-rr76.3%
fma-udef76.3%
distribute-lft1-in76.3%
metadata-eval76.3%
Simplified76.3%
Final simplification66.6%
(FPCore (re im) :precision binary64 (if (<= im 4.1e+39) (cos re) (+ (* im (* 0.5 im)) 1.0)))
double code(double re, double im) {
double tmp;
if (im <= 4.1e+39) {
tmp = cos(re);
} else {
tmp = (im * (0.5 * im)) + 1.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 4.1d+39) then
tmp = cos(re)
else
tmp = (im * (0.5d0 * im)) + 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 4.1e+39) {
tmp = Math.cos(re);
} else {
tmp = (im * (0.5 * im)) + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 4.1e+39: tmp = math.cos(re) else: tmp = (im * (0.5 * im)) + 1.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 4.1e+39) tmp = cos(re); else tmp = Float64(Float64(im * Float64(0.5 * im)) + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 4.1e+39) tmp = cos(re); else tmp = (im * (0.5 * im)) + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 4.1e+39], N[Cos[re], $MachinePrecision], N[(N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.1 \cdot 10^{+39}:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right) + 1\\
\end{array}
\end{array}
if im < 4.10000000000000004e39Initial program 100.0%
Taylor expanded in im around 0 58.7%
if 4.10000000000000004e39 < im Initial program 100.0%
Taylor expanded in im around 0 61.9%
associate-*r*61.9%
*-commutative61.9%
fma-def61.9%
unpow261.9%
Simplified61.9%
fma-udef61.9%
*-commutative61.9%
Applied egg-rr61.9%
Taylor expanded in re around 0 45.3%
+-commutative45.3%
unpow245.3%
associate-*r*45.3%
Simplified45.3%
Final simplification55.1%
(FPCore (re im) :precision binary64 (+ (* im (* 0.5 im)) 1.0))
double code(double re, double im) {
return (im * (0.5 * im)) + 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (im * (0.5d0 * im)) + 1.0d0
end function
public static double code(double re, double im) {
return (im * (0.5 * im)) + 1.0;
}
def code(re, im): return (im * (0.5 * im)) + 1.0
function code(re, im) return Float64(Float64(im * Float64(0.5 * im)) + 1.0) end
function tmp = code(re, im) tmp = (im * (0.5 * im)) + 1.0; end
code[re_, im_] := N[(N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(0.5 \cdot im\right) + 1
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 72.6%
associate-*r*72.6%
*-commutative72.6%
fma-def72.6%
unpow272.6%
Simplified72.6%
fma-udef72.6%
*-commutative72.6%
Applied egg-rr72.6%
Taylor expanded in re around 0 46.1%
+-commutative46.1%
unpow246.1%
associate-*r*46.1%
Simplified46.1%
Final simplification46.1%
(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%
Applied egg-rr23.7%
+-inverses23.7%
+-rgt-identity23.7%
*-inverses23.7%
Simplified23.7%
Final simplification23.7%
herbie shell --seed 2023229
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))