
(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 15 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
(let* ((t_0 (* 0.5 (cos re))) (t_1 (* 0.08333333333333333 (pow im 4.0))))
(if (<= im 0.68)
(* t_0 (+ (+ 2.0 (* im im)) t_1))
(if (<= im 2e+73)
(* (+ (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re))))
(* t_0 (+ 2.0 (+ (* im im) (+ t_1 0.00023919753086419754))))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = 0.08333333333333333 * pow(im, 4.0);
double tmp;
if (im <= 0.68) {
tmp = t_0 * ((2.0 + (im * im)) + t_1);
} else if (im <= 2e+73) {
tmp = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * re)));
} else {
tmp = t_0 * (2.0 + ((im * im) + (t_1 + 0.00023919753086419754)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * cos(re)
t_1 = 0.08333333333333333d0 * (im ** 4.0d0)
if (im <= 0.68d0) then
tmp = t_0 * ((2.0d0 + (im * im)) + t_1)
else if (im <= 2d+73) then
tmp = (exp(-im) + exp(im)) * (0.5d0 + ((-0.25d0) * (re * re)))
else
tmp = t_0 * (2.0d0 + ((im * im) + (t_1 + 0.00023919753086419754d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double t_1 = 0.08333333333333333 * Math.pow(im, 4.0);
double tmp;
if (im <= 0.68) {
tmp = t_0 * ((2.0 + (im * im)) + t_1);
} else if (im <= 2e+73) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
} else {
tmp = t_0 * (2.0 + ((im * im) + (t_1 + 0.00023919753086419754)));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = 0.08333333333333333 * math.pow(im, 4.0) tmp = 0 if im <= 0.68: tmp = t_0 * ((2.0 + (im * im)) + t_1) elif im <= 2e+73: tmp = (math.exp(-im) + math.exp(im)) * (0.5 + (-0.25 * (re * re))) else: tmp = t_0 * (2.0 + ((im * im) + (t_1 + 0.00023919753086419754))) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(0.08333333333333333 * (im ^ 4.0)) tmp = 0.0 if (im <= 0.68) tmp = Float64(t_0 * Float64(Float64(2.0 + Float64(im * im)) + t_1)); elseif (im <= 2e+73) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))); else tmp = Float64(t_0 * Float64(2.0 + Float64(Float64(im * im) + Float64(t_1 + 0.00023919753086419754)))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = 0.08333333333333333 * (im ^ 4.0); tmp = 0.0; if (im <= 0.68) tmp = t_0 * ((2.0 + (im * im)) + t_1); elseif (im <= 2e+73) tmp = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * re))); else tmp = t_0 * (2.0 + ((im * im) + (t_1 + 0.00023919753086419754))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.08333333333333333 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.68], N[(t$95$0 * N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2e+73], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 + N[(N[(im * im), $MachinePrecision] + N[(t$95$1 + 0.00023919753086419754), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
t_1 := 0.08333333333333333 \cdot {im}^{4}\\
\mathbf{if}\;im \leq 0.68:\\
\;\;\;\;t_0 \cdot \left(\left(2 + im \cdot im\right) + t_1\right)\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(2 + \left(im \cdot im + \left(t_1 + 0.00023919753086419754\right)\right)\right)\\
\end{array}
\end{array}
if im < 0.680000000000000049Initial program 100.0%
Taylor expanded in im around 0 93.6%
associate-+r+93.6%
unpow293.6%
Simplified93.6%
if 0.680000000000000049 < im < 1.99999999999999997e73Initial program 100.0%
Taylor expanded in re around 0 5.3%
associate-*r*5.3%
distribute-rgt-out84.2%
unpow284.2%
Simplified84.2%
if 1.99999999999999997e73 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around inf 100.0%
associate-*r*100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+r+100.0%
unpow2100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Applied egg-rr98.2%
Final simplification93.7%
(FPCore (re im)
:precision binary64
(if (or (<= im 0.68) (not (<= im 2e+73)))
(*
(* 0.5 (cos re))
(+ (+ 2.0 (* im im)) (* 0.08333333333333333 (pow im 4.0))))
(* (+ (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re))))))
double code(double re, double im) {
double tmp;
if ((im <= 0.68) || !(im <= 2e+73)) {
tmp = (0.5 * cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * pow(im, 4.0)));
} else {
tmp = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * re)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 0.68d0) .or. (.not. (im <= 2d+73))) then
tmp = (0.5d0 * cos(re)) * ((2.0d0 + (im * im)) + (0.08333333333333333d0 * (im ** 4.0d0)))
else
tmp = (exp(-im) + exp(im)) * (0.5d0 + ((-0.25d0) * (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 0.68) || !(im <= 2e+73)) {
tmp = (0.5 * Math.cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * Math.pow(im, 4.0)));
} else {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 0.68) or not (im <= 2e+73): tmp = (0.5 * math.cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * math.pow(im, 4.0))) else: tmp = (math.exp(-im) + math.exp(im)) * (0.5 + (-0.25 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if ((im <= 0.68) || !(im <= 2e+73)) tmp = Float64(Float64(0.5 * cos(re)) * Float64(Float64(2.0 + Float64(im * im)) + Float64(0.08333333333333333 * (im ^ 4.0)))); else tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 0.68) || ~((im <= 2e+73))) tmp = (0.5 * cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * (im ^ 4.0))); else tmp = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 0.68], N[Not[LessEqual[im, 2e+73]], $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[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.68 \lor \neg \left(im \leq 2 \cdot 10^{+73}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(\left(2 + im \cdot im\right) + 0.08333333333333333 \cdot {im}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if im < 0.680000000000000049 or 1.99999999999999997e73 < im Initial program 100.0%
Taylor expanded in im around 0 94.5%
associate-+r+94.5%
unpow294.5%
Simplified94.5%
if 0.680000000000000049 < im < 1.99999999999999997e73Initial program 100.0%
Taylor expanded in re around 0 5.3%
associate-*r*5.3%
distribute-rgt-out84.2%
unpow284.2%
Simplified84.2%
Final simplification93.7%
(FPCore (re im)
:precision binary64
(if (<= im 0.66)
(* (* 0.5 (cos re)) (+ 2.0 (* im im)))
(if (<= im 4.5e+152)
(* (+ (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re))))
(* im (* 0.5 (* (cos re) im))))))
double code(double re, double im) {
double tmp;
if (im <= 0.66) {
tmp = (0.5 * cos(re)) * (2.0 + (im * im));
} else if (im <= 4.5e+152) {
tmp = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * 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 <= 0.66d0) then
tmp = (0.5d0 * cos(re)) * (2.0d0 + (im * im))
else if (im <= 4.5d+152) then
tmp = (exp(-im) + exp(im)) * (0.5d0 + ((-0.25d0) * (re * 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 <= 0.66) {
tmp = (0.5 * Math.cos(re)) * (2.0 + (im * im));
} else if (im <= 4.5e+152) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
} else {
tmp = im * (0.5 * (Math.cos(re) * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.66: tmp = (0.5 * math.cos(re)) * (2.0 + (im * im)) elif im <= 4.5e+152: tmp = (math.exp(-im) + math.exp(im)) * (0.5 + (-0.25 * (re * re))) else: tmp = im * (0.5 * (math.cos(re) * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.66) tmp = Float64(Float64(0.5 * cos(re)) * Float64(2.0 + Float64(im * im))); elseif (im <= 4.5e+152) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))); else tmp = Float64(im * Float64(0.5 * Float64(cos(re) * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.66) tmp = (0.5 * cos(re)) * (2.0 + (im * im)); elseif (im <= 4.5e+152) tmp = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * re))); else tmp = im * (0.5 * (cos(re) * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.66], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.5e+152], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(0.5 * N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.66:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+152}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 0.660000000000000031Initial program 100.0%
Taylor expanded in im around 0 87.4%
unpow287.4%
Simplified87.4%
if 0.660000000000000031 < im < 4.5000000000000001e152Initial program 100.0%
Taylor expanded in re around 0 2.6%
associate-*r*2.6%
distribute-rgt-out79.5%
unpow279.5%
Simplified79.5%
if 4.5000000000000001e152 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification87.6%
(FPCore (re im)
:precision binary64
(if (<= im 0.66)
(* (* 0.5 (cos re)) (+ 2.0 (* im im)))
(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 <= 0.66) {
tmp = (0.5 * cos(re)) * (2.0 + (im * im));
} 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 <= 0.66d0) then
tmp = (0.5d0 * cos(re)) * (2.0d0 + (im * im))
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 <= 0.66) {
tmp = (0.5 * Math.cos(re)) * (2.0 + (im * im));
} 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 <= 0.66: tmp = (0.5 * math.cos(re)) * (2.0 + (im * im)) 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 <= 0.66) tmp = Float64(Float64(0.5 * cos(re)) * Float64(2.0 + Float64(im * im))); elseif (im <= 2.1e+154) tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(im * Float64(0.5 * Float64(cos(re) * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.66) tmp = (0.5 * cos(re)) * (2.0 + (im * im)); 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, 0.66], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.1e+154], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(0.5 * N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.66:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 2.1 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 0.660000000000000031Initial program 100.0%
Taylor expanded in im around 0 87.4%
unpow287.4%
Simplified87.4%
if 0.660000000000000031 < im < 2.09999999999999994e154Initial program 100.0%
Taylor expanded in re around 0 69.2%
*-commutative69.2%
Simplified69.2%
if 2.09999999999999994e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification86.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ 2.0 (* im im))))
(if (or (<= im 3800000.0) (not (<= im 2.15e+136)))
(* (* 0.5 (cos re)) t_0)
(fma 0.5 t_0 (* -0.25 (* t_0 (* re re)))))))
double code(double re, double im) {
double t_0 = 2.0 + (im * im);
double tmp;
if ((im <= 3800000.0) || !(im <= 2.15e+136)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = fma(0.5, t_0, (-0.25 * (t_0 * (re * re))));
}
return tmp;
}
function code(re, im) t_0 = Float64(2.0 + Float64(im * im)) tmp = 0.0 if ((im <= 3800000.0) || !(im <= 2.15e+136)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = fma(0.5, t_0, Float64(-0.25 * Float64(t_0 * Float64(re * re)))); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[im, 3800000.0], N[Not[LessEqual[im, 2.15e+136]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(0.5 * t$95$0 + N[(-0.25 * N[(t$95$0 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 + im \cdot im\\
\mathbf{if}\;im \leq 3800000 \lor \neg \left(im \leq 2.15 \cdot 10^{+136}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t_0, -0.25 \cdot \left(t_0 \cdot \left(re \cdot re\right)\right)\right)\\
\end{array}
\end{array}
if im < 3.8e6 or 2.1499999999999999e136 < im Initial program 100.0%
Taylor expanded in im around 0 87.6%
unpow287.6%
Simplified87.6%
if 3.8e6 < im < 2.1499999999999999e136Initial program 100.0%
Taylor expanded in im around 0 5.2%
unpow25.2%
Simplified5.2%
Taylor expanded in re around 0 36.6%
fma-def36.6%
unpow236.6%
*-commutative36.6%
unpow236.6%
unpow236.6%
Simplified36.6%
Final simplification80.6%
(FPCore (re im) :precision binary64 (if (or (<= im 5800000000.0) (not (<= im 2.15e+136))) (* (* 0.5 (cos re)) (+ 2.0 (* im im))) (* (* im im) (* -0.25 (* re re)))))
double code(double re, double im) {
double tmp;
if ((im <= 5800000000.0) || !(im <= 2.15e+136)) {
tmp = (0.5 * cos(re)) * (2.0 + (im * im));
} else {
tmp = (im * im) * (-0.25 * (re * re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 5800000000.0d0) .or. (.not. (im <= 2.15d+136))) then
tmp = (0.5d0 * cos(re)) * (2.0d0 + (im * im))
else
tmp = (im * im) * ((-0.25d0) * (re * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 5800000000.0) || !(im <= 2.15e+136)) {
tmp = (0.5 * Math.cos(re)) * (2.0 + (im * im));
} else {
tmp = (im * im) * (-0.25 * (re * re));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 5800000000.0) or not (im <= 2.15e+136): tmp = (0.5 * math.cos(re)) * (2.0 + (im * im)) else: tmp = (im * im) * (-0.25 * (re * re)) return tmp
function code(re, im) tmp = 0.0 if ((im <= 5800000000.0) || !(im <= 2.15e+136)) tmp = Float64(Float64(0.5 * cos(re)) * Float64(2.0 + Float64(im * im))); else tmp = Float64(Float64(im * im) * Float64(-0.25 * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 5800000000.0) || ~((im <= 2.15e+136))) tmp = (0.5 * cos(re)) * (2.0 + (im * im)); else tmp = (im * im) * (-0.25 * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 5800000000.0], N[Not[LessEqual[im, 2.15e+136]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(im * im), $MachinePrecision] * N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5800000000 \lor \neg \left(im \leq 2.15 \cdot 10^{+136}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if im < 5.8e9 or 2.1499999999999999e136 < im Initial program 100.0%
Taylor expanded in im around 0 87.6%
unpow287.6%
Simplified87.6%
if 5.8e9 < im < 2.1499999999999999e136Initial program 100.0%
Taylor expanded in im around 0 5.2%
unpow25.2%
Simplified5.2%
Taylor expanded in re around 0 36.6%
fma-def36.6%
unpow236.6%
*-commutative36.6%
unpow236.6%
unpow236.6%
Simplified36.6%
Taylor expanded in re around inf 34.7%
*-commutative34.7%
+-commutative34.7%
unpow234.7%
fma-udef34.7%
associate-*r*34.7%
unpow234.7%
Simplified34.7%
Taylor expanded in im around inf 34.7%
unpow234.7%
associate-*r*34.7%
unpow234.7%
Simplified34.7%
Final simplification80.3%
(FPCore (re im)
:precision binary64
(if (<= im 8500000.0)
(cos re)
(if (<= im 2.15e+136)
(* (* im im) (* -0.25 (* re re)))
(* im (* 0.5 (* (cos re) im))))))
double code(double re, double im) {
double tmp;
if (im <= 8500000.0) {
tmp = cos(re);
} else if (im <= 2.15e+136) {
tmp = (im * im) * (-0.25 * (re * 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 <= 8500000.0d0) then
tmp = cos(re)
else if (im <= 2.15d+136) then
tmp = (im * im) * ((-0.25d0) * (re * 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 <= 8500000.0) {
tmp = Math.cos(re);
} else if (im <= 2.15e+136) {
tmp = (im * im) * (-0.25 * (re * re));
} else {
tmp = im * (0.5 * (Math.cos(re) * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 8500000.0: tmp = math.cos(re) elif im <= 2.15e+136: tmp = (im * im) * (-0.25 * (re * re)) else: tmp = im * (0.5 * (math.cos(re) * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 8500000.0) tmp = cos(re); elseif (im <= 2.15e+136) tmp = Float64(Float64(im * im) * Float64(-0.25 * Float64(re * re))); else tmp = Float64(im * Float64(0.5 * Float64(cos(re) * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 8500000.0) tmp = cos(re); elseif (im <= 2.15e+136) tmp = (im * im) * (-0.25 * (re * re)); else tmp = im * (0.5 * (cos(re) * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 8500000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.15e+136], N[(N[(im * im), $MachinePrecision] * N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(0.5 * N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 8500000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.15 \cdot 10^{+136}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 8.5e6Initial program 100.0%
Taylor expanded in im around 0 66.1%
if 8.5e6 < im < 2.1499999999999999e136Initial program 100.0%
Taylor expanded in im around 0 5.2%
unpow25.2%
Simplified5.2%
Taylor expanded in re around 0 36.6%
fma-def36.6%
unpow236.6%
*-commutative36.6%
unpow236.6%
unpow236.6%
Simplified36.6%
Taylor expanded in re around inf 34.7%
*-commutative34.7%
+-commutative34.7%
unpow234.7%
fma-udef34.7%
associate-*r*34.7%
unpow234.7%
Simplified34.7%
Taylor expanded in im around inf 34.7%
unpow234.7%
associate-*r*34.7%
unpow234.7%
Simplified34.7%
if 2.1499999999999999e136 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification65.7%
(FPCore (re im)
:precision binary64
(if (<= im 500000000.0)
(cos re)
(if (<= im 2.15e+136)
(* (* im im) (* -0.25 (* re re)))
(+ 1.0 (* 0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 500000000.0) {
tmp = cos(re);
} else if (im <= 2.15e+136) {
tmp = (im * im) * (-0.25 * (re * re));
} else {
tmp = 1.0 + (0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 500000000.0d0) then
tmp = cos(re)
else if (im <= 2.15d+136) then
tmp = (im * im) * ((-0.25d0) * (re * re))
else
tmp = 1.0d0 + (0.5d0 * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 500000000.0) {
tmp = Math.cos(re);
} else if (im <= 2.15e+136) {
tmp = (im * im) * (-0.25 * (re * re));
} else {
tmp = 1.0 + (0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 500000000.0: tmp = math.cos(re) elif im <= 2.15e+136: tmp = (im * im) * (-0.25 * (re * re)) else: tmp = 1.0 + (0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 500000000.0) tmp = cos(re); elseif (im <= 2.15e+136) tmp = Float64(Float64(im * im) * Float64(-0.25 * Float64(re * re))); else tmp = Float64(1.0 + Float64(0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 500000000.0) tmp = cos(re); elseif (im <= 2.15e+136) tmp = (im * im) * (-0.25 * (re * re)); else tmp = 1.0 + (0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 500000000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.15e+136], N[(N[(im * im), $MachinePrecision] * N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 500000000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.15 \cdot 10^{+136}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(-0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 5e8Initial program 100.0%
Taylor expanded in im around 0 66.1%
if 5e8 < im < 2.1499999999999999e136Initial program 100.0%
Taylor expanded in im around 0 5.2%
unpow25.2%
Simplified5.2%
Taylor expanded in re around 0 36.6%
fma-def36.6%
unpow236.6%
*-commutative36.6%
unpow236.6%
unpow236.6%
Simplified36.6%
Taylor expanded in re around inf 34.7%
*-commutative34.7%
+-commutative34.7%
unpow234.7%
fma-udef34.7%
associate-*r*34.7%
unpow234.7%
Simplified34.7%
Taylor expanded in im around inf 34.7%
unpow234.7%
associate-*r*34.7%
unpow234.7%
Simplified34.7%
if 2.1499999999999999e136 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in re around 0 55.2%
distribute-rgt-in55.2%
metadata-eval55.2%
unpow255.2%
Simplified55.2%
Final simplification60.6%
(FPCore (re im) :precision binary64 (if (<= re 720000.0) (+ 1.0 (* 0.5 (* im im))) (* re (* (* im im) (* re -0.25)))))
double code(double re, double im) {
double tmp;
if (re <= 720000.0) {
tmp = 1.0 + (0.5 * (im * im));
} else {
tmp = re * ((im * im) * (re * -0.25));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 720000.0d0) then
tmp = 1.0d0 + (0.5d0 * (im * im))
else
tmp = re * ((im * im) * (re * (-0.25d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 720000.0) {
tmp = 1.0 + (0.5 * (im * im));
} else {
tmp = re * ((im * im) * (re * -0.25));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 720000.0: tmp = 1.0 + (0.5 * (im * im)) else: tmp = re * ((im * im) * (re * -0.25)) return tmp
function code(re, im) tmp = 0.0 if (re <= 720000.0) tmp = Float64(1.0 + Float64(0.5 * Float64(im * im))); else tmp = Float64(re * Float64(Float64(im * im) * Float64(re * -0.25))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 720000.0) tmp = 1.0 + (0.5 * (im * im)); else tmp = re * ((im * im) * (re * -0.25)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 720000.0], N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(N[(im * im), $MachinePrecision] * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 720000:\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(\left(im \cdot im\right) \cdot \left(re \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if re < 7.2e5Initial program 100.0%
Taylor expanded in im around 0 75.5%
unpow275.5%
Simplified75.5%
Taylor expanded in re around 0 53.0%
distribute-rgt-in53.0%
metadata-eval53.0%
unpow253.0%
Simplified53.0%
if 7.2e5 < re Initial program 100.0%
Taylor expanded in im around 0 78.8%
unpow278.8%
Simplified78.8%
Taylor expanded in re around 0 12.2%
fma-def12.2%
unpow212.2%
*-commutative12.2%
unpow212.2%
unpow212.2%
Simplified12.2%
Taylor expanded in re around inf 31.2%
*-commutative31.2%
+-commutative31.2%
unpow231.2%
fma-udef31.2%
associate-*r*31.2%
unpow231.2%
Simplified31.2%
Taylor expanded in im around inf 31.1%
unpow231.1%
associate-*r*31.1%
unpow231.1%
associate-*l*31.1%
*-commutative31.1%
associate-*l*31.4%
*-commutative31.4%
Simplified31.4%
Final simplification47.7%
(FPCore (re im) :precision binary64 (if (<= im 8500000.0) 1.0 (if (<= im 1.9e+136) (* (* re re) -0.5) (* im (* 0.5 im)))))
double code(double re, double im) {
double tmp;
if (im <= 8500000.0) {
tmp = 1.0;
} else if (im <= 1.9e+136) {
tmp = (re * re) * -0.5;
} 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 <= 8500000.0d0) then
tmp = 1.0d0
else if (im <= 1.9d+136) then
tmp = (re * re) * (-0.5d0)
else
tmp = im * (0.5d0 * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 8500000.0) {
tmp = 1.0;
} else if (im <= 1.9e+136) {
tmp = (re * re) * -0.5;
} else {
tmp = im * (0.5 * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 8500000.0: tmp = 1.0 elif im <= 1.9e+136: tmp = (re * re) * -0.5 else: tmp = im * (0.5 * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 8500000.0) tmp = 1.0; elseif (im <= 1.9e+136) tmp = Float64(Float64(re * re) * -0.5); else tmp = Float64(im * Float64(0.5 * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 8500000.0) tmp = 1.0; elseif (im <= 1.9e+136) tmp = (re * re) * -0.5; else tmp = im * (0.5 * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 8500000.0], 1.0, If[LessEqual[im, 1.9e+136], N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision], N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 8500000:\\
\;\;\;\;1\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+136}:\\
\;\;\;\;\left(re \cdot re\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\end{array}
\end{array}
if im < 8.5e6Initial program 100.0%
Applied egg-rr35.7%
+-inverses35.7%
+-rgt-identity35.7%
*-inverses35.7%
Simplified35.7%
if 8.5e6 < im < 1.90000000000000007e136Initial program 100.0%
Taylor expanded in im around 0 5.2%
unpow25.2%
Simplified5.2%
Taylor expanded in re around 0 36.6%
fma-def36.6%
unpow236.6%
*-commutative36.6%
unpow236.6%
unpow236.6%
Simplified36.6%
Taylor expanded in re around inf 34.7%
*-commutative34.7%
+-commutative34.7%
unpow234.7%
fma-udef34.7%
associate-*r*34.7%
unpow234.7%
Simplified34.7%
Taylor expanded in im around 0 24.3%
*-commutative24.3%
unpow224.3%
Simplified24.3%
if 1.90000000000000007e136 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 55.2%
Final simplification36.3%
(FPCore (re im) :precision binary64 (if (<= re 3.3e+160) (+ 1.0 (* 0.5 (* im im))) (* (* re re) -0.5)))
double code(double re, double im) {
double tmp;
if (re <= 3.3e+160) {
tmp = 1.0 + (0.5 * (im * im));
} else {
tmp = (re * re) * -0.5;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 3.3d+160) then
tmp = 1.0d0 + (0.5d0 * (im * im))
else
tmp = (re * re) * (-0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 3.3e+160) {
tmp = 1.0 + (0.5 * (im * im));
} else {
tmp = (re * re) * -0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.3e+160: tmp = 1.0 + (0.5 * (im * im)) else: tmp = (re * re) * -0.5 return tmp
function code(re, im) tmp = 0.0 if (re <= 3.3e+160) tmp = Float64(1.0 + Float64(0.5 * Float64(im * im))); else tmp = Float64(Float64(re * re) * -0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.3e+160) tmp = 1.0 + (0.5 * (im * im)); else tmp = (re * re) * -0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.3e+160], N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.3 \cdot 10^{+160}:\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot -0.5\\
\end{array}
\end{array}
if re < 3.2999999999999997e160Initial program 100.0%
Taylor expanded in im around 0 76.3%
unpow276.3%
Simplified76.3%
Taylor expanded in re around 0 48.8%
distribute-rgt-in48.8%
metadata-eval48.8%
unpow248.8%
Simplified48.8%
if 3.2999999999999997e160 < re Initial program 100.0%
Taylor expanded in im around 0 76.4%
unpow276.4%
Simplified76.4%
Taylor expanded in re around 0 12.4%
fma-def12.4%
unpow212.4%
*-commutative12.4%
unpow212.4%
unpow212.4%
Simplified12.4%
Taylor expanded in re around inf 35.3%
*-commutative35.3%
+-commutative35.3%
unpow235.3%
fma-udef35.3%
associate-*r*35.3%
unpow235.3%
Simplified35.3%
Taylor expanded in im around 0 35.3%
*-commutative35.3%
unpow235.3%
Simplified35.3%
Final simplification46.9%
(FPCore (re im) :precision binary64 (if (<= re 3.3e+160) (+ 1.0 (* 0.5 (* im im))) (+ 1.0 (* (* re re) -0.5))))
double code(double re, double im) {
double tmp;
if (re <= 3.3e+160) {
tmp = 1.0 + (0.5 * (im * im));
} else {
tmp = 1.0 + ((re * re) * -0.5);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 3.3d+160) then
tmp = 1.0d0 + (0.5d0 * (im * im))
else
tmp = 1.0d0 + ((re * re) * (-0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 3.3e+160) {
tmp = 1.0 + (0.5 * (im * im));
} else {
tmp = 1.0 + ((re * re) * -0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.3e+160: tmp = 1.0 + (0.5 * (im * im)) else: tmp = 1.0 + ((re * re) * -0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 3.3e+160) tmp = Float64(1.0 + Float64(0.5 * Float64(im * im))); else tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.3e+160) tmp = 1.0 + (0.5 * (im * im)); else tmp = 1.0 + ((re * re) * -0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.3e+160], N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.3 \cdot 10^{+160}:\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
\end{array}
\end{array}
if re < 3.2999999999999997e160Initial program 100.0%
Taylor expanded in im around 0 76.3%
unpow276.3%
Simplified76.3%
Taylor expanded in re around 0 48.8%
distribute-rgt-in48.8%
metadata-eval48.8%
unpow248.8%
Simplified48.8%
if 3.2999999999999997e160 < re Initial program 100.0%
Taylor expanded in im around 0 76.4%
unpow276.4%
Simplified76.4%
Taylor expanded in re around 0 12.4%
fma-def12.4%
unpow212.4%
*-commutative12.4%
unpow212.4%
unpow212.4%
Simplified12.4%
Taylor expanded in im around 0 35.3%
*-commutative35.3%
unpow235.3%
Simplified35.3%
Final simplification46.9%
(FPCore (re im) :precision binary64 (if (<= im 0.0145) 1.0 (* im (* 0.5 im))))
double code(double re, double im) {
double tmp;
if (im <= 0.0145) {
tmp = 1.0;
} 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 <= 0.0145d0) then
tmp = 1.0d0
else
tmp = im * (0.5d0 * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0145) {
tmp = 1.0;
} else {
tmp = im * (0.5 * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0145: tmp = 1.0 else: tmp = im * (0.5 * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0145) tmp = 1.0; else tmp = Float64(im * Float64(0.5 * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0145) tmp = 1.0; else tmp = im * (0.5 * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0145], 1.0, N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0145:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\end{array}
\end{array}
if im < 0.0145000000000000007Initial program 100.0%
Applied egg-rr36.5%
+-inverses36.5%
+-rgt-identity36.5%
*-inverses36.5%
Simplified36.5%
if 0.0145000000000000007 < im Initial program 100.0%
Taylor expanded in im around 0 45.4%
unpow245.4%
Simplified45.4%
Taylor expanded in im around inf 45.2%
associate-*r*45.2%
unpow245.2%
associate-*r*45.2%
*-commutative45.2%
associate-*l*45.2%
*-commutative45.2%
Simplified45.2%
Taylor expanded in re around 0 25.2%
Final simplification33.5%
(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-rr27.3%
+-inverses27.3%
+-rgt-identity27.3%
*-inverses27.3%
Simplified27.3%
Final simplification27.3%
herbie shell --seed 2023274
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))