
(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 1000.0)
(* (cos re) (fma im (* 0.5 im) 1.0))
(if (<= im 2.1e+154)
(* (+ (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re))))
(* im (* (cos re) (* 0.5 im))))))
double code(double re, double im) {
double tmp;
if (im <= 1000.0) {
tmp = cos(re) * fma(im, (0.5 * im), 1.0);
} else if (im <= 2.1e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * re)));
} else {
tmp = im * (cos(re) * (0.5 * im));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 1000.0) tmp = Float64(cos(re) * fma(im, Float64(0.5 * im), 1.0)); elseif (im <= 2.1e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))); else tmp = Float64(im * Float64(cos(re) * Float64(0.5 * im))); end return tmp end
code[re_, im_] := If[LessEqual[im, 1000.0], N[(N[Cos[re], $MachinePrecision] * N[(im * N[(0.5 * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.1e+154], 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[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1000:\\
\;\;\;\;\cos re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\
\mathbf{elif}\;im \leq 2.1 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1e3Initial program 100.0%
Taylor expanded in im around 0 84.0%
Simplified84.0%
Taylor expanded in re around inf 84.0%
*-lft-identity84.0%
associate-*r*84.0%
distribute-rgt-out84.0%
+-commutative84.0%
*-commutative84.0%
unpow284.0%
associate-*l*84.0%
fma-def84.0%
Simplified84.0%
if 1e3 < im < 2.09999999999999994e154Initial program 100.0%
Taylor expanded in re around 0 0.0%
Simplified72.7%
if 2.09999999999999994e154 < 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%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification83.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (+ (exp (- im)) (exp im)))))
(if (<= im 0.18)
(cos re)
(if (<= im 2.9e+100)
t_0
(if (<= im 5.4e+133)
(* im (* im (+ 0.5 (* -0.25 (* re re)))))
(if (<= im 1.9e+154) t_0 (* im (* (cos re) (* 0.5 im)))))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) + exp(im));
double tmp;
if (im <= 0.18) {
tmp = cos(re);
} else if (im <= 2.9e+100) {
tmp = t_0;
} else if (im <= 5.4e+133) {
tmp = im * (im * (0.5 + (-0.25 * (re * re))));
} else if (im <= 1.9e+154) {
tmp = t_0;
} else {
tmp = im * (cos(re) * (0.5 * 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 * (exp(-im) + exp(im))
if (im <= 0.18d0) then
tmp = cos(re)
else if (im <= 2.9d+100) then
tmp = t_0
else if (im <= 5.4d+133) then
tmp = im * (im * (0.5d0 + ((-0.25d0) * (re * re))))
else if (im <= 1.9d+154) then
tmp = t_0
else
tmp = im * (cos(re) * (0.5d0 * im))
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 tmp;
if (im <= 0.18) {
tmp = Math.cos(re);
} else if (im <= 2.9e+100) {
tmp = t_0;
} else if (im <= 5.4e+133) {
tmp = im * (im * (0.5 + (-0.25 * (re * re))));
} else if (im <= 1.9e+154) {
tmp = t_0;
} else {
tmp = im * (Math.cos(re) * (0.5 * im));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) + math.exp(im)) tmp = 0 if im <= 0.18: tmp = math.cos(re) elif im <= 2.9e+100: tmp = t_0 elif im <= 5.4e+133: tmp = im * (im * (0.5 + (-0.25 * (re * re)))) elif im <= 1.9e+154: tmp = t_0 else: tmp = im * (math.cos(re) * (0.5 * im)) return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (im <= 0.18) tmp = cos(re); elseif (im <= 2.9e+100) tmp = t_0; elseif (im <= 5.4e+133) tmp = Float64(im * Float64(im * Float64(0.5 + Float64(-0.25 * Float64(re * re))))); elseif (im <= 1.9e+154) tmp = t_0; else tmp = Float64(im * Float64(cos(re) * Float64(0.5 * im))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) + exp(im)); tmp = 0.0; if (im <= 0.18) tmp = cos(re); elseif (im <= 2.9e+100) tmp = t_0; elseif (im <= 5.4e+133) tmp = im * (im * (0.5 + (-0.25 * (re * re)))); elseif (im <= 1.9e+154) tmp = t_0; else tmp = im * (cos(re) * (0.5 * im)); 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]}, If[LessEqual[im, 0.18], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.9e+100], t$95$0, If[LessEqual[im, 5.4e+133], N[(im * N[(im * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.9e+154], t$95$0, N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;im \leq 0.18:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.9 \cdot 10^{+100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\
\;\;\;\;im \cdot \left(im \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\right)\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 0.17999999999999999Initial program 100.0%
Taylor expanded in im around 0 67.6%
if 0.17999999999999999 < im < 2.9e100 or 5.4000000000000004e133 < im < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in re around 0 80.0%
if 2.9e100 < im < 5.4000000000000004e133Initial program 100.0%
Taylor expanded in im around 0 6.5%
Simplified6.5%
Taylor expanded in im around inf 6.5%
*-commutative6.5%
*-commutative6.5%
unpow26.5%
associate-*r*6.5%
associate-*r*6.5%
*-commutative6.5%
associate-*l*6.5%
Simplified6.5%
Taylor expanded in re around 0 79.2%
*-commutative79.2%
associate-*r*79.2%
distribute-rgt-out79.2%
unpow279.2%
Simplified79.2%
if 1.8999999999999999e154 < 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%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification72.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (+ (exp (- im)) (exp im)))))
(if (<= im 0.18)
(* (cos re) (fma im (* 0.5 im) 1.0))
(if (<= im 2.9e+100)
t_0
(if (<= im 5.4e+133)
(* im (* im (+ 0.5 (* -0.25 (* re re)))))
(if (<= im 2.5e+154) t_0 (* im (* (cos re) (* 0.5 im)))))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) + exp(im));
double tmp;
if (im <= 0.18) {
tmp = cos(re) * fma(im, (0.5 * im), 1.0);
} else if (im <= 2.9e+100) {
tmp = t_0;
} else if (im <= 5.4e+133) {
tmp = im * (im * (0.5 + (-0.25 * (re * re))));
} else if (im <= 2.5e+154) {
tmp = t_0;
} else {
tmp = im * (cos(re) * (0.5 * im));
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (im <= 0.18) tmp = Float64(cos(re) * fma(im, Float64(0.5 * im), 1.0)); elseif (im <= 2.9e+100) tmp = t_0; elseif (im <= 5.4e+133) tmp = Float64(im * Float64(im * Float64(0.5 + Float64(-0.25 * Float64(re * re))))); elseif (im <= 2.5e+154) tmp = t_0; else tmp = Float64(im * Float64(cos(re) * Float64(0.5 * im))); 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]}, If[LessEqual[im, 0.18], N[(N[Cos[re], $MachinePrecision] * N[(im * N[(0.5 * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.9e+100], t$95$0, If[LessEqual[im, 5.4e+133], N[(im * N[(im * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+154], t$95$0, N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;im \leq 0.18:\\
\;\;\;\;\cos re \cdot \mathsf{fma}\left(im, 0.5 \cdot im, 1\right)\\
\mathbf{elif}\;im \leq 2.9 \cdot 10^{+100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\
\;\;\;\;im \cdot \left(im \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 0.17999999999999999Initial program 100.0%
Taylor expanded in im around 0 84.0%
Simplified84.0%
Taylor expanded in re around inf 84.0%
*-lft-identity84.0%
associate-*r*84.0%
distribute-rgt-out84.0%
+-commutative84.0%
*-commutative84.0%
unpow284.0%
associate-*l*84.0%
fma-def84.0%
Simplified84.0%
if 0.17999999999999999 < im < 2.9e100 or 5.4000000000000004e133 < im < 2.50000000000000002e154Initial program 100.0%
Taylor expanded in re around 0 80.0%
if 2.9e100 < im < 5.4000000000000004e133Initial program 100.0%
Taylor expanded in im around 0 6.5%
Simplified6.5%
Taylor expanded in im around inf 6.5%
*-commutative6.5%
*-commutative6.5%
unpow26.5%
associate-*r*6.5%
associate-*r*6.5%
*-commutative6.5%
associate-*l*6.5%
Simplified6.5%
Taylor expanded in re around 0 79.2%
*-commutative79.2%
associate-*r*79.2%
distribute-rgt-out79.2%
unpow279.2%
Simplified79.2%
if 2.50000000000000002e154 < 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%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification84.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* re re) (* im im)))
(t_1 (* -0.25 t_0))
(t_2 (* 0.5 (* im im))))
(if (<= im 12200000000000.0)
(cos re)
(if (<= im 4.5e+134)
(+ (cos re) (* 0.5 (* (+ 1.0 (* (* re re) -0.5)) (* im im))))
(if (<= im 1.4e+154)
(/ (- (* t_1 t_1) (* t_2 t_2)) (fma -0.25 t_0 (* 0.5 (* im (- im)))))
(* im (* (cos re) (* 0.5 im))))))))
double code(double re, double im) {
double t_0 = (re * re) * (im * im);
double t_1 = -0.25 * t_0;
double t_2 = 0.5 * (im * im);
double tmp;
if (im <= 12200000000000.0) {
tmp = cos(re);
} else if (im <= 4.5e+134) {
tmp = cos(re) + (0.5 * ((1.0 + ((re * re) * -0.5)) * (im * im)));
} else if (im <= 1.4e+154) {
tmp = ((t_1 * t_1) - (t_2 * t_2)) / fma(-0.25, t_0, (0.5 * (im * -im)));
} else {
tmp = im * (cos(re) * (0.5 * im));
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(re * re) * Float64(im * im)) t_1 = Float64(-0.25 * t_0) t_2 = Float64(0.5 * Float64(im * im)) tmp = 0.0 if (im <= 12200000000000.0) tmp = cos(re); elseif (im <= 4.5e+134) tmp = Float64(cos(re) + Float64(0.5 * Float64(Float64(1.0 + Float64(Float64(re * re) * -0.5)) * Float64(im * im)))); elseif (im <= 1.4e+154) tmp = Float64(Float64(Float64(t_1 * t_1) - Float64(t_2 * t_2)) / fma(-0.25, t_0, Float64(0.5 * Float64(im * Float64(-im))))); else tmp = Float64(im * Float64(cos(re) * Float64(0.5 * im))); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.25 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 12200000000000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 4.5e+134], N[(N[Cos[re], $MachinePrecision] + N[(0.5 * N[(N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.4e+154], N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(-0.25 * t$95$0 + N[(0.5 * N[(im * (-im)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(re \cdot re\right) \cdot \left(im \cdot im\right)\\
t_1 := -0.25 \cdot t_0\\
t_2 := 0.5 \cdot \left(im \cdot im\right)\\
\mathbf{if}\;im \leq 12200000000000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+134}:\\
\;\;\;\;\cos re + 0.5 \cdot \left(\left(1 + \left(re \cdot re\right) \cdot -0.5\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\frac{t_1 \cdot t_1 - t_2 \cdot t_2}{\mathsf{fma}\left(-0.25, t_0, 0.5 \cdot \left(im \cdot \left(-im\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1.22e13Initial program 100.0%
Taylor expanded in im around 0 66.6%
if 1.22e13 < im < 4.4999999999999997e134Initial program 100.0%
Taylor expanded in im around 0 4.8%
Simplified4.8%
Taylor expanded in re around 0 27.4%
*-commutative27.4%
associate-*r*27.4%
distribute-lft1-in27.4%
unpow227.4%
unpow227.4%
Simplified27.4%
if 4.4999999999999997e134 < im < 1.4e154Initial program 100.0%
Taylor expanded in im around 0 10.5%
Simplified10.5%
Taylor expanded in im around inf 10.5%
*-commutative10.5%
*-commutative10.5%
unpow210.5%
associate-*r*10.5%
associate-*r*10.5%
*-commutative10.5%
associate-*l*10.5%
Simplified10.5%
Taylor expanded in re around 0 8.4%
*-commutative8.4%
associate-*r*8.4%
distribute-rgt-out8.4%
unpow28.4%
Simplified8.4%
associate-*r*8.4%
distribute-lft-in8.4%
flip-+80.0%
*-commutative80.0%
associate-*l*80.0%
*-commutative80.0%
associate-*l*80.0%
*-commutative80.0%
*-commutative80.0%
*-commutative80.0%
associate-*l*80.0%
*-commutative80.0%
fma-neg80.0%
Applied egg-rr80.0%
if 1.4e154 < 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%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification64.4%
(FPCore (re im)
:precision binary64
(if (<= im 12200000000000.0)
(cos re)
(if (<= im 3.5e+141)
(+ (cos re) (* 0.5 (* (+ 1.0 (* (* re re) -0.5)) (* im im))))
(* im (* (cos re) (* 0.5 im))))))
double code(double re, double im) {
double tmp;
if (im <= 12200000000000.0) {
tmp = cos(re);
} else if (im <= 3.5e+141) {
tmp = cos(re) + (0.5 * ((1.0 + ((re * re) * -0.5)) * (im * im)));
} else {
tmp = im * (cos(re) * (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 <= 12200000000000.0d0) then
tmp = cos(re)
else if (im <= 3.5d+141) then
tmp = cos(re) + (0.5d0 * ((1.0d0 + ((re * re) * (-0.5d0))) * (im * im)))
else
tmp = im * (cos(re) * (0.5d0 * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 12200000000000.0) {
tmp = Math.cos(re);
} else if (im <= 3.5e+141) {
tmp = Math.cos(re) + (0.5 * ((1.0 + ((re * re) * -0.5)) * (im * im)));
} else {
tmp = im * (Math.cos(re) * (0.5 * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 12200000000000.0: tmp = math.cos(re) elif im <= 3.5e+141: tmp = math.cos(re) + (0.5 * ((1.0 + ((re * re) * -0.5)) * (im * im))) else: tmp = im * (math.cos(re) * (0.5 * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 12200000000000.0) tmp = cos(re); elseif (im <= 3.5e+141) tmp = Float64(cos(re) + Float64(0.5 * Float64(Float64(1.0 + Float64(Float64(re * re) * -0.5)) * Float64(im * im)))); else tmp = Float64(im * Float64(cos(re) * Float64(0.5 * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 12200000000000.0) tmp = cos(re); elseif (im <= 3.5e+141) tmp = cos(re) + (0.5 * ((1.0 + ((re * re) * -0.5)) * (im * im))); else tmp = im * (cos(re) * (0.5 * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 12200000000000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 3.5e+141], N[(N[Cos[re], $MachinePrecision] + N[(0.5 * N[(N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 12200000000000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 3.5 \cdot 10^{+141}:\\
\;\;\;\;\cos re + 0.5 \cdot \left(\left(1 + \left(re \cdot re\right) \cdot -0.5\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1.22e13Initial program 100.0%
Taylor expanded in im around 0 66.6%
if 1.22e13 < im < 3.5e141Initial program 100.0%
Taylor expanded in im around 0 4.9%
Simplified4.9%
Taylor expanded in re around 0 26.8%
*-commutative26.8%
associate-*r*26.8%
distribute-lft1-in26.8%
unpow226.8%
unpow226.8%
Simplified26.8%
if 3.5e141 < im Initial program 100.0%
Taylor expanded in im around 0 87.3%
Simplified87.3%
Taylor expanded in im around inf 87.3%
*-commutative87.3%
*-commutative87.3%
unpow287.3%
associate-*r*87.3%
associate-*r*87.3%
*-commutative87.3%
associate-*l*87.3%
Simplified87.3%
Final simplification63.1%
(FPCore (re im)
:precision binary64
(if (<= im 12200000000000.0)
(cos re)
(if (<= im 1.55e+135)
(* im (* im (+ 0.5 (* -0.25 (* re re)))))
(* im (* (cos re) (* 0.5 im))))))
double code(double re, double im) {
double tmp;
if (im <= 12200000000000.0) {
tmp = cos(re);
} else if (im <= 1.55e+135) {
tmp = im * (im * (0.5 + (-0.25 * (re * re))));
} else {
tmp = im * (cos(re) * (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 <= 12200000000000.0d0) then
tmp = cos(re)
else if (im <= 1.55d+135) then
tmp = im * (im * (0.5d0 + ((-0.25d0) * (re * re))))
else
tmp = im * (cos(re) * (0.5d0 * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 12200000000000.0) {
tmp = Math.cos(re);
} else if (im <= 1.55e+135) {
tmp = im * (im * (0.5 + (-0.25 * (re * re))));
} else {
tmp = im * (Math.cos(re) * (0.5 * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 12200000000000.0: tmp = math.cos(re) elif im <= 1.55e+135: tmp = im * (im * (0.5 + (-0.25 * (re * re)))) else: tmp = im * (math.cos(re) * (0.5 * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 12200000000000.0) tmp = cos(re); elseif (im <= 1.55e+135) tmp = Float64(im * Float64(im * Float64(0.5 + Float64(-0.25 * Float64(re * re))))); else tmp = Float64(im * Float64(cos(re) * Float64(0.5 * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 12200000000000.0) tmp = cos(re); elseif (im <= 1.55e+135) tmp = im * (im * (0.5 + (-0.25 * (re * re)))); else tmp = im * (cos(re) * (0.5 * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 12200000000000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.55e+135], N[(im * N[(im * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 12200000000000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\
\;\;\;\;im \cdot \left(im \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1.22e13Initial program 100.0%
Taylor expanded in im around 0 66.6%
if 1.22e13 < im < 1.55000000000000011e135Initial program 100.0%
Taylor expanded in im around 0 4.8%
Simplified4.8%
Taylor expanded in im around inf 4.8%
*-commutative4.8%
*-commutative4.8%
unpow24.8%
associate-*r*4.8%
associate-*r*4.8%
*-commutative4.8%
associate-*l*4.8%
Simplified4.8%
Taylor expanded in re around 0 27.4%
*-commutative27.4%
associate-*r*27.4%
distribute-rgt-out27.4%
unpow227.4%
Simplified27.4%
if 1.55000000000000011e135 < im Initial program 100.0%
Taylor expanded in im around 0 84.6%
Simplified84.6%
Taylor expanded in im around inf 84.6%
*-commutative84.6%
*-commutative84.6%
unpow284.6%
associate-*r*84.6%
associate-*r*84.6%
*-commutative84.6%
associate-*l*84.6%
Simplified84.6%
Final simplification63.1%
(FPCore (re im)
:precision binary64
(if (<= im 12200000000000.0)
(cos re)
(if (<= im 1.55e+135)
(* im (* im (+ 0.5 (* -0.25 (* re re)))))
(+ 1.0 (* im (* 0.5 im))))))
double code(double re, double im) {
double tmp;
if (im <= 12200000000000.0) {
tmp = cos(re);
} else if (im <= 1.55e+135) {
tmp = im * (im * (0.5 + (-0.25 * (re * re))));
} else {
tmp = 1.0 + (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 <= 12200000000000.0d0) then
tmp = cos(re)
else if (im <= 1.55d+135) then
tmp = im * (im * (0.5d0 + ((-0.25d0) * (re * re))))
else
tmp = 1.0d0 + (im * (0.5d0 * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 12200000000000.0) {
tmp = Math.cos(re);
} else if (im <= 1.55e+135) {
tmp = im * (im * (0.5 + (-0.25 * (re * re))));
} else {
tmp = 1.0 + (im * (0.5 * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 12200000000000.0: tmp = math.cos(re) elif im <= 1.55e+135: tmp = im * (im * (0.5 + (-0.25 * (re * re)))) else: tmp = 1.0 + (im * (0.5 * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 12200000000000.0) tmp = cos(re); elseif (im <= 1.55e+135) tmp = Float64(im * Float64(im * Float64(0.5 + Float64(-0.25 * Float64(re * re))))); else tmp = Float64(1.0 + Float64(im * Float64(0.5 * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 12200000000000.0) tmp = cos(re); elseif (im <= 1.55e+135) tmp = im * (im * (0.5 + (-0.25 * (re * re)))); else tmp = 1.0 + (im * (0.5 * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 12200000000000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.55e+135], N[(im * N[(im * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 12200000000000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\
\;\;\;\;im \cdot \left(im \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + im \cdot \left(0.5 \cdot im\right)\\
\end{array}
\end{array}
if im < 1.22e13Initial program 100.0%
Taylor expanded in im around 0 66.6%
if 1.22e13 < im < 1.55000000000000011e135Initial program 100.0%
Taylor expanded in im around 0 4.8%
Simplified4.8%
Taylor expanded in im around inf 4.8%
*-commutative4.8%
*-commutative4.8%
unpow24.8%
associate-*r*4.8%
associate-*r*4.8%
*-commutative4.8%
associate-*l*4.8%
Simplified4.8%
Taylor expanded in re around 0 27.4%
*-commutative27.4%
associate-*r*27.4%
distribute-rgt-out27.4%
unpow227.4%
Simplified27.4%
if 1.55000000000000011e135 < im Initial program 100.0%
Taylor expanded in im around 0 84.6%
Simplified84.6%
Taylor expanded in re around 0 67.3%
*-commutative67.3%
unpow267.3%
associate-*l*67.3%
Simplified67.3%
Final simplification61.1%
(FPCore (re im) :precision binary64 (if (or (<= im 9.2e-7) (not (<= im 1.55e+135))) (+ 1.0 (* im (* 0.5 im))) (* im (* im (+ 0.5 (* -0.25 (* re re)))))))
double code(double re, double im) {
double tmp;
if ((im <= 9.2e-7) || !(im <= 1.55e+135)) {
tmp = 1.0 + (im * (0.5 * im));
} else {
tmp = im * (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 <= 9.2d-7) .or. (.not. (im <= 1.55d+135))) then
tmp = 1.0d0 + (im * (0.5d0 * im))
else
tmp = im * (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 <= 9.2e-7) || !(im <= 1.55e+135)) {
tmp = 1.0 + (im * (0.5 * im));
} else {
tmp = im * (im * (0.5 + (-0.25 * (re * re))));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 9.2e-7) or not (im <= 1.55e+135): tmp = 1.0 + (im * (0.5 * im)) else: tmp = im * (im * (0.5 + (-0.25 * (re * re)))) return tmp
function code(re, im) tmp = 0.0 if ((im <= 9.2e-7) || !(im <= 1.55e+135)) tmp = Float64(1.0 + Float64(im * Float64(0.5 * im))); else tmp = Float64(im * Float64(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 <= 9.2e-7) || ~((im <= 1.55e+135))) tmp = 1.0 + (im * (0.5 * im)); else tmp = im * (im * (0.5 + (-0.25 * (re * re)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 9.2e-7], N[Not[LessEqual[im, 1.55e+135]], $MachinePrecision]], N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(im * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 9.2 \cdot 10^{-7} \lor \neg \left(im \leq 1.55 \cdot 10^{+135}\right):\\
\;\;\;\;1 + im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(im \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\right)\\
\end{array}
\end{array}
if im < 9.1999999999999998e-7 or 1.55000000000000011e135 < im Initial program 100.0%
Taylor expanded in im around 0 84.3%
Simplified84.3%
Taylor expanded in re around 0 56.0%
*-commutative56.0%
unpow256.0%
associate-*l*56.0%
Simplified56.0%
if 9.1999999999999998e-7 < im < 1.55000000000000011e135Initial program 100.0%
Taylor expanded in im around 0 5.6%
Simplified5.6%
Taylor expanded in im around inf 4.9%
*-commutative4.9%
*-commutative4.9%
unpow24.9%
associate-*r*4.9%
associate-*r*4.9%
*-commutative4.9%
associate-*l*4.9%
Simplified4.9%
Taylor expanded in re around 0 24.9%
*-commutative24.9%
associate-*r*24.9%
distribute-rgt-out24.9%
unpow224.9%
Simplified24.9%
Final simplification51.2%
(FPCore (re im) :precision binary64 (if (or (<= im 12200000000000.0) (not (<= im 1.55e+135))) (+ 1.0 (* im (* 0.5 im))) (* -0.25 (* re (* re (* im im))))))
double code(double re, double im) {
double tmp;
if ((im <= 12200000000000.0) || !(im <= 1.55e+135)) {
tmp = 1.0 + (im * (0.5 * im));
} else {
tmp = -0.25 * (re * (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 <= 12200000000000.0d0) .or. (.not. (im <= 1.55d+135))) then
tmp = 1.0d0 + (im * (0.5d0 * im))
else
tmp = (-0.25d0) * (re * (re * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 12200000000000.0) || !(im <= 1.55e+135)) {
tmp = 1.0 + (im * (0.5 * im));
} else {
tmp = -0.25 * (re * (re * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 12200000000000.0) or not (im <= 1.55e+135): tmp = 1.0 + (im * (0.5 * im)) else: tmp = -0.25 * (re * (re * (im * im))) return tmp
function code(re, im) tmp = 0.0 if ((im <= 12200000000000.0) || !(im <= 1.55e+135)) tmp = Float64(1.0 + Float64(im * Float64(0.5 * im))); else tmp = Float64(-0.25 * Float64(re * Float64(re * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 12200000000000.0) || ~((im <= 1.55e+135))) tmp = 1.0 + (im * (0.5 * im)); else tmp = -0.25 * (re * (re * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 12200000000000.0], N[Not[LessEqual[im, 1.55e+135]], $MachinePrecision]], N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.25 * N[(re * N[(re * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 12200000000000 \lor \neg \left(im \leq 1.55 \cdot 10^{+135}\right):\\
\;\;\;\;1 + im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;-0.25 \cdot \left(re \cdot \left(re \cdot \left(im \cdot im\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.22e13 or 1.55000000000000011e135 < im Initial program 100.0%
Taylor expanded in im around 0 83.0%
Simplified83.0%
Taylor expanded in re around 0 55.0%
*-commutative55.0%
unpow255.0%
associate-*l*55.0%
Simplified55.0%
if 1.22e13 < im < 1.55000000000000011e135Initial program 100.0%
Taylor expanded in im around 0 4.8%
Simplified4.8%
Taylor expanded in im around inf 4.8%
*-commutative4.8%
*-commutative4.8%
unpow24.8%
associate-*r*4.8%
associate-*r*4.8%
*-commutative4.8%
associate-*l*4.8%
Simplified4.8%
Taylor expanded in re around 0 27.4%
*-commutative27.4%
associate-*r*27.4%
distribute-rgt-out27.4%
unpow227.4%
Simplified27.4%
Taylor expanded in re around inf 26.1%
unpow226.1%
unpow226.1%
*-commutative26.1%
associate-*l*26.1%
Simplified26.1%
Final simplification51.0%
(FPCore (re im) :precision binary64 (if (or (<= im 12200000000000.0) (not (<= im 1.05e+135))) (+ 1.0 (* im (* 0.5 im))) (* im (* re (* re (* im -0.25))))))
double code(double re, double im) {
double tmp;
if ((im <= 12200000000000.0) || !(im <= 1.05e+135)) {
tmp = 1.0 + (im * (0.5 * im));
} else {
tmp = im * (re * (re * (im * -0.25)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 12200000000000.0d0) .or. (.not. (im <= 1.05d+135))) then
tmp = 1.0d0 + (im * (0.5d0 * im))
else
tmp = im * (re * (re * (im * (-0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 12200000000000.0) || !(im <= 1.05e+135)) {
tmp = 1.0 + (im * (0.5 * im));
} else {
tmp = im * (re * (re * (im * -0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 12200000000000.0) or not (im <= 1.05e+135): tmp = 1.0 + (im * (0.5 * im)) else: tmp = im * (re * (re * (im * -0.25))) return tmp
function code(re, im) tmp = 0.0 if ((im <= 12200000000000.0) || !(im <= 1.05e+135)) tmp = Float64(1.0 + Float64(im * Float64(0.5 * im))); else tmp = Float64(im * Float64(re * Float64(re * Float64(im * -0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 12200000000000.0) || ~((im <= 1.05e+135))) tmp = 1.0 + (im * (0.5 * im)); else tmp = im * (re * (re * (im * -0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 12200000000000.0], N[Not[LessEqual[im, 1.05e+135]], $MachinePrecision]], N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(re * N[(re * N[(im * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 12200000000000 \lor \neg \left(im \leq 1.05 \cdot 10^{+135}\right):\\
\;\;\;\;1 + im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(re \cdot \left(re \cdot \left(im \cdot -0.25\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.22e13 or 1.05000000000000005e135 < im Initial program 100.0%
Taylor expanded in im around 0 83.0%
Simplified83.0%
Taylor expanded in re around 0 55.0%
*-commutative55.0%
unpow255.0%
associate-*l*55.0%
Simplified55.0%
if 1.22e13 < im < 1.05000000000000005e135Initial program 100.0%
Taylor expanded in im around 0 4.8%
Simplified4.8%
Taylor expanded in im around inf 4.8%
*-commutative4.8%
*-commutative4.8%
unpow24.8%
associate-*r*4.8%
associate-*r*4.8%
*-commutative4.8%
associate-*l*4.8%
Simplified4.8%
Taylor expanded in re around 0 27.4%
*-commutative27.4%
associate-*r*27.4%
distribute-rgt-out27.4%
unpow227.4%
Simplified27.4%
Taylor expanded in re around inf 26.1%
unpow226.1%
associate-*r*26.1%
*-commutative26.1%
associate-*l*26.1%
*-commutative26.1%
Simplified26.1%
Final simplification51.0%
(FPCore (re im) :precision binary64 (if (<= im 310.0) 0.25 (if (<= im 4.5e+149) (+ 0.25 (* (* re re) 0.25)) (* im (* 0.5 im)))))
double code(double re, double im) {
double tmp;
if (im <= 310.0) {
tmp = 0.25;
} else if (im <= 4.5e+149) {
tmp = 0.25 + ((re * re) * 0.25);
} 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 <= 310.0d0) then
tmp = 0.25d0
else if (im <= 4.5d+149) then
tmp = 0.25d0 + ((re * re) * 0.25d0)
else
tmp = im * (0.5d0 * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 310.0) {
tmp = 0.25;
} else if (im <= 4.5e+149) {
tmp = 0.25 + ((re * re) * 0.25);
} else {
tmp = im * (0.5 * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 310.0: tmp = 0.25 elif im <= 4.5e+149: tmp = 0.25 + ((re * re) * 0.25) else: tmp = im * (0.5 * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 310.0) tmp = 0.25; elseif (im <= 4.5e+149) tmp = Float64(0.25 + Float64(Float64(re * re) * 0.25)); else tmp = Float64(im * Float64(0.5 * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 310.0) tmp = 0.25; elseif (im <= 4.5e+149) tmp = 0.25 + ((re * re) * 0.25); else tmp = im * (0.5 * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 310.0], 0.25, If[LessEqual[im, 4.5e+149], N[(0.25 + N[(N[(re * re), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision], N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 310:\\
\;\;\;\;0.25\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+149}:\\
\;\;\;\;0.25 + \left(re \cdot re\right) \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\end{array}
\end{array}
if im < 310Initial program 100.0%
Applied egg-rr9.9%
Taylor expanded in re around 0 10.0%
if 310 < im < 4.49999999999999982e149Initial program 100.0%
Applied egg-rr2.3%
Taylor expanded in re around 0 14.0%
*-commutative14.0%
unpow214.0%
Simplified14.0%
if 4.49999999999999982e149 < im Initial program 100.0%
Taylor expanded in im around 0 93.2%
Simplified93.2%
Taylor expanded in im around inf 93.2%
*-commutative93.2%
*-commutative93.2%
unpow293.2%
associate-*r*93.2%
associate-*r*93.2%
*-commutative93.2%
associate-*l*93.2%
Simplified93.2%
Taylor expanded in re around 0 74.0%
Final simplification17.1%
(FPCore (re im) :precision binary64 (if (<= re 7e+166) (+ 1.0 (* im (* 0.5 im))) (+ 0.25 (* (* re re) 0.25))))
double code(double re, double im) {
double tmp;
if (re <= 7e+166) {
tmp = 1.0 + (im * (0.5 * im));
} else {
tmp = 0.25 + ((re * 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 <= 7d+166) then
tmp = 1.0d0 + (im * (0.5d0 * im))
else
tmp = 0.25d0 + ((re * re) * 0.25d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 7e+166) {
tmp = 1.0 + (im * (0.5 * im));
} else {
tmp = 0.25 + ((re * re) * 0.25);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 7e+166: tmp = 1.0 + (im * (0.5 * im)) else: tmp = 0.25 + ((re * re) * 0.25) return tmp
function code(re, im) tmp = 0.0 if (re <= 7e+166) tmp = Float64(1.0 + Float64(im * Float64(0.5 * im))); else tmp = Float64(0.25 + Float64(Float64(re * re) * 0.25)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 7e+166) tmp = 1.0 + (im * (0.5 * im)); else tmp = 0.25 + ((re * re) * 0.25); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 7e+166], N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 + N[(N[(re * re), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 7 \cdot 10^{+166}:\\
\;\;\;\;1 + im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 + \left(re \cdot re\right) \cdot 0.25\\
\end{array}
\end{array}
if re < 6.9999999999999997e166Initial program 100.0%
Taylor expanded in im around 0 71.8%
Simplified71.8%
Taylor expanded in re around 0 51.5%
*-commutative51.5%
unpow251.5%
associate-*l*51.5%
Simplified51.5%
if 6.9999999999999997e166 < re Initial program 100.0%
Applied egg-rr6.0%
Taylor expanded in re around 0 18.9%
*-commutative18.9%
unpow218.9%
Simplified18.9%
Final simplification47.9%
(FPCore (re im) :precision binary64 (if (<= im 9.2e-7) 0.25 (* im (* 0.5 im))))
double code(double re, double im) {
double tmp;
if (im <= 9.2e-7) {
tmp = 0.25;
} 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 <= 9.2d-7) then
tmp = 0.25d0
else
tmp = im * (0.5d0 * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 9.2e-7) {
tmp = 0.25;
} else {
tmp = im * (0.5 * im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 9.2e-7: tmp = 0.25 else: tmp = im * (0.5 * im) return tmp
function code(re, im) tmp = 0.0 if (im <= 9.2e-7) tmp = 0.25; else tmp = Float64(im * Float64(0.5 * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 9.2e-7) tmp = 0.25; else tmp = im * (0.5 * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 9.2e-7], 0.25, N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 9.2 \cdot 10^{-7}:\\
\;\;\;\;0.25\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\end{array}
\end{array}
if im < 9.1999999999999998e-7Initial program 100.0%
Applied egg-rr10.0%
Taylor expanded in re around 0 10.0%
if 9.1999999999999998e-7 < im Initial program 100.0%
Taylor expanded in im around 0 38.8%
Simplified38.8%
Taylor expanded in im around inf 38.4%
*-commutative38.4%
*-commutative38.4%
unpow238.4%
associate-*r*38.4%
associate-*r*38.4%
*-commutative38.4%
associate-*l*38.4%
Simplified38.4%
Taylor expanded in re around 0 30.0%
Final simplification15.4%
(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.9%
Taylor expanded in re around 0 8.0%
Final simplification8.0%
herbie shell --seed 2023271
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))