
(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 19 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 (+ (exp (- im)) (exp im))))
(t_1 (* 0.041666666666666664 (* (cos re) (pow im 4.0)))))
(if (<= im -6.5e+97)
t_1
(if (<= im -0.00096)
t_0
(if (<= im 1.45e-29) (cos re) (if (<= im 1.2e+77) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) + exp(im));
double t_1 = 0.041666666666666664 * (cos(re) * pow(im, 4.0));
double tmp;
if (im <= -6.5e+97) {
tmp = t_1;
} else if (im <= -0.00096) {
tmp = t_0;
} else if (im <= 1.45e-29) {
tmp = cos(re);
} else if (im <= 1.2e+77) {
tmp = t_0;
} else {
tmp = t_1;
}
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 * (exp(-im) + exp(im))
t_1 = 0.041666666666666664d0 * (cos(re) * (im ** 4.0d0))
if (im <= (-6.5d+97)) then
tmp = t_1
else if (im <= (-0.00096d0)) then
tmp = t_0
else if (im <= 1.45d-29) then
tmp = cos(re)
else if (im <= 1.2d+77) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) + Math.exp(im));
double t_1 = 0.041666666666666664 * (Math.cos(re) * Math.pow(im, 4.0));
double tmp;
if (im <= -6.5e+97) {
tmp = t_1;
} else if (im <= -0.00096) {
tmp = t_0;
} else if (im <= 1.45e-29) {
tmp = Math.cos(re);
} else if (im <= 1.2e+77) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) + math.exp(im)) t_1 = 0.041666666666666664 * (math.cos(re) * math.pow(im, 4.0)) tmp = 0 if im <= -6.5e+97: tmp = t_1 elif im <= -0.00096: tmp = t_0 elif im <= 1.45e-29: tmp = math.cos(re) elif im <= 1.2e+77: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))) t_1 = Float64(0.041666666666666664 * Float64(cos(re) * (im ^ 4.0))) tmp = 0.0 if (im <= -6.5e+97) tmp = t_1; elseif (im <= -0.00096) tmp = t_0; elseif (im <= 1.45e-29) tmp = cos(re); elseif (im <= 1.2e+77) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) + exp(im)); t_1 = 0.041666666666666664 * (cos(re) * (im ^ 4.0)); tmp = 0.0; if (im <= -6.5e+97) tmp = t_1; elseif (im <= -0.00096) tmp = t_0; elseif (im <= 1.45e-29) tmp = cos(re); elseif (im <= 1.2e+77) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.041666666666666664 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.5e+97], t$95$1, If[LessEqual[im, -0.00096], t$95$0, If[LessEqual[im, 1.45e-29], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.2e+77], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
t_1 := 0.041666666666666664 \cdot \left(\cos re \cdot {im}^{4}\right)\\
\mathbf{if}\;im \leq -6.5 \cdot 10^{+97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.00096:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.45 \cdot 10^{-29}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+77}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -6.4999999999999999e97 or 1.1999999999999999e77 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -6.4999999999999999e97 < im < -9.60000000000000024e-4 or 1.45000000000000012e-29 < im < 1.1999999999999999e77Initial program 100.0%
Taylor expanded in re around 0 89.2%
if -9.60000000000000024e-4 < im < 1.45000000000000012e-29Initial program 100.0%
Taylor expanded in im around 0 99.6%
Final simplification98.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (+ (exp (- im)) (exp im))))
(t_1 (* 0.041666666666666664 (* (cos re) (pow im 4.0)))))
(if (<= im -6.5e+97)
t_1
(if (<= im -0.065)
t_0
(if (<= im 1.45e-29)
(* (cos re) (fma im (* 0.5 im) 1.0))
(if (<= im 1.15e+77) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) + exp(im));
double t_1 = 0.041666666666666664 * (cos(re) * pow(im, 4.0));
double tmp;
if (im <= -6.5e+97) {
tmp = t_1;
} else if (im <= -0.065) {
tmp = t_0;
} else if (im <= 1.45e-29) {
tmp = cos(re) * fma(im, (0.5 * im), 1.0);
} else if (im <= 1.15e+77) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))) t_1 = Float64(0.041666666666666664 * Float64(cos(re) * (im ^ 4.0))) tmp = 0.0 if (im <= -6.5e+97) tmp = t_1; elseif (im <= -0.065) tmp = t_0; elseif (im <= 1.45e-29) tmp = Float64(cos(re) * fma(im, Float64(0.5 * im), 1.0)); elseif (im <= 1.15e+77) tmp = t_0; else tmp = t_1; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.041666666666666664 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.5e+97], t$95$1, If[LessEqual[im, -0.065], t$95$0, If[LessEqual[im, 1.45e-29], N[(N[Cos[re], $MachinePrecision] * N[(im * N[(0.5 * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.15e+77], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
t_1 := 0.041666666666666664 \cdot \left(\cos re \cdot {im}^{4}\right)\\
\mathbf{if}\;im \leq -6.5 \cdot 10^{+97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.065:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.45 \cdot 10^{-29}:\\
\;\;\;\;\cos re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -6.4999999999999999e97 or 1.14999999999999997e77 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -6.4999999999999999e97 < im < -0.065000000000000002 or 1.45000000000000012e-29 < im < 1.14999999999999997e77Initial program 100.0%
Taylor expanded in re around 0 89.2%
if -0.065000000000000002 < im < 1.45000000000000012e-29Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 99.9%
associate-*r*99.9%
unpow299.9%
fma-udef99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in re around inf 99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-lft1-in99.9%
*-commutative99.9%
unpow299.9%
associate-*l*99.9%
fma-def99.9%
Simplified99.9%
Final simplification98.4%
(FPCore (re im) :precision binary64 (if (or (<= im -2.2) (not (<= im 2.2))) (* 0.041666666666666664 (* (cos re) (pow im 4.0))) (cos re)))
double code(double re, double im) {
double tmp;
if ((im <= -2.2) || !(im <= 2.2)) {
tmp = 0.041666666666666664 * (cos(re) * pow(im, 4.0));
} else {
tmp = cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-2.2d0)) .or. (.not. (im <= 2.2d0))) then
tmp = 0.041666666666666664d0 * (cos(re) * (im ** 4.0d0))
else
tmp = cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -2.2) || !(im <= 2.2)) {
tmp = 0.041666666666666664 * (Math.cos(re) * Math.pow(im, 4.0));
} else {
tmp = Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -2.2) or not (im <= 2.2): tmp = 0.041666666666666664 * (math.cos(re) * math.pow(im, 4.0)) else: tmp = math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -2.2) || !(im <= 2.2)) tmp = Float64(0.041666666666666664 * Float64(cos(re) * (im ^ 4.0))); else tmp = cos(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -2.2) || ~((im <= 2.2))) tmp = 0.041666666666666664 * (cos(re) * (im ^ 4.0)); else tmp = cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -2.2], N[Not[LessEqual[im, 2.2]], $MachinePrecision]], N[(0.041666666666666664 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Cos[re], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.2 \lor \neg \left(im \leq 2.2\right):\\
\;\;\;\;0.041666666666666664 \cdot \left(\cos re \cdot {im}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re\\
\end{array}
\end{array}
if im < -2.2000000000000002 or 2.2000000000000002 < im Initial program 100.0%
Taylor expanded in im around 0 81.5%
Simplified81.5%
Taylor expanded in im around inf 81.5%
*-commutative81.5%
Simplified81.5%
if -2.2000000000000002 < im < 2.2000000000000002Initial program 100.0%
Taylor expanded in im around 0 99.6%
Final simplification89.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos re) (* im (* 0.5 im))))
(t_1 (* 0.041666666666666664 (pow im 4.0))))
(if (<= im -1.4e+152)
t_0
(if (<= im -6.2e+19)
t_1
(if (<= im 3800000000.0) (cos re) (if (<= im 1.9e+154) t_1 t_0))))))
double code(double re, double im) {
double t_0 = cos(re) * (im * (0.5 * im));
double t_1 = 0.041666666666666664 * pow(im, 4.0);
double tmp;
if (im <= -1.4e+152) {
tmp = t_0;
} else if (im <= -6.2e+19) {
tmp = t_1;
} else if (im <= 3800000000.0) {
tmp = cos(re);
} else if (im <= 1.9e+154) {
tmp = t_1;
} else {
tmp = t_0;
}
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 = cos(re) * (im * (0.5d0 * im))
t_1 = 0.041666666666666664d0 * (im ** 4.0d0)
if (im <= (-1.4d+152)) then
tmp = t_0
else if (im <= (-6.2d+19)) then
tmp = t_1
else if (im <= 3800000000.0d0) then
tmp = cos(re)
else if (im <= 1.9d+154) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.cos(re) * (im * (0.5 * im));
double t_1 = 0.041666666666666664 * Math.pow(im, 4.0);
double tmp;
if (im <= -1.4e+152) {
tmp = t_0;
} else if (im <= -6.2e+19) {
tmp = t_1;
} else if (im <= 3800000000.0) {
tmp = Math.cos(re);
} else if (im <= 1.9e+154) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = math.cos(re) * (im * (0.5 * im)) t_1 = 0.041666666666666664 * math.pow(im, 4.0) tmp = 0 if im <= -1.4e+152: tmp = t_0 elif im <= -6.2e+19: tmp = t_1 elif im <= 3800000000.0: tmp = math.cos(re) elif im <= 1.9e+154: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(cos(re) * Float64(im * Float64(0.5 * im))) t_1 = Float64(0.041666666666666664 * (im ^ 4.0)) tmp = 0.0 if (im <= -1.4e+152) tmp = t_0; elseif (im <= -6.2e+19) tmp = t_1; elseif (im <= 3800000000.0) tmp = cos(re); elseif (im <= 1.9e+154) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = cos(re) * (im * (0.5 * im)); t_1 = 0.041666666666666664 * (im ^ 4.0); tmp = 0.0; if (im <= -1.4e+152) tmp = t_0; elseif (im <= -6.2e+19) tmp = t_1; elseif (im <= 3800000000.0) tmp = cos(re); elseif (im <= 1.9e+154) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[re], $MachinePrecision] * N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.041666666666666664 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.4e+152], t$95$0, If[LessEqual[im, -6.2e+19], t$95$1, If[LessEqual[im, 3800000000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.9e+154], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos re \cdot \left(im \cdot \left(0.5 \cdot im\right)\right)\\
t_1 := 0.041666666666666664 \cdot {im}^{4}\\
\mathbf{if}\;im \leq -1.4 \cdot 10^{+152}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -6.2 \cdot 10^{+19}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 3800000000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.4000000000000001e152 or 1.8999999999999999e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 98.9%
associate-*r*98.9%
unpow298.9%
fma-udef98.9%
*-commutative98.9%
Simplified98.9%
Taylor expanded in im around inf 98.9%
*-commutative98.9%
associate-*l*98.9%
unpow298.9%
associate-*l*98.9%
Simplified98.9%
if -1.4000000000000001e152 < im < -6.2e19 or 3.8e9 < im < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 61.4%
Simplified61.4%
Taylor expanded in im around inf 61.4%
*-commutative61.4%
Simplified61.4%
Taylor expanded in re around 0 53.2%
if -6.2e19 < im < 3.8e9Initial program 100.0%
Taylor expanded in im around 0 97.9%
Final simplification87.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.041666666666666664 (pow im 4.0)))
(t_1 (* (* im im) (+ 0.5 (* (* re re) -0.25)))))
(if (<= im -1e+216)
t_1
(if (<= im -4.8e+18)
t_0
(if (<= im 32000000000.0)
(cos re)
(if (<= im 1e+188) t_0 (if (<= im 1e+219) t_1 (* 0.5 (* im im)))))))))
double code(double re, double im) {
double t_0 = 0.041666666666666664 * pow(im, 4.0);
double t_1 = (im * im) * (0.5 + ((re * re) * -0.25));
double tmp;
if (im <= -1e+216) {
tmp = t_1;
} else if (im <= -4.8e+18) {
tmp = t_0;
} else if (im <= 32000000000.0) {
tmp = cos(re);
} else if (im <= 1e+188) {
tmp = t_0;
} else if (im <= 1e+219) {
tmp = t_1;
} else {
tmp = 0.5 * (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) :: t_1
real(8) :: tmp
t_0 = 0.041666666666666664d0 * (im ** 4.0d0)
t_1 = (im * im) * (0.5d0 + ((re * re) * (-0.25d0)))
if (im <= (-1d+216)) then
tmp = t_1
else if (im <= (-4.8d+18)) then
tmp = t_0
else if (im <= 32000000000.0d0) then
tmp = cos(re)
else if (im <= 1d+188) then
tmp = t_0
else if (im <= 1d+219) then
tmp = t_1
else
tmp = 0.5d0 * (im * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.041666666666666664 * Math.pow(im, 4.0);
double t_1 = (im * im) * (0.5 + ((re * re) * -0.25));
double tmp;
if (im <= -1e+216) {
tmp = t_1;
} else if (im <= -4.8e+18) {
tmp = t_0;
} else if (im <= 32000000000.0) {
tmp = Math.cos(re);
} else if (im <= 1e+188) {
tmp = t_0;
} else if (im <= 1e+219) {
tmp = t_1;
} else {
tmp = 0.5 * (im * im);
}
return tmp;
}
def code(re, im): t_0 = 0.041666666666666664 * math.pow(im, 4.0) t_1 = (im * im) * (0.5 + ((re * re) * -0.25)) tmp = 0 if im <= -1e+216: tmp = t_1 elif im <= -4.8e+18: tmp = t_0 elif im <= 32000000000.0: tmp = math.cos(re) elif im <= 1e+188: tmp = t_0 elif im <= 1e+219: tmp = t_1 else: tmp = 0.5 * (im * im) return tmp
function code(re, im) t_0 = Float64(0.041666666666666664 * (im ^ 4.0)) t_1 = Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(re * re) * -0.25))) tmp = 0.0 if (im <= -1e+216) tmp = t_1; elseif (im <= -4.8e+18) tmp = t_0; elseif (im <= 32000000000.0) tmp = cos(re); elseif (im <= 1e+188) tmp = t_0; elseif (im <= 1e+219) tmp = t_1; else tmp = Float64(0.5 * Float64(im * im)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.041666666666666664 * (im ^ 4.0); t_1 = (im * im) * (0.5 + ((re * re) * -0.25)); tmp = 0.0; if (im <= -1e+216) tmp = t_1; elseif (im <= -4.8e+18) tmp = t_0; elseif (im <= 32000000000.0) tmp = cos(re); elseif (im <= 1e+188) tmp = t_0; elseif (im <= 1e+219) tmp = t_1; else tmp = 0.5 * (im * im); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.041666666666666664 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1e+216], t$95$1, If[LessEqual[im, -4.8e+18], t$95$0, If[LessEqual[im, 32000000000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1e+188], t$95$0, If[LessEqual[im, 1e+219], t$95$1, N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.041666666666666664 \cdot {im}^{4}\\
t_1 := \left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
\mathbf{if}\;im \leq -1 \cdot 10^{+216}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -4.8 \cdot 10^{+18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 32000000000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 10^{+188}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 10^{+219}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < -1e216 or 1e188 < im < 9.99999999999999965e218Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
unpow2100.0%
fma-udef100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*l*100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
associate-*r*0.0%
distribute-rgt-out93.1%
unpow293.1%
*-commutative93.1%
unpow293.1%
Simplified93.1%
if -1e216 < im < -4.8e18 or 3.2e10 < im < 1e188Initial program 100.0%
Taylor expanded in im around 0 73.3%
Simplified73.3%
Taylor expanded in im around inf 73.3%
*-commutative73.3%
Simplified73.3%
Taylor expanded in re around 0 61.0%
if -4.8e18 < im < 3.2e10Initial program 100.0%
Taylor expanded in im around 0 97.9%
if 9.99999999999999965e218 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
unpow2100.0%
fma-udef100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*l*100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around 0 95.0%
unpow295.0%
Simplified95.0%
Final simplification84.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* im im)))
(t_1 (+ 0.25 (* (* re re) 0.25)))
(t_2 (* (* im im) (+ 0.5 (* (* re re) -0.25)))))
(if (<= im -1.95e+167)
t_2
(if (<= im -1.45e+20)
t_1
(if (<= im 580.0)
(cos re)
(if (<= im 6.6e+134)
t_1
(if (<= im 5e+188) (+ 1.0 t_0) (if (<= im 1.8e+219) t_2 t_0))))))))
double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = 0.25 + ((re * re) * 0.25);
double t_2 = (im * im) * (0.5 + ((re * re) * -0.25));
double tmp;
if (im <= -1.95e+167) {
tmp = t_2;
} else if (im <= -1.45e+20) {
tmp = t_1;
} else if (im <= 580.0) {
tmp = cos(re);
} else if (im <= 6.6e+134) {
tmp = t_1;
} else if (im <= 5e+188) {
tmp = 1.0 + t_0;
} else if (im <= 1.8e+219) {
tmp = t_2;
} else {
tmp = t_0;
}
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) :: t_2
real(8) :: tmp
t_0 = 0.5d0 * (im * im)
t_1 = 0.25d0 + ((re * re) * 0.25d0)
t_2 = (im * im) * (0.5d0 + ((re * re) * (-0.25d0)))
if (im <= (-1.95d+167)) then
tmp = t_2
else if (im <= (-1.45d+20)) then
tmp = t_1
else if (im <= 580.0d0) then
tmp = cos(re)
else if (im <= 6.6d+134) then
tmp = t_1
else if (im <= 5d+188) then
tmp = 1.0d0 + t_0
else if (im <= 1.8d+219) then
tmp = t_2
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = 0.25 + ((re * re) * 0.25);
double t_2 = (im * im) * (0.5 + ((re * re) * -0.25));
double tmp;
if (im <= -1.95e+167) {
tmp = t_2;
} else if (im <= -1.45e+20) {
tmp = t_1;
} else if (im <= 580.0) {
tmp = Math.cos(re);
} else if (im <= 6.6e+134) {
tmp = t_1;
} else if (im <= 5e+188) {
tmp = 1.0 + t_0;
} else if (im <= 1.8e+219) {
tmp = t_2;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (im * im) t_1 = 0.25 + ((re * re) * 0.25) t_2 = (im * im) * (0.5 + ((re * re) * -0.25)) tmp = 0 if im <= -1.95e+167: tmp = t_2 elif im <= -1.45e+20: tmp = t_1 elif im <= 580.0: tmp = math.cos(re) elif im <= 6.6e+134: tmp = t_1 elif im <= 5e+188: tmp = 1.0 + t_0 elif im <= 1.8e+219: tmp = t_2 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(im * im)) t_1 = Float64(0.25 + Float64(Float64(re * re) * 0.25)) t_2 = Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(re * re) * -0.25))) tmp = 0.0 if (im <= -1.95e+167) tmp = t_2; elseif (im <= -1.45e+20) tmp = t_1; elseif (im <= 580.0) tmp = cos(re); elseif (im <= 6.6e+134) tmp = t_1; elseif (im <= 5e+188) tmp = Float64(1.0 + t_0); elseif (im <= 1.8e+219) tmp = t_2; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im * im); t_1 = 0.25 + ((re * re) * 0.25); t_2 = (im * im) * (0.5 + ((re * re) * -0.25)); tmp = 0.0; if (im <= -1.95e+167) tmp = t_2; elseif (im <= -1.45e+20) tmp = t_1; elseif (im <= 580.0) tmp = cos(re); elseif (im <= 6.6e+134) tmp = t_1; elseif (im <= 5e+188) tmp = 1.0 + t_0; elseif (im <= 1.8e+219) tmp = t_2; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.25 + N[(N[(re * re), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.95e+167], t$95$2, If[LessEqual[im, -1.45e+20], t$95$1, If[LessEqual[im, 580.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 6.6e+134], t$95$1, If[LessEqual[im, 5e+188], N[(1.0 + t$95$0), $MachinePrecision], If[LessEqual[im, 1.8e+219], t$95$2, t$95$0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := 0.25 + \left(re \cdot re\right) \cdot 0.25\\
t_2 := \left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
\mathbf{if}\;im \leq -1.95 \cdot 10^{+167}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -1.45 \cdot 10^{+20}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 580:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+134}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 5 \cdot 10^{+188}:\\
\;\;\;\;1 + t_0\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+219}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.9499999999999999e167 or 5.0000000000000001e188 < im < 1.80000000000000003e219Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
unpow2100.0%
fma-udef100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*l*100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
associate-*r*0.0%
distribute-rgt-out86.8%
unpow286.8%
*-commutative86.8%
unpow286.8%
Simplified86.8%
if -1.9499999999999999e167 < im < -1.45e20 or 580 < im < 6.6e134Initial program 100.0%
Applied egg-rr2.8%
Taylor expanded in re around 0 25.9%
*-commutative25.9%
unpow225.9%
Simplified25.9%
if -1.45e20 < im < 580Initial program 100.0%
Taylor expanded in im around 0 97.9%
if 6.6e134 < im < 5.0000000000000001e188Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 75.0%
associate-*r*75.0%
unpow275.0%
fma-udef75.0%
*-commutative75.0%
Simplified75.0%
Taylor expanded in re around 0 63.5%
unpow263.5%
Simplified63.5%
if 1.80000000000000003e219 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
unpow2100.0%
fma-udef100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*l*100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around 0 95.0%
unpow295.0%
Simplified95.0%
Final simplification75.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* im im))) (t_1 (+ 0.25 (* (* re re) 0.25))))
(if (<= im -9.5e+153)
t_0
(if (<= im -4.1e+18)
t_1
(if (<= im 310.0) 1.0 (if (<= im 6.5e+135) t_1 t_0))))))
double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = 0.25 + ((re * re) * 0.25);
double tmp;
if (im <= -9.5e+153) {
tmp = t_0;
} else if (im <= -4.1e+18) {
tmp = t_1;
} else if (im <= 310.0) {
tmp = 1.0;
} else if (im <= 6.5e+135) {
tmp = t_1;
} else {
tmp = t_0;
}
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 * (im * im)
t_1 = 0.25d0 + ((re * re) * 0.25d0)
if (im <= (-9.5d+153)) then
tmp = t_0
else if (im <= (-4.1d+18)) then
tmp = t_1
else if (im <= 310.0d0) then
tmp = 1.0d0
else if (im <= 6.5d+135) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = 0.25 + ((re * re) * 0.25);
double tmp;
if (im <= -9.5e+153) {
tmp = t_0;
} else if (im <= -4.1e+18) {
tmp = t_1;
} else if (im <= 310.0) {
tmp = 1.0;
} else if (im <= 6.5e+135) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (im * im) t_1 = 0.25 + ((re * re) * 0.25) tmp = 0 if im <= -9.5e+153: tmp = t_0 elif im <= -4.1e+18: tmp = t_1 elif im <= 310.0: tmp = 1.0 elif im <= 6.5e+135: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(im * im)) t_1 = Float64(0.25 + Float64(Float64(re * re) * 0.25)) tmp = 0.0 if (im <= -9.5e+153) tmp = t_0; elseif (im <= -4.1e+18) tmp = t_1; elseif (im <= 310.0) tmp = 1.0; elseif (im <= 6.5e+135) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im * im); t_1 = 0.25 + ((re * re) * 0.25); tmp = 0.0; if (im <= -9.5e+153) tmp = t_0; elseif (im <= -4.1e+18) tmp = t_1; elseif (im <= 310.0) tmp = 1.0; elseif (im <= 6.5e+135) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.25 + N[(N[(re * re), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -9.5e+153], t$95$0, If[LessEqual[im, -4.1e+18], t$95$1, If[LessEqual[im, 310.0], 1.0, If[LessEqual[im, 6.5e+135], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := 0.25 + \left(re \cdot re\right) \cdot 0.25\\
\mathbf{if}\;im \leq -9.5 \cdot 10^{+153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -4.1 \cdot 10^{+18}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 310:\\
\;\;\;\;1\\
\mathbf{elif}\;im \leq 6.5 \cdot 10^{+135}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -9.4999999999999995e153 or 6.5000000000000003e135 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 94.4%
associate-*r*94.4%
unpow294.4%
fma-udef94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in im around inf 94.4%
*-commutative94.4%
associate-*l*94.4%
unpow294.4%
associate-*l*94.4%
Simplified94.4%
Taylor expanded in re around 0 69.7%
unpow269.7%
Simplified69.7%
if -9.4999999999999995e153 < im < -4.1e18 or 310 < im < 6.5000000000000003e135Initial program 100.0%
Applied egg-rr2.8%
Taylor expanded in re around 0 24.4%
*-commutative24.4%
unpow224.4%
Simplified24.4%
if -4.1e18 < im < 310Initial program 100.0%
Taylor expanded in im around 0 98.3%
Simplified98.3%
Taylor expanded in im around inf 3.4%
*-commutative3.4%
Simplified3.4%
Applied egg-rr53.4%
Final simplification51.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* im im))) (t_1 (- (* re re) re)))
(if (<= im -1.9e+153)
t_0
(if (<= im -1.4e+19)
t_1
(if (<= im 360.0) 1.0 (if (<= im 1.05e+136) t_1 t_0))))))
double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = (re * re) - re;
double tmp;
if (im <= -1.9e+153) {
tmp = t_0;
} else if (im <= -1.4e+19) {
tmp = t_1;
} else if (im <= 360.0) {
tmp = 1.0;
} else if (im <= 1.05e+136) {
tmp = t_1;
} else {
tmp = t_0;
}
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 * (im * im)
t_1 = (re * re) - re
if (im <= (-1.9d+153)) then
tmp = t_0
else if (im <= (-1.4d+19)) then
tmp = t_1
else if (im <= 360.0d0) then
tmp = 1.0d0
else if (im <= 1.05d+136) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = (re * re) - re;
double tmp;
if (im <= -1.9e+153) {
tmp = t_0;
} else if (im <= -1.4e+19) {
tmp = t_1;
} else if (im <= 360.0) {
tmp = 1.0;
} else if (im <= 1.05e+136) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (im * im) t_1 = (re * re) - re tmp = 0 if im <= -1.9e+153: tmp = t_0 elif im <= -1.4e+19: tmp = t_1 elif im <= 360.0: tmp = 1.0 elif im <= 1.05e+136: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(im * im)) t_1 = Float64(Float64(re * re) - re) tmp = 0.0 if (im <= -1.9e+153) tmp = t_0; elseif (im <= -1.4e+19) tmp = t_1; elseif (im <= 360.0) tmp = 1.0; elseif (im <= 1.05e+136) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im * im); t_1 = (re * re) - re; tmp = 0.0; if (im <= -1.9e+153) tmp = t_0; elseif (im <= -1.4e+19) tmp = t_1; elseif (im <= 360.0) tmp = 1.0; elseif (im <= 1.05e+136) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(re * re), $MachinePrecision] - re), $MachinePrecision]}, If[LessEqual[im, -1.9e+153], t$95$0, If[LessEqual[im, -1.4e+19], t$95$1, If[LessEqual[im, 360.0], 1.0, If[LessEqual[im, 1.05e+136], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := re \cdot re - re\\
\mathbf{if}\;im \leq -1.9 \cdot 10^{+153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -1.4 \cdot 10^{+19}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 360:\\
\;\;\;\;1\\
\mathbf{elif}\;im \leq 1.05 \cdot 10^{+136}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.89999999999999983e153 or 1.05e136 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around 0 94.4%
associate-*r*94.4%
unpow294.4%
fma-udef94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in im around inf 94.4%
*-commutative94.4%
associate-*l*94.4%
unpow294.4%
associate-*l*94.4%
Simplified94.4%
Taylor expanded in re around 0 69.7%
unpow269.7%
Simplified69.7%
if -1.89999999999999983e153 < im < -1.4e19 or 360 < im < 1.05e136Initial program 100.0%
Taylor expanded in re around 0 0.0%
Simplified62.7%
Applied egg-rr23.7%
fma-neg23.7%
Simplified23.7%
if -1.4e19 < im < 360Initial program 100.0%
Taylor expanded in im around 0 98.3%
Simplified98.3%
Taylor expanded in im around inf 3.4%
*-commutative3.4%
Simplified3.4%
Applied egg-rr53.4%
Final simplification51.7%
(FPCore (re im) :precision binary64 (if (or (<= re -6e+145) (not (<= re 3.3e+174))) (- (* re re) re) (+ 1.0 (* 0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if ((re <= -6e+145) || !(re <= 3.3e+174)) {
tmp = (re * 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 ((re <= (-6d+145)) .or. (.not. (re <= 3.3d+174))) then
tmp = (re * 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 ((re <= -6e+145) || !(re <= 3.3e+174)) {
tmp = (re * re) - re;
} else {
tmp = 1.0 + (0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -6e+145) or not (re <= 3.3e+174): tmp = (re * re) - re else: tmp = 1.0 + (0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if ((re <= -6e+145) || !(re <= 3.3e+174)) tmp = Float64(Float64(re * 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 ((re <= -6e+145) || ~((re <= 3.3e+174))) tmp = (re * re) - re; else tmp = 1.0 + (0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -6e+145], N[Not[LessEqual[re, 3.3e+174]], $MachinePrecision]], N[(N[(re * re), $MachinePrecision] - re), $MachinePrecision], N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -6 \cdot 10^{+145} \lor \neg \left(re \leq 3.3 \cdot 10^{+174}\right):\\
\;\;\;\;re \cdot re - re\\
\mathbf{else}:\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if re < -6.0000000000000005e145 or 3.3000000000000001e174 < re Initial program 100.0%
Taylor expanded in re around 0 0.6%
Simplified24.8%
Applied egg-rr38.1%
fma-neg38.1%
Simplified38.1%
if -6.0000000000000005e145 < re < 3.3000000000000001e174Initial program 100.0%
Taylor expanded in im around 0 90.8%
Simplified90.8%
Taylor expanded in im around 0 76.1%
associate-*r*76.1%
unpow276.1%
fma-udef76.1%
*-commutative76.1%
Simplified76.1%
Taylor expanded in re around 0 55.2%
unpow255.2%
Simplified55.2%
Final simplification51.1%
(FPCore (re im) :precision binary64 (if (or (<= im -0.00041) (not (<= im 1.4))) (* 0.5 (* im im)) 1.0))
double code(double re, double im) {
double tmp;
if ((im <= -0.00041) || !(im <= 1.4)) {
tmp = 0.5 * (im * im);
} else {
tmp = 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 <= (-0.00041d0)) .or. (.not. (im <= 1.4d0))) then
tmp = 0.5d0 * (im * im)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -0.00041) || !(im <= 1.4)) {
tmp = 0.5 * (im * im);
} else {
tmp = 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -0.00041) or not (im <= 1.4): tmp = 0.5 * (im * im) else: tmp = 1.0 return tmp
function code(re, im) tmp = 0.0 if ((im <= -0.00041) || !(im <= 1.4)) tmp = Float64(0.5 * Float64(im * im)); else tmp = 1.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -0.00041) || ~((im <= 1.4))) tmp = 0.5 * (im * im); else tmp = 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.00041], N[Not[LessEqual[im, 1.4]], $MachinePrecision]], N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.00041 \lor \neg \left(im \leq 1.4\right):\\
\;\;\;\;0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if im < -4.0999999999999999e-4 or 1.3999999999999999 < im Initial program 100.0%
Taylor expanded in im around 0 81.7%
Simplified81.7%
Taylor expanded in im around 0 56.4%
associate-*r*56.4%
unpow256.4%
fma-udef56.4%
*-commutative56.4%
Simplified56.4%
Taylor expanded in im around inf 55.8%
*-commutative55.8%
associate-*l*55.8%
unpow255.8%
associate-*l*55.8%
Simplified55.8%
Taylor expanded in re around 0 41.4%
unpow241.4%
Simplified41.4%
if -4.0999999999999999e-4 < im < 1.3999999999999999Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 3.3%
*-commutative3.3%
Simplified3.3%
Applied egg-rr54.8%
Final simplification47.3%
(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%
Taylor expanded in im around 0 89.8%
Simplified89.8%
Taylor expanded in im around inf 46.7%
*-commutative46.7%
Simplified46.7%
Applied egg-rr3.3%
Final simplification3.3%
(FPCore (re im) :precision binary64 0.041666666666666664)
double code(double re, double im) {
return 0.041666666666666664;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.041666666666666664d0
end function
public static double code(double re, double im) {
return 0.041666666666666664;
}
def code(re, im): return 0.041666666666666664
function code(re, im) return 0.041666666666666664 end
function tmp = code(re, im) tmp = 0.041666666666666664; end
code[re_, im_] := 0.041666666666666664
\begin{array}{l}
\\
0.041666666666666664
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 89.8%
Simplified89.8%
Taylor expanded in im around inf 46.7%
*-commutative46.7%
Simplified46.7%
Applied egg-rr7.1%
Final simplification7.1%
(FPCore (re im) :precision binary64 0.0625)
double code(double re, double im) {
return 0.0625;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0625d0
end function
public static double code(double re, double im) {
return 0.0625;
}
def code(re, im): return 0.0625
function code(re, im) return 0.0625 end
function tmp = code(re, im) tmp = 0.0625; end
code[re_, im_] := 0.0625
\begin{array}{l}
\\
0.0625
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 89.8%
Simplified89.8%
Taylor expanded in im around inf 46.7%
*-commutative46.7%
Simplified46.7%
Applied egg-rr7.3%
Final simplification7.3%
(FPCore (re im) :precision binary64 0.125)
double code(double re, double im) {
return 0.125;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.125d0
end function
public static double code(double re, double im) {
return 0.125;
}
def code(re, im): return 0.125
function code(re, im) return 0.125 end
function tmp = code(re, im) tmp = 0.125; end
code[re_, im_] := 0.125
\begin{array}{l}
\\
0.125
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 89.8%
Simplified89.8%
Taylor expanded in im around inf 46.7%
*-commutative46.7%
Simplified46.7%
Applied egg-rr7.5%
Final simplification7.5%
(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%
Applied egg-rr7.7%
Taylor expanded in re around 0 7.8%
Final simplification7.8%
(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%
Taylor expanded in im around 0 89.8%
Simplified89.8%
Taylor expanded in im around inf 46.7%
*-commutative46.7%
Simplified46.7%
Applied egg-rr8.3%
Final simplification8.3%
(FPCore (re im) :precision binary64 0.75)
double code(double re, double im) {
return 0.75;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.75d0
end function
public static double code(double re, double im) {
return 0.75;
}
def code(re, im): return 0.75
function code(re, im) return 0.75 end
function tmp = code(re, im) tmp = 0.75; end
code[re_, im_] := 0.75
\begin{array}{l}
\\
0.75
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 89.8%
Simplified89.8%
Taylor expanded in im around inf 46.7%
*-commutative46.7%
Simplified46.7%
Applied egg-rr8.7%
Final simplification8.7%
(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%
Taylor expanded in im around 0 89.8%
Simplified89.8%
Taylor expanded in im around inf 46.7%
*-commutative46.7%
Simplified46.7%
Applied egg-rr25.6%
Final simplification25.6%
herbie shell --seed 2023196
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))