
(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
(if (<= im 2.5)
(* (* 0.5 (cos re)) (+ 2.0 (* im im)))
(if (<= im 1.2e+77)
(* (+ (exp (- im)) (exp im)) (+ 0.5 (* (* re re) -0.25)))
(* (cos re) (* (pow im 4.0) 0.041666666666666664)))))
double code(double re, double im) {
double tmp;
if (im <= 2.5) {
tmp = (0.5 * cos(re)) * (2.0 + (im * im));
} else if (im <= 1.2e+77) {
tmp = (exp(-im) + exp(im)) * (0.5 + ((re * re) * -0.25));
} else {
tmp = cos(re) * (pow(im, 4.0) * 0.041666666666666664);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.5d0) then
tmp = (0.5d0 * cos(re)) * (2.0d0 + (im * im))
else if (im <= 1.2d+77) then
tmp = (exp(-im) + exp(im)) * (0.5d0 + ((re * re) * (-0.25d0)))
else
tmp = cos(re) * ((im ** 4.0d0) * 0.041666666666666664d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.5) {
tmp = (0.5 * Math.cos(re)) * (2.0 + (im * im));
} else if (im <= 1.2e+77) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 + ((re * re) * -0.25));
} else {
tmp = Math.cos(re) * (Math.pow(im, 4.0) * 0.041666666666666664);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.5: tmp = (0.5 * math.cos(re)) * (2.0 + (im * im)) elif im <= 1.2e+77: tmp = (math.exp(-im) + math.exp(im)) * (0.5 + ((re * re) * -0.25)) else: tmp = math.cos(re) * (math.pow(im, 4.0) * 0.041666666666666664) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.5) tmp = Float64(Float64(0.5 * cos(re)) * Float64(2.0 + Float64(im * im))); elseif (im <= 1.2e+77) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 + Float64(Float64(re * re) * -0.25))); else tmp = Float64(cos(re) * Float64((im ^ 4.0) * 0.041666666666666664)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.5) tmp = (0.5 * cos(re)) * (2.0 + (im * im)); elseif (im <= 1.2e+77) tmp = (exp(-im) + exp(im)) * (0.5 + ((re * re) * -0.25)); else tmp = cos(re) * ((im ^ 4.0) * 0.041666666666666664); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.5], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.2e+77], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.5:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+77}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{4} \cdot 0.041666666666666664\right)\\
\end{array}
\end{array}
if im < 2.5Initial program 100.0%
Taylor expanded in im around 0 82.5%
Simplified82.5%
if 2.5 < im < 1.1999999999999999e77Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 7.7%
associate-*r*7.7%
distribute-rgt-out76.9%
*-commutative76.9%
unpow276.9%
Simplified76.9%
if 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%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification85.0%
(FPCore (re im)
:precision binary64
(if (<= im 2.5)
(*
(* 0.5 (cos re))
(+ (+ 2.0 (* im im)) (* 0.08333333333333333 (pow im 4.0))))
(if (<= im 1.2e+77)
(* (+ (exp (- im)) (exp im)) (+ 0.5 (* (* re re) -0.25)))
(* (cos re) (* (pow im 4.0) 0.041666666666666664)))))
double code(double re, double im) {
double tmp;
if (im <= 2.5) {
tmp = (0.5 * cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * pow(im, 4.0)));
} else if (im <= 1.2e+77) {
tmp = (exp(-im) + exp(im)) * (0.5 + ((re * re) * -0.25));
} else {
tmp = cos(re) * (pow(im, 4.0) * 0.041666666666666664);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.5d0) then
tmp = (0.5d0 * cos(re)) * ((2.0d0 + (im * im)) + (0.08333333333333333d0 * (im ** 4.0d0)))
else if (im <= 1.2d+77) then
tmp = (exp(-im) + exp(im)) * (0.5d0 + ((re * re) * (-0.25d0)))
else
tmp = cos(re) * ((im ** 4.0d0) * 0.041666666666666664d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.5) {
tmp = (0.5 * Math.cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * Math.pow(im, 4.0)));
} else if (im <= 1.2e+77) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 + ((re * re) * -0.25));
} else {
tmp = Math.cos(re) * (Math.pow(im, 4.0) * 0.041666666666666664);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.5: tmp = (0.5 * math.cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * math.pow(im, 4.0))) elif im <= 1.2e+77: tmp = (math.exp(-im) + math.exp(im)) * (0.5 + ((re * re) * -0.25)) else: tmp = math.cos(re) * (math.pow(im, 4.0) * 0.041666666666666664) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.5) tmp = Float64(Float64(0.5 * cos(re)) * Float64(Float64(2.0 + Float64(im * im)) + Float64(0.08333333333333333 * (im ^ 4.0)))); elseif (im <= 1.2e+77) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 + Float64(Float64(re * re) * -0.25))); else tmp = Float64(cos(re) * Float64((im ^ 4.0) * 0.041666666666666664)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.5) tmp = (0.5 * cos(re)) * ((2.0 + (im * im)) + (0.08333333333333333 * (im ^ 4.0))); elseif (im <= 1.2e+77) tmp = (exp(-im) + exp(im)) * (0.5 + ((re * re) * -0.25)); else tmp = cos(re) * ((im ^ 4.0) * 0.041666666666666664); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.5], 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], If[LessEqual[im, 1.2e+77], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.5:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(\left(2 + im \cdot im\right) + 0.08333333333333333 \cdot {im}^{4}\right)\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+77}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{4} \cdot 0.041666666666666664\right)\\
\end{array}
\end{array}
if im < 2.5Initial program 100.0%
Taylor expanded in im around 0 87.8%
Simplified87.8%
if 2.5 < im < 1.1999999999999999e77Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 7.7%
associate-*r*7.7%
distribute-rgt-out76.9%
*-commutative76.9%
unpow276.9%
Simplified76.9%
if 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%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification89.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= im 0.053)
(* t_0 (+ 2.0 (* im im)))
(if (<= im 1.35e+154)
(* 0.5 (+ (exp (- im)) (exp im)))
(* t_0 (* im im))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double tmp;
if (im <= 0.053) {
tmp = t_0 * (2.0 + (im * im));
} else if (im <= 1.35e+154) {
tmp = 0.5 * (exp(-im) + exp(im));
} else {
tmp = t_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 <= 0.053d0) then
tmp = t_0 * (2.0d0 + (im * im))
else if (im <= 1.35d+154) then
tmp = 0.5d0 * (exp(-im) + exp(im))
else
tmp = t_0 * (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 <= 0.053) {
tmp = t_0 * (2.0 + (im * im));
} else if (im <= 1.35e+154) {
tmp = 0.5 * (Math.exp(-im) + Math.exp(im));
} else {
tmp = t_0 * (im * im);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) tmp = 0 if im <= 0.053: tmp = t_0 * (2.0 + (im * im)) elif im <= 1.35e+154: tmp = 0.5 * (math.exp(-im) + math.exp(im)) else: tmp = t_0 * (im * im) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) tmp = 0.0 if (im <= 0.053) tmp = Float64(t_0 * Float64(2.0 + Float64(im * im))); elseif (im <= 1.35e+154) tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(t_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 <= 0.053) tmp = t_0 * (2.0 + (im * im)); elseif (im <= 1.35e+154) tmp = 0.5 * (exp(-im) + exp(im)); else tmp = t_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, 0.053], N[(t$95$0 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathbf{if}\;im \leq 0.053:\\
\;\;\;\;t_0 \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 0.0529999999999999985Initial program 100.0%
Taylor expanded in im around 0 82.8%
Simplified82.8%
if 0.0529999999999999985 < im < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in re around 0 77.5%
if 1.35000000000000003e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification83.8%
(FPCore (re im)
:precision binary64
(if (<= im 0.039)
(* (* 0.5 (cos re)) (+ 2.0 (* im im)))
(if (<= im 1.2e+77)
(* 0.5 (+ (exp (- im)) (exp im)))
(* (cos re) (* (pow im 4.0) 0.041666666666666664)))))
double code(double re, double im) {
double tmp;
if (im <= 0.039) {
tmp = (0.5 * cos(re)) * (2.0 + (im * im));
} else if (im <= 1.2e+77) {
tmp = 0.5 * (exp(-im) + exp(im));
} else {
tmp = cos(re) * (pow(im, 4.0) * 0.041666666666666664);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.039d0) then
tmp = (0.5d0 * cos(re)) * (2.0d0 + (im * im))
else if (im <= 1.2d+77) then
tmp = 0.5d0 * (exp(-im) + exp(im))
else
tmp = cos(re) * ((im ** 4.0d0) * 0.041666666666666664d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.039) {
tmp = (0.5 * Math.cos(re)) * (2.0 + (im * im));
} else if (im <= 1.2e+77) {
tmp = 0.5 * (Math.exp(-im) + Math.exp(im));
} else {
tmp = Math.cos(re) * (Math.pow(im, 4.0) * 0.041666666666666664);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.039: tmp = (0.5 * math.cos(re)) * (2.0 + (im * im)) elif im <= 1.2e+77: tmp = 0.5 * (math.exp(-im) + math.exp(im)) else: tmp = math.cos(re) * (math.pow(im, 4.0) * 0.041666666666666664) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.039) tmp = Float64(Float64(0.5 * cos(re)) * Float64(2.0 + Float64(im * im))); elseif (im <= 1.2e+77) tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(cos(re) * Float64((im ^ 4.0) * 0.041666666666666664)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.039) tmp = (0.5 * cos(re)) * (2.0 + (im * im)); elseif (im <= 1.2e+77) tmp = 0.5 * (exp(-im) + exp(im)); else tmp = cos(re) * ((im ^ 4.0) * 0.041666666666666664); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.039], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.2e+77], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.039:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+77}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{4} \cdot 0.041666666666666664\right)\\
\end{array}
\end{array}
if im < 0.0389999999999999999Initial program 100.0%
Taylor expanded in im around 0 82.8%
Simplified82.8%
if 0.0389999999999999999 < im < 1.1999999999999999e77Initial program 100.0%
Taylor expanded in re around 0 80.3%
if 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%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification85.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= im 250.0)
(* t_0 (+ 2.0 (* im im)))
(if (<= im 1.35e+154)
(*
(pow im 4.0)
(+ 0.041666666666666664 (* (* re re) -0.020833333333333332)))
(* t_0 (* im im))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double tmp;
if (im <= 250.0) {
tmp = t_0 * (2.0 + (im * im));
} else if (im <= 1.35e+154) {
tmp = pow(im, 4.0) * (0.041666666666666664 + ((re * re) * -0.020833333333333332));
} else {
tmp = t_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 <= 250.0d0) then
tmp = t_0 * (2.0d0 + (im * im))
else if (im <= 1.35d+154) then
tmp = (im ** 4.0d0) * (0.041666666666666664d0 + ((re * re) * (-0.020833333333333332d0)))
else
tmp = t_0 * (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 <= 250.0) {
tmp = t_0 * (2.0 + (im * im));
} else if (im <= 1.35e+154) {
tmp = Math.pow(im, 4.0) * (0.041666666666666664 + ((re * re) * -0.020833333333333332));
} else {
tmp = t_0 * (im * im);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) tmp = 0 if im <= 250.0: tmp = t_0 * (2.0 + (im * im)) elif im <= 1.35e+154: tmp = math.pow(im, 4.0) * (0.041666666666666664 + ((re * re) * -0.020833333333333332)) else: tmp = t_0 * (im * im) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) tmp = 0.0 if (im <= 250.0) tmp = Float64(t_0 * Float64(2.0 + Float64(im * im))); elseif (im <= 1.35e+154) tmp = Float64((im ^ 4.0) * Float64(0.041666666666666664 + Float64(Float64(re * re) * -0.020833333333333332))); else tmp = Float64(t_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 <= 250.0) tmp = t_0 * (2.0 + (im * im)); elseif (im <= 1.35e+154) tmp = (im ^ 4.0) * (0.041666666666666664 + ((re * re) * -0.020833333333333332)); else tmp = t_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, 250.0], N[(t$95$0 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[Power[im, 4.0], $MachinePrecision] * N[(0.041666666666666664 + N[(N[(re * re), $MachinePrecision] * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathbf{if}\;im \leq 250:\\
\;\;\;\;t_0 \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;{im}^{4} \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.020833333333333332\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 82.5%
Simplified82.5%
if 250 < im < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 57.5%
Simplified57.5%
Taylor expanded in im around inf 57.5%
associate-*r*57.5%
*-commutative57.5%
associate-*l*57.5%
Simplified57.5%
Taylor expanded in re around 0 5.6%
+-commutative5.6%
associate-*r*5.6%
distribute-rgt-out47.0%
*-commutative47.0%
unpow247.0%
Simplified47.0%
if 1.35000000000000003e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification80.1%
(FPCore (re im)
:precision binary64
(if (<= im 250.0)
(cos re)
(if (<= im 1.45e+76)
(+ 1.0 (* re (* re -0.5)))
(if (<= im 1.35e+154)
(+ (* (pow im 4.0) 0.041666666666666664) 1.0)
(* (* 0.5 (cos re)) (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = cos(re);
} else if (im <= 1.45e+76) {
tmp = 1.0 + (re * (re * -0.5));
} else if (im <= 1.35e+154) {
tmp = (pow(im, 4.0) * 0.041666666666666664) + 1.0;
} else {
tmp = (0.5 * cos(re)) * (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 <= 250.0d0) then
tmp = cos(re)
else if (im <= 1.45d+76) then
tmp = 1.0d0 + (re * (re * (-0.5d0)))
else if (im <= 1.35d+154) then
tmp = ((im ** 4.0d0) * 0.041666666666666664d0) + 1.0d0
else
tmp = (0.5d0 * cos(re)) * (im * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = Math.cos(re);
} else if (im <= 1.45e+76) {
tmp = 1.0 + (re * (re * -0.5));
} else if (im <= 1.35e+154) {
tmp = (Math.pow(im, 4.0) * 0.041666666666666664) + 1.0;
} else {
tmp = (0.5 * Math.cos(re)) * (im * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 250.0: tmp = math.cos(re) elif im <= 1.45e+76: tmp = 1.0 + (re * (re * -0.5)) elif im <= 1.35e+154: tmp = (math.pow(im, 4.0) * 0.041666666666666664) + 1.0 else: tmp = (0.5 * math.cos(re)) * (im * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 250.0) tmp = cos(re); elseif (im <= 1.45e+76) tmp = Float64(1.0 + Float64(re * Float64(re * -0.5))); elseif (im <= 1.35e+154) tmp = Float64(Float64((im ^ 4.0) * 0.041666666666666664) + 1.0); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(im * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 250.0) tmp = cos(re); elseif (im <= 1.45e+76) tmp = 1.0 + (re * (re * -0.5)); elseif (im <= 1.35e+154) tmp = ((im ^ 4.0) * 0.041666666666666664) + 1.0; else tmp = (0.5 * cos(re)) * (im * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 250.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.45e+76], N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 250:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.45 \cdot 10^{+76}:\\
\;\;\;\;1 + re \cdot \left(re \cdot -0.5\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;{im}^{4} \cdot 0.041666666666666664 + 1\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 70.2%
if 250 < im < 1.4500000000000001e76Initial program 100.0%
Taylor expanded in im around 0 3.3%
Taylor expanded in re around 0 11.0%
expm1-log1p-u2.0%
expm1-udef2.0%
*-commutative2.0%
unpow22.0%
associate-*l*2.0%
Applied egg-rr2.0%
expm1-def2.0%
expm1-log1p11.0%
Simplified11.0%
if 1.4500000000000001e76 < im < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 95.0%
Simplified95.0%
Taylor expanded in re around 0 71.4%
distribute-lft-in71.4%
metadata-eval71.4%
unpow271.4%
*-commutative71.4%
Simplified71.4%
Taylor expanded in im around inf 71.4%
if 1.35000000000000003e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification70.3%
(FPCore (re im)
:precision binary64
(if (<= im 700.0)
(cos re)
(if (<= im 8.2e+76)
(* (pow im 4.0) (* re (* re -0.020833333333333332)))
(if (<= im 1.35e+154)
(+ (* (pow im 4.0) 0.041666666666666664) 1.0)
(* (* 0.5 (cos re)) (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = cos(re);
} else if (im <= 8.2e+76) {
tmp = pow(im, 4.0) * (re * (re * -0.020833333333333332));
} else if (im <= 1.35e+154) {
tmp = (pow(im, 4.0) * 0.041666666666666664) + 1.0;
} else {
tmp = (0.5 * cos(re)) * (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 <= 700.0d0) then
tmp = cos(re)
else if (im <= 8.2d+76) then
tmp = (im ** 4.0d0) * (re * (re * (-0.020833333333333332d0)))
else if (im <= 1.35d+154) then
tmp = ((im ** 4.0d0) * 0.041666666666666664d0) + 1.0d0
else
tmp = (0.5d0 * cos(re)) * (im * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = Math.cos(re);
} else if (im <= 8.2e+76) {
tmp = Math.pow(im, 4.0) * (re * (re * -0.020833333333333332));
} else if (im <= 1.35e+154) {
tmp = (Math.pow(im, 4.0) * 0.041666666666666664) + 1.0;
} else {
tmp = (0.5 * Math.cos(re)) * (im * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 700.0: tmp = math.cos(re) elif im <= 8.2e+76: tmp = math.pow(im, 4.0) * (re * (re * -0.020833333333333332)) elif im <= 1.35e+154: tmp = (math.pow(im, 4.0) * 0.041666666666666664) + 1.0 else: tmp = (0.5 * math.cos(re)) * (im * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 700.0) tmp = cos(re); elseif (im <= 8.2e+76) tmp = Float64((im ^ 4.0) * Float64(re * Float64(re * -0.020833333333333332))); elseif (im <= 1.35e+154) tmp = Float64(Float64((im ^ 4.0) * 0.041666666666666664) + 1.0); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(im * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 700.0) tmp = cos(re); elseif (im <= 8.2e+76) tmp = (im ^ 4.0) * (re * (re * -0.020833333333333332)); elseif (im <= 1.35e+154) tmp = ((im ^ 4.0) * 0.041666666666666664) + 1.0; else tmp = (0.5 * cos(re)) * (im * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 700.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 8.2e+76], N[(N[Power[im, 4.0], $MachinePrecision] * N[(re * N[(re * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 700:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 8.2 \cdot 10^{+76}:\\
\;\;\;\;{im}^{4} \cdot \left(re \cdot \left(re \cdot -0.020833333333333332\right)\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;{im}^{4} \cdot 0.041666666666666664 + 1\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 700Initial program 100.0%
Taylor expanded in im around 0 69.9%
if 700 < im < 8.1999999999999997e76Initial program 100.0%
Taylor expanded in im around 0 4.3%
Simplified4.3%
Taylor expanded in im around inf 4.3%
associate-*r*4.3%
*-commutative4.3%
associate-*l*4.3%
Simplified4.3%
Taylor expanded in re around 0 12.9%
+-commutative12.9%
associate-*r*12.9%
distribute-rgt-out12.9%
*-commutative12.9%
unpow212.9%
Simplified12.9%
Taylor expanded in re around inf 10.9%
unpow210.9%
associate-*r*10.9%
*-commutative10.9%
associate-*r*10.9%
*-commutative10.9%
Simplified10.9%
if 8.1999999999999997e76 < im < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 95.0%
Simplified95.0%
Taylor expanded in re around 0 71.4%
distribute-lft-in71.4%
metadata-eval71.4%
unpow271.4%
*-commutative71.4%
Simplified71.4%
Taylor expanded in im around inf 71.4%
if 1.35000000000000003e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification70.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= im 700.0)
(* t_0 (+ 2.0 (* im im)))
(if (<= im 2.2e+76)
(* (pow im 4.0) (* re (* re -0.020833333333333332)))
(if (<= im 1.35e+154)
(+ (* (pow im 4.0) 0.041666666666666664) 1.0)
(* t_0 (* im im)))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double tmp;
if (im <= 700.0) {
tmp = t_0 * (2.0 + (im * im));
} else if (im <= 2.2e+76) {
tmp = pow(im, 4.0) * (re * (re * -0.020833333333333332));
} else if (im <= 1.35e+154) {
tmp = (pow(im, 4.0) * 0.041666666666666664) + 1.0;
} else {
tmp = t_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 <= 700.0d0) then
tmp = t_0 * (2.0d0 + (im * im))
else if (im <= 2.2d+76) then
tmp = (im ** 4.0d0) * (re * (re * (-0.020833333333333332d0)))
else if (im <= 1.35d+154) then
tmp = ((im ** 4.0d0) * 0.041666666666666664d0) + 1.0d0
else
tmp = t_0 * (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 <= 700.0) {
tmp = t_0 * (2.0 + (im * im));
} else if (im <= 2.2e+76) {
tmp = Math.pow(im, 4.0) * (re * (re * -0.020833333333333332));
} else if (im <= 1.35e+154) {
tmp = (Math.pow(im, 4.0) * 0.041666666666666664) + 1.0;
} else {
tmp = t_0 * (im * im);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) tmp = 0 if im <= 700.0: tmp = t_0 * (2.0 + (im * im)) elif im <= 2.2e+76: tmp = math.pow(im, 4.0) * (re * (re * -0.020833333333333332)) elif im <= 1.35e+154: tmp = (math.pow(im, 4.0) * 0.041666666666666664) + 1.0 else: tmp = t_0 * (im * im) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) tmp = 0.0 if (im <= 700.0) tmp = Float64(t_0 * Float64(2.0 + Float64(im * im))); elseif (im <= 2.2e+76) tmp = Float64((im ^ 4.0) * Float64(re * Float64(re * -0.020833333333333332))); elseif (im <= 1.35e+154) tmp = Float64(Float64((im ^ 4.0) * 0.041666666666666664) + 1.0); else tmp = Float64(t_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 <= 700.0) tmp = t_0 * (2.0 + (im * im)); elseif (im <= 2.2e+76) tmp = (im ^ 4.0) * (re * (re * -0.020833333333333332)); elseif (im <= 1.35e+154) tmp = ((im ^ 4.0) * 0.041666666666666664) + 1.0; else tmp = t_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, 700.0], N[(t$95$0 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.2e+76], N[(N[Power[im, 4.0], $MachinePrecision] * N[(re * N[(re * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision] + 1.0), $MachinePrecision], N[(t$95$0 * N[(im * im), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathbf{if}\;im \leq 700:\\
\;\;\;\;t_0 \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 2.2 \cdot 10^{+76}:\\
\;\;\;\;{im}^{4} \cdot \left(re \cdot \left(re \cdot -0.020833333333333332\right)\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;{im}^{4} \cdot 0.041666666666666664 + 1\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 700Initial program 100.0%
Taylor expanded in im around 0 82.1%
Simplified82.1%
if 700 < im < 2.2e76Initial program 100.0%
Taylor expanded in im around 0 4.3%
Simplified4.3%
Taylor expanded in im around inf 4.3%
associate-*r*4.3%
*-commutative4.3%
associate-*l*4.3%
Simplified4.3%
Taylor expanded in re around 0 12.9%
+-commutative12.9%
associate-*r*12.9%
distribute-rgt-out12.9%
*-commutative12.9%
unpow212.9%
Simplified12.9%
Taylor expanded in re around inf 10.9%
unpow210.9%
associate-*r*10.9%
*-commutative10.9%
associate-*r*10.9%
*-commutative10.9%
Simplified10.9%
if 2.2e76 < im < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 95.0%
Simplified95.0%
Taylor expanded in re around 0 71.4%
distribute-lft-in71.4%
metadata-eval71.4%
unpow271.4%
*-commutative71.4%
Simplified71.4%
Taylor expanded in im around inf 71.4%
if 1.35000000000000003e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification80.0%
(FPCore (re im)
:precision binary64
(if (<= im 250.0)
(cos re)
(if (<= im 1.15e+74)
(+ 1.0 (* re (* re -0.5)))
(+ (* (pow im 4.0) 0.041666666666666664) 1.0))))
double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = cos(re);
} else if (im <= 1.15e+74) {
tmp = 1.0 + (re * (re * -0.5));
} else {
tmp = (pow(im, 4.0) * 0.041666666666666664) + 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 <= 250.0d0) then
tmp = cos(re)
else if (im <= 1.15d+74) then
tmp = 1.0d0 + (re * (re * (-0.5d0)))
else
tmp = ((im ** 4.0d0) * 0.041666666666666664d0) + 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = Math.cos(re);
} else if (im <= 1.15e+74) {
tmp = 1.0 + (re * (re * -0.5));
} else {
tmp = (Math.pow(im, 4.0) * 0.041666666666666664) + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 250.0: tmp = math.cos(re) elif im <= 1.15e+74: tmp = 1.0 + (re * (re * -0.5)) else: tmp = (math.pow(im, 4.0) * 0.041666666666666664) + 1.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 250.0) tmp = cos(re); elseif (im <= 1.15e+74) tmp = Float64(1.0 + Float64(re * Float64(re * -0.5))); else tmp = Float64(Float64((im ^ 4.0) * 0.041666666666666664) + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 250.0) tmp = cos(re); elseif (im <= 1.15e+74) tmp = 1.0 + (re * (re * -0.5)); else tmp = ((im ^ 4.0) * 0.041666666666666664) + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 250.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.15e+74], N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 250:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+74}:\\
\;\;\;\;1 + re \cdot \left(re \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;{im}^{4} \cdot 0.041666666666666664 + 1\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 70.2%
if 250 < im < 1.1499999999999999e74Initial program 100.0%
Taylor expanded in im around 0 3.3%
Taylor expanded in re around 0 11.0%
expm1-log1p-u2.0%
expm1-udef2.0%
*-commutative2.0%
unpow22.0%
associate-*l*2.0%
Applied egg-rr2.0%
expm1-def2.0%
expm1-log1p11.0%
Simplified11.0%
if 1.1499999999999999e74 < im Initial program 100.0%
Taylor expanded in im around 0 97.9%
Simplified97.9%
Taylor expanded in re around 0 66.2%
distribute-lft-in66.2%
metadata-eval66.2%
unpow266.2%
*-commutative66.2%
Simplified66.2%
Taylor expanded in im around inf 66.2%
Final simplification66.8%
(FPCore (re im)
:precision binary64
(if (<= im 250.0)
(cos re)
(if (<= im 4.3e+73)
(+ 1.0 (* re (* re -0.5)))
(* (pow im 4.0) 0.041666666666666664))))
double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = cos(re);
} else if (im <= 4.3e+73) {
tmp = 1.0 + (re * (re * -0.5));
} else {
tmp = pow(im, 4.0) * 0.041666666666666664;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 250.0d0) then
tmp = cos(re)
else if (im <= 4.3d+73) then
tmp = 1.0d0 + (re * (re * (-0.5d0)))
else
tmp = (im ** 4.0d0) * 0.041666666666666664d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = Math.cos(re);
} else if (im <= 4.3e+73) {
tmp = 1.0 + (re * (re * -0.5));
} else {
tmp = Math.pow(im, 4.0) * 0.041666666666666664;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 250.0: tmp = math.cos(re) elif im <= 4.3e+73: tmp = 1.0 + (re * (re * -0.5)) else: tmp = math.pow(im, 4.0) * 0.041666666666666664 return tmp
function code(re, im) tmp = 0.0 if (im <= 250.0) tmp = cos(re); elseif (im <= 4.3e+73) tmp = Float64(1.0 + Float64(re * Float64(re * -0.5))); else tmp = Float64((im ^ 4.0) * 0.041666666666666664); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 250.0) tmp = cos(re); elseif (im <= 4.3e+73) tmp = 1.0 + (re * (re * -0.5)); else tmp = (im ^ 4.0) * 0.041666666666666664; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 250.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 4.3e+73], N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 250:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 4.3 \cdot 10^{+73}:\\
\;\;\;\;1 + re \cdot \left(re \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;{im}^{4} \cdot 0.041666666666666664\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 70.2%
if 250 < im < 4.30000000000000013e73Initial program 100.0%
Taylor expanded in im around 0 3.3%
Taylor expanded in re around 0 11.0%
expm1-log1p-u2.0%
expm1-udef2.0%
*-commutative2.0%
unpow22.0%
associate-*l*2.0%
Applied egg-rr2.0%
expm1-def2.0%
expm1-log1p11.0%
Simplified11.0%
if 4.30000000000000013e73 < im Initial program 100.0%
Taylor expanded in im around 0 97.9%
Simplified97.9%
Taylor expanded in im around inf 97.9%
associate-*r*97.9%
*-commutative97.9%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in re around 0 0.4%
+-commutative0.4%
associate-*r*0.4%
distribute-rgt-out76.0%
*-commutative76.0%
unpow276.0%
Simplified76.0%
Taylor expanded in re around 0 66.2%
Final simplification66.8%
(FPCore (re im) :precision binary64 (if (<= im 250.0) (cos re) (if (<= im 5.8e+150) (+ 1.0 (* re (* re -0.5))) (+ 1.0 (* 0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = cos(re);
} else if (im <= 5.8e+150) {
tmp = 1.0 + (re * (re * -0.5));
} 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 <= 250.0d0) then
tmp = cos(re)
else if (im <= 5.8d+150) then
tmp = 1.0d0 + (re * (re * (-0.5d0)))
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 <= 250.0) {
tmp = Math.cos(re);
} else if (im <= 5.8e+150) {
tmp = 1.0 + (re * (re * -0.5));
} else {
tmp = 1.0 + (0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 250.0: tmp = math.cos(re) elif im <= 5.8e+150: tmp = 1.0 + (re * (re * -0.5)) else: tmp = 1.0 + (0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 250.0) tmp = cos(re); elseif (im <= 5.8e+150) tmp = Float64(1.0 + Float64(re * Float64(re * -0.5))); 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 <= 250.0) tmp = cos(re); elseif (im <= 5.8e+150) tmp = 1.0 + (re * (re * -0.5)); else tmp = 1.0 + (0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 250.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 5.8e+150], N[(1.0 + N[(re * N[(re * -0.5), $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 250:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 5.8 \cdot 10^{+150}:\\
\;\;\;\;1 + re \cdot \left(re \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 70.2%
if 250 < im < 5.80000000000000022e150Initial program 100.0%
Taylor expanded in im around 0 3.2%
Taylor expanded in re around 0 9.7%
expm1-log1p-u1.8%
expm1-udef1.8%
*-commutative1.8%
unpow21.8%
associate-*l*1.8%
Applied egg-rr1.8%
expm1-def1.8%
expm1-log1p9.7%
Simplified9.7%
if 5.80000000000000022e150 < im Initial program 100.0%
Taylor expanded in im around 0 96.5%
Simplified96.5%
Taylor expanded in re around 0 60.5%
distribute-lft-in60.5%
metadata-eval60.5%
unpow260.5%
Simplified60.5%
Final simplification62.6%
(FPCore (re im) :precision binary64 (if (or (<= re 3.4e+157) (not (<= re 5.3e+247))) (+ 1.0 (* 0.5 (* im im))) (+ 1.0 (* re (* re -0.5)))))
double code(double re, double im) {
double tmp;
if ((re <= 3.4e+157) || !(re <= 5.3e+247)) {
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.4d+157) .or. (.not. (re <= 5.3d+247))) 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.4e+157) || !(re <= 5.3e+247)) {
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.4e+157) or not (re <= 5.3e+247): 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.4e+157) || !(re <= 5.3e+247)) tmp = Float64(1.0 + Float64(0.5 * Float64(im * im))); else tmp = Float64(1.0 + Float64(re * Float64(re * -0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= 3.4e+157) || ~((re <= 5.3e+247))) tmp = 1.0 + (0.5 * (im * im)); else tmp = 1.0 + (re * (re * -0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, 3.4e+157], N[Not[LessEqual[re, 5.3e+247]], $MachinePrecision]], N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.4 \cdot 10^{+157} \lor \neg \left(re \leq 5.3 \cdot 10^{+247}\right):\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(re \cdot -0.5\right)\\
\end{array}
\end{array}
if re < 3.39999999999999979e157 or 5.3000000000000002e247 < re Initial program 100.0%
Taylor expanded in im around 0 75.7%
Simplified75.7%
Taylor expanded in re around 0 52.5%
distribute-lft-in52.5%
metadata-eval52.5%
unpow252.5%
Simplified52.5%
if 3.39999999999999979e157 < re < 5.3000000000000002e247Initial program 100.0%
Taylor expanded in im around 0 40.4%
Taylor expanded in re around 0 39.3%
expm1-log1p-u0.0%
expm1-udef0.0%
*-commutative0.0%
unpow20.0%
associate-*l*0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p39.3%
Simplified39.3%
Final simplification51.9%
(FPCore (re im) :precision binary64 (+ 1.0 (* 0.5 (* im im))))
double code(double re, double im) {
return 1.0 + (0.5 * (im * im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + (0.5d0 * (im * im))
end function
public static double code(double re, double im) {
return 1.0 + (0.5 * (im * im));
}
def code(re, im): return 1.0 + (0.5 * (im * im))
function code(re, im) return Float64(1.0 + Float64(0.5 * Float64(im * im))) end
function tmp = code(re, im) tmp = 1.0 + (0.5 * (im * im)); end
code[re_, im_] := N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 0.5 \cdot \left(im \cdot im\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 75.4%
Simplified75.4%
Taylor expanded in re around 0 50.5%
distribute-lft-in50.5%
metadata-eval50.5%
unpow250.5%
Simplified50.5%
Final simplification50.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%
Taylor expanded in im around 0 56.3%
Taylor expanded in re around 0 35.7%
Final simplification35.7%
herbie shell --seed 2023199
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))