
(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 16 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%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= (+ (exp (- im)) (exp im)) 4.0)
(*
t_0
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(* t_0 (+ (exp im) 3.0)))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double tmp;
if ((exp(-im) + exp(im)) <= 4.0) {
tmp = t_0 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (exp(im) + 3.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) :: tmp
t_0 = 0.5d0 * cos(re)
if ((exp(-im) + exp(im)) <= 4.0d0) then
tmp = t_0 * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = t_0 * (exp(im) + 3.0d0)
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 ((Math.exp(-im) + Math.exp(im)) <= 4.0) {
tmp = t_0 * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (Math.exp(im) + 3.0);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) tmp = 0 if (math.exp(-im) + math.exp(im)) <= 4.0: tmp = t_0 * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = t_0 * (math.exp(im) + 3.0) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) tmp = 0.0 if (Float64(exp(Float64(-im)) + exp(im)) <= 4.0) tmp = Float64(t_0 * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(t_0 * Float64(exp(im) + 3.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); tmp = 0.0; if ((exp(-im) + exp(im)) <= 4.0) tmp = t_0 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = t_0 * (exp(im) + 3.0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision], 4.0], N[(t$95$0 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathbf{if}\;e^{-im} + e^{im} \leq 4:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + 3\right)\\
\end{array}
\end{array}
if (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 4Initial program 100.0%
Taylor expanded in im around 0 99.7%
if 4 < (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
Applied egg-rr47.0%
Final simplification71.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= (+ (exp (- im)) (exp im)) 4.0)
(*
t_0
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))
(* t_0 (+ (exp im) 3.0)))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double tmp;
if ((exp(-im) + exp(im)) <= 4.0) {
tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
} else {
tmp = t_0 * (exp(im) + 3.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) :: tmp
t_0 = 0.5d0 * cos(re)
if ((exp(-im) + exp(im)) <= 4.0d0) then
tmp = t_0 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))))
else
tmp = t_0 * (exp(im) + 3.0d0)
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 ((Math.exp(-im) + Math.exp(im)) <= 4.0) {
tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
} else {
tmp = t_0 * (Math.exp(im) + 3.0);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) tmp = 0 if (math.exp(-im) + math.exp(im)) <= 4.0: tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))) else: tmp = t_0 * (math.exp(im) + 3.0) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) tmp = 0.0 if (Float64(exp(Float64(-im)) + exp(im)) <= 4.0) tmp = Float64(t_0 * Float64(Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))))); else tmp = Float64(t_0 * Float64(exp(im) + 3.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); tmp = 0.0; if ((exp(-im) + exp(im)) <= 4.0) tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))); else tmp = t_0 * (exp(im) + 3.0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision], 4.0], N[(t$95$0 * N[(N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathbf{if}\;e^{-im} + e^{im} \leq 4:\\
\;\;\;\;t\_0 \cdot \left(\left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + 3\right)\\
\end{array}
\end{array}
if (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 4Initial program 100.0%
Taylor expanded in im around 0 99.7%
Taylor expanded in im around 0 99.7%
*-commutative99.7%
Simplified99.7%
if 4 < (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
Applied egg-rr47.0%
Final simplification71.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
(t_1 (* 0.5 (cos re))))
(if (<= im 0.0023)
(*
t_1
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 t_0)))
(if (<= im 6.4e+100)
(* 0.5 (+ (exp (- im)) (exp im)))
(* t_1 (+ 4.0 t_0))))))
double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * cos(re);
double tmp;
if (im <= 0.0023) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 6.4e+100) {
tmp = 0.5 * (exp(-im) + exp(im));
} else {
tmp = t_1 * (4.0 + 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 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
t_1 = 0.5d0 * cos(re)
if (im <= 0.0023d0) then
tmp = t_1 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + t_0))
else if (im <= 6.4d+100) then
tmp = 0.5d0 * (exp(-im) + exp(im))
else
tmp = t_1 * (4.0d0 + t_0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * Math.cos(re);
double tmp;
if (im <= 0.0023) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 6.4e+100) {
tmp = 0.5 * (Math.exp(-im) + Math.exp(im));
} else {
tmp = t_1 * (4.0 + t_0);
}
return tmp;
}
def code(re, im): t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) t_1 = 0.5 * math.cos(re) tmp = 0 if im <= 0.0023: tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)) elif im <= 6.4e+100: tmp = 0.5 * (math.exp(-im) + math.exp(im)) else: tmp = t_1 * (4.0 + t_0) return tmp
function code(re, im) t_0 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) t_1 = Float64(0.5 * cos(re)) tmp = 0.0 if (im <= 0.0023) tmp = Float64(t_1 * Float64(Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) + Float64(1.0 + t_0))); elseif (im <= 6.4e+100) tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(t_1 * Float64(4.0 + t_0)); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); t_1 = 0.5 * cos(re); tmp = 0.0; if (im <= 0.0023) tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)); elseif (im <= 6.4e+100) tmp = 0.5 * (exp(-im) + exp(im)); else tmp = t_1 * (4.0 + t_0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0023], N[(t$95$1 * N[(N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.4e+100], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(4.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
t_1 := 0.5 \cdot \cos re\\
\mathbf{if}\;im \leq 0.0023:\\
\;\;\;\;t\_1 \cdot \left(\left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right) + \left(1 + t\_0\right)\right)\\
\mathbf{elif}\;im \leq 6.4 \cdot 10^{+100}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(4 + t\_0\right)\\
\end{array}
\end{array}
if im < 0.0023Initial program 100.0%
Taylor expanded in im around 0 91.5%
Taylor expanded in im around 0 61.3%
*-commutative61.3%
Simplified61.3%
if 0.0023 < im < 6.3999999999999998e100Initial program 100.0%
Taylor expanded in re around 0 58.1%
if 6.3999999999999998e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification67.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
(t_1 (* 0.5 (cos re)))
(t_2
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(if (<= im 0.0023)
(* t_1 (+ t_2 (+ 1.0 t_0)))
(if (<= im 6.4e+100) (* 0.5 (+ (exp im) t_2)) (* t_1 (+ 4.0 t_0))))))
double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * cos(re);
double t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 0.0023) {
tmp = t_1 * (t_2 + (1.0 + t_0));
} else if (im <= 6.4e+100) {
tmp = 0.5 * (exp(im) + t_2);
} else {
tmp = t_1 * (4.0 + 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 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
t_1 = 0.5d0 * cos(re)
t_2 = 1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))
if (im <= 0.0023d0) then
tmp = t_1 * (t_2 + (1.0d0 + t_0))
else if (im <= 6.4d+100) then
tmp = 0.5d0 * (exp(im) + t_2)
else
tmp = t_1 * (4.0d0 + t_0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * Math.cos(re);
double t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 0.0023) {
tmp = t_1 * (t_2 + (1.0 + t_0));
} else if (im <= 6.4e+100) {
tmp = 0.5 * (Math.exp(im) + t_2);
} else {
tmp = t_1 * (4.0 + t_0);
}
return tmp;
}
def code(re, im): t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) t_1 = 0.5 * math.cos(re) t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) tmp = 0 if im <= 0.0023: tmp = t_1 * (t_2 + (1.0 + t_0)) elif im <= 6.4e+100: tmp = 0.5 * (math.exp(im) + t_2) else: tmp = t_1 * (4.0 + t_0) return tmp
function code(re, im) t_0 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) t_1 = Float64(0.5 * cos(re)) t_2 = Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) tmp = 0.0 if (im <= 0.0023) tmp = Float64(t_1 * Float64(t_2 + Float64(1.0 + t_0))); elseif (im <= 6.4e+100) tmp = Float64(0.5 * Float64(exp(im) + t_2)); else tmp = Float64(t_1 * Float64(4.0 + t_0)); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); t_1 = 0.5 * cos(re); t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)); tmp = 0.0; if (im <= 0.0023) tmp = t_1 * (t_2 + (1.0 + t_0)); elseif (im <= 6.4e+100) tmp = 0.5 * (exp(im) + t_2); else tmp = t_1 * (4.0 + t_0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0023], N[(t$95$1 * N[(t$95$2 + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.4e+100], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(4.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
t_1 := 0.5 \cdot \cos re\\
t_2 := 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\\
\mathbf{if}\;im \leq 0.0023:\\
\;\;\;\;t\_1 \cdot \left(t\_2 + \left(1 + t\_0\right)\right)\\
\mathbf{elif}\;im \leq 6.4 \cdot 10^{+100}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + t\_2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(4 + t\_0\right)\\
\end{array}
\end{array}
if im < 0.0023Initial program 100.0%
Taylor expanded in im around 0 91.5%
Taylor expanded in im around 0 61.3%
*-commutative61.3%
Simplified61.3%
if 0.0023 < im < 6.3999999999999998e100Initial program 100.0%
Taylor expanded in re around 0 58.1%
Taylor expanded in im around 0 58.1%
if 6.3999999999999998e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification67.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re)))
(t_1
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(if (<= im 0.0023)
(* t_0 (+ t_1 (+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 6.4e+100)
(* 0.5 (+ (exp im) t_1))
(*
t_0
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 0.0023) {
tmp = t_0 * (t_1 + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 6.4e+100) {
tmp = 0.5 * (exp(im) + t_1);
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * cos(re)
t_1 = 1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))
if (im <= 0.0023d0) then
tmp = t_0 * (t_1 + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 6.4d+100) then
tmp = 0.5d0 * (exp(im) + t_1)
else
tmp = t_0 * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 0.0023) {
tmp = t_0 * (t_1 + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 6.4e+100) {
tmp = 0.5 * (Math.exp(im) + t_1);
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) tmp = 0 if im <= 0.0023: tmp = t_0 * (t_1 + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 6.4e+100: tmp = 0.5 * (math.exp(im) + t_1) else: tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) tmp = 0.0 if (im <= 0.0023) tmp = Float64(t_0 * Float64(t_1 + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (im <= 6.4e+100) tmp = Float64(0.5 * Float64(exp(im) + t_1)); else tmp = Float64(t_0 * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)); tmp = 0.0; if (im <= 0.0023) tmp = t_0 * (t_1 + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 6.4e+100) tmp = 0.5 * (exp(im) + t_1); else tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0023], N[(t$95$0 * N[(t$95$1 + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.4e+100], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
t_1 := 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\\
\mathbf{if}\;im \leq 0.0023:\\
\;\;\;\;t\_0 \cdot \left(t\_1 + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 6.4 \cdot 10^{+100}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 0.0023Initial program 100.0%
Taylor expanded in im around 0 91.5%
Taylor expanded in im around 0 91.3%
if 0.0023 < im < 6.3999999999999998e100Initial program 100.0%
Taylor expanded in re around 0 58.1%
Taylor expanded in im around 0 58.1%
if 6.3999999999999998e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification90.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re)))
(t_1
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(if (<= im 0.0022)
(* t_0 (+ t_1 (+ im 1.0)))
(if (<= im 6.4e+100)
(* 0.5 (+ (exp im) t_1))
(*
t_0
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 0.0022) {
tmp = t_0 * (t_1 + (im + 1.0));
} else if (im <= 6.4e+100) {
tmp = 0.5 * (exp(im) + t_1);
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * cos(re)
t_1 = 1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))
if (im <= 0.0022d0) then
tmp = t_0 * (t_1 + (im + 1.0d0))
else if (im <= 6.4d+100) then
tmp = 0.5d0 * (exp(im) + t_1)
else
tmp = t_0 * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 0.0022) {
tmp = t_0 * (t_1 + (im + 1.0));
} else if (im <= 6.4e+100) {
tmp = 0.5 * (Math.exp(im) + t_1);
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) tmp = 0 if im <= 0.0022: tmp = t_0 * (t_1 + (im + 1.0)) elif im <= 6.4e+100: tmp = 0.5 * (math.exp(im) + t_1) else: tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) tmp = 0.0 if (im <= 0.0022) tmp = Float64(t_0 * Float64(t_1 + Float64(im + 1.0))); elseif (im <= 6.4e+100) tmp = Float64(0.5 * Float64(exp(im) + t_1)); else tmp = Float64(t_0 * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)); tmp = 0.0; if (im <= 0.0022) tmp = t_0 * (t_1 + (im + 1.0)); elseif (im <= 6.4e+100) tmp = 0.5 * (exp(im) + t_1); else tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0022], N[(t$95$0 * N[(t$95$1 + N[(im + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.4e+100], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
t_1 := 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\\
\mathbf{if}\;im \leq 0.0022:\\
\;\;\;\;t\_0 \cdot \left(t\_1 + \left(im + 1\right)\right)\\
\mathbf{elif}\;im \leq 6.4 \cdot 10^{+100}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 0.00220000000000000013Initial program 100.0%
Taylor expanded in im around 0 91.5%
Taylor expanded in im around 0 91.1%
if 0.00220000000000000013 < im < 6.3999999999999998e100Initial program 100.0%
Taylor expanded in re around 0 58.1%
Taylor expanded in im around 0 58.1%
if 6.3999999999999998e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification89.8%
(FPCore (re im)
:precision binary64
(if (<= im 0.0023)
(cos re)
(if (<= im 6.4e+100)
(*
0.5
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(*
(* 0.5 (cos re))
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (im <= 0.0023) {
tmp = cos(re);
} else if (im <= 6.4e+100) {
tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = (0.5 * cos(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.0023d0) then
tmp = cos(re)
else if (im <= 6.4d+100) then
tmp = 0.5d0 * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = (0.5d0 * cos(re)) * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0023) {
tmp = Math.cos(re);
} else if (im <= 6.4e+100) {
tmp = 0.5 * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = (0.5 * Math.cos(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0023: tmp = math.cos(re) elif im <= 6.4e+100: tmp = 0.5 * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = (0.5 * math.cos(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0023) tmp = cos(re); elseif (im <= 6.4e+100) tmp = Float64(0.5 * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0023) tmp = cos(re); elseif (im <= 6.4e+100) tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = (0.5 * cos(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0023], N[Cos[re], $MachinePrecision], If[LessEqual[im, 6.4e+100], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0023:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 6.4 \cdot 10^{+100}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 0.0023Initial program 100.0%
Taylor expanded in im around 0 62.0%
if 0.0023 < im < 6.3999999999999998e100Initial program 100.0%
Taylor expanded in re around 0 58.1%
Taylor expanded in im around 0 58.1%
if 6.3999999999999998e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification67.7%
(FPCore (re im)
:precision binary64
(if (<= im 2.45)
(cos re)
(if (<= im 1.86e+154)
(+ (* 0.5 (exp im)) 1.5)
(* (* 0.5 (cos re)) (+ 4.0 (* im (+ 1.0 (* 0.5 im))))))))
double code(double re, double im) {
double tmp;
if (im <= 2.45) {
tmp = cos(re);
} else if (im <= 1.86e+154) {
tmp = (0.5 * exp(im)) + 1.5;
} else {
tmp = (0.5 * cos(re)) * (4.0 + (im * (1.0 + (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 <= 2.45d0) then
tmp = cos(re)
else if (im <= 1.86d+154) then
tmp = (0.5d0 * exp(im)) + 1.5d0
else
tmp = (0.5d0 * cos(re)) * (4.0d0 + (im * (1.0d0 + (0.5d0 * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.45) {
tmp = Math.cos(re);
} else if (im <= 1.86e+154) {
tmp = (0.5 * Math.exp(im)) + 1.5;
} else {
tmp = (0.5 * Math.cos(re)) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.45: tmp = math.cos(re) elif im <= 1.86e+154: tmp = (0.5 * math.exp(im)) + 1.5 else: tmp = (0.5 * math.cos(re)) * (4.0 + (im * (1.0 + (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.45) tmp = cos(re); elseif (im <= 1.86e+154) tmp = Float64(Float64(0.5 * exp(im)) + 1.5); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.45) tmp = cos(re); elseif (im <= 1.86e+154) tmp = (0.5 * exp(im)) + 1.5; else tmp = (0.5 * cos(re)) * (4.0 + (im * (1.0 + (0.5 * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.45], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.86e+154], N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 1.5), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.45:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.86 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot e^{im} + 1.5\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 2.4500000000000002Initial program 100.0%
Taylor expanded in im around 0 62.0%
if 2.4500000000000002 < im < 1.86000000000000014e154Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 55.2%
+-commutative55.2%
distribute-lft-in55.2%
metadata-eval55.2%
Simplified55.2%
if 1.86000000000000014e154 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
(FPCore (re im)
:precision binary64
(if (<= im 2.15)
(cos re)
(if (<= im 1.2e+144)
(+ (* 0.5 (exp im)) 1.5)
(if (<= im 1.4e+177)
(* (+ 4.0 (* im (+ 1.0 (* 0.5 im)))) (+ 0.5 (* -0.25 (* re re))))
(+ (* im (+ 0.5 (* im 0.25))) 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 2.15) {
tmp = cos(re);
} else if (im <= 1.2e+144) {
tmp = (0.5 * exp(im)) + 1.5;
} else if (im <= 1.4e+177) {
tmp = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re)));
} else {
tmp = (im * (0.5 + (im * 0.25))) + 2.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.15d0) then
tmp = cos(re)
else if (im <= 1.2d+144) then
tmp = (0.5d0 * exp(im)) + 1.5d0
else if (im <= 1.4d+177) then
tmp = (4.0d0 + (im * (1.0d0 + (0.5d0 * im)))) * (0.5d0 + ((-0.25d0) * (re * re)))
else
tmp = (im * (0.5d0 + (im * 0.25d0))) + 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.15) {
tmp = Math.cos(re);
} else if (im <= 1.2e+144) {
tmp = (0.5 * Math.exp(im)) + 1.5;
} else if (im <= 1.4e+177) {
tmp = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re)));
} else {
tmp = (im * (0.5 + (im * 0.25))) + 2.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.15: tmp = math.cos(re) elif im <= 1.2e+144: tmp = (0.5 * math.exp(im)) + 1.5 elif im <= 1.4e+177: tmp = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re))) else: tmp = (im * (0.5 + (im * 0.25))) + 2.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 2.15) tmp = cos(re); elseif (im <= 1.2e+144) tmp = Float64(Float64(0.5 * exp(im)) + 1.5); elseif (im <= 1.4e+177) tmp = Float64(Float64(4.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))); else tmp = Float64(Float64(im * Float64(0.5 + Float64(im * 0.25))) + 2.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.15) tmp = cos(re); elseif (im <= 1.2e+144) tmp = (0.5 * exp(im)) + 1.5; elseif (im <= 1.4e+177) tmp = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re))); else tmp = (im * (0.5 + (im * 0.25))) + 2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.15], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.2e+144], N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 1.5), $MachinePrecision], If[LessEqual[im, 1.4e+177], N[(N[(4.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.15:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+144}:\\
\;\;\;\;0.5 \cdot e^{im} + 1.5\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{+177}:\\
\;\;\;\;\left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 + im \cdot 0.25\right) + 2\\
\end{array}
\end{array}
if im < 2.14999999999999991Initial program 100.0%
Taylor expanded in im around 0 62.0%
if 2.14999999999999991 < im < 1.2e144Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 55.9%
+-commutative55.9%
distribute-lft-in55.9%
metadata-eval55.9%
Simplified55.9%
if 1.2e144 < im < 1.40000000000000001e177Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 28.8%
Taylor expanded in re around 0 64.5%
unpow264.5%
Applied egg-rr64.5%
if 1.40000000000000001e177 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 85.7%
+-commutative85.7%
distribute-lft-in85.7%
metadata-eval85.7%
Simplified85.7%
Taylor expanded in im around 0 85.7%
+-commutative85.7%
*-commutative85.7%
Simplified85.7%
Final simplification63.9%
(FPCore (re im)
:precision binary64
(let* ((t_0
(* (+ 4.0 (* im (+ 1.0 (* 0.5 im)))) (+ 0.5 (* -0.25 (* re re))))))
(if (<= im 650.0)
(cos re)
(if (<= im 3.8e+111)
t_0
(if (<= im 1.2e+144)
(+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))
(if (<= im 5e+175) t_0 (+ (* im (+ 0.5 (* im 0.25))) 2.0)))))))
double code(double re, double im) {
double t_0 = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re)));
double tmp;
if (im <= 650.0) {
tmp = cos(re);
} else if (im <= 3.8e+111) {
tmp = t_0;
} else if (im <= 1.2e+144) {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
} else if (im <= 5e+175) {
tmp = t_0;
} else {
tmp = (im * (0.5 + (im * 0.25))) + 2.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) :: tmp
t_0 = (4.0d0 + (im * (1.0d0 + (0.5d0 * im)))) * (0.5d0 + ((-0.25d0) * (re * re)))
if (im <= 650.0d0) then
tmp = cos(re)
else if (im <= 3.8d+111) then
tmp = t_0
else if (im <= 1.2d+144) then
tmp = 2.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0)))))
else if (im <= 5d+175) then
tmp = t_0
else
tmp = (im * (0.5d0 + (im * 0.25d0))) + 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re)));
double tmp;
if (im <= 650.0) {
tmp = Math.cos(re);
} else if (im <= 3.8e+111) {
tmp = t_0;
} else if (im <= 1.2e+144) {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
} else if (im <= 5e+175) {
tmp = t_0;
} else {
tmp = (im * (0.5 + (im * 0.25))) + 2.0;
}
return tmp;
}
def code(re, im): t_0 = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re))) tmp = 0 if im <= 650.0: tmp = math.cos(re) elif im <= 3.8e+111: tmp = t_0 elif im <= 1.2e+144: tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) elif im <= 5e+175: tmp = t_0 else: tmp = (im * (0.5 + (im * 0.25))) + 2.0 return tmp
function code(re, im) t_0 = Float64(Float64(4.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))) tmp = 0.0 if (im <= 650.0) tmp = cos(re); elseif (im <= 3.8e+111) tmp = t_0; elseif (im <= 1.2e+144) tmp = Float64(2.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333)))))); elseif (im <= 5e+175) tmp = t_0; else tmp = Float64(Float64(im * Float64(0.5 + Float64(im * 0.25))) + 2.0); end return tmp end
function tmp_2 = code(re, im) t_0 = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re))); tmp = 0.0; if (im <= 650.0) tmp = cos(re); elseif (im <= 3.8e+111) tmp = t_0; elseif (im <= 1.2e+144) tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))); elseif (im <= 5e+175) tmp = t_0; else tmp = (im * (0.5 + (im * 0.25))) + 2.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(4.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 650.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 3.8e+111], t$95$0, If[LessEqual[im, 1.2e+144], N[(2.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5e+175], t$95$0, N[(N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq 650:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{+111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+144}:\\
\;\;\;\;2 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\\
\mathbf{elif}\;im \leq 5 \cdot 10^{+175}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 + im \cdot 0.25\right) + 2\\
\end{array}
\end{array}
if im < 650Initial program 100.0%
Taylor expanded in im around 0 61.7%
if 650 < im < 3.79999999999999976e111 or 1.2e144 < im < 5e175Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 8.8%
Taylor expanded in re around 0 26.0%
unpow226.0%
Applied egg-rr26.0%
if 3.79999999999999976e111 < im < 1.2e144Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 66.7%
+-commutative66.7%
distribute-lft-in66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in im around 0 66.7%
+-commutative66.7%
*-commutative66.7%
Simplified66.7%
if 5e175 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 85.7%
+-commutative85.7%
distribute-lft-in85.7%
metadata-eval85.7%
Simplified85.7%
Taylor expanded in im around 0 85.7%
+-commutative85.7%
*-commutative85.7%
Simplified85.7%
Final simplification60.6%
(FPCore (re im)
:precision binary64
(let* ((t_0
(* (+ 4.0 (* im (+ 1.0 (* 0.5 im)))) (+ 0.5 (* -0.25 (* re re))))))
(if (<= im 600.0)
1.0
(if (<= im 3.8e+111)
t_0
(if (<= im 1e+144)
(+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))
(if (<= im 1.82e+176) t_0 (+ (* im (+ 0.5 (* im 0.25))) 2.0)))))))
double code(double re, double im) {
double t_0 = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re)));
double tmp;
if (im <= 600.0) {
tmp = 1.0;
} else if (im <= 3.8e+111) {
tmp = t_0;
} else if (im <= 1e+144) {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
} else if (im <= 1.82e+176) {
tmp = t_0;
} else {
tmp = (im * (0.5 + (im * 0.25))) + 2.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) :: tmp
t_0 = (4.0d0 + (im * (1.0d0 + (0.5d0 * im)))) * (0.5d0 + ((-0.25d0) * (re * re)))
if (im <= 600.0d0) then
tmp = 1.0d0
else if (im <= 3.8d+111) then
tmp = t_0
else if (im <= 1d+144) then
tmp = 2.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0)))))
else if (im <= 1.82d+176) then
tmp = t_0
else
tmp = (im * (0.5d0 + (im * 0.25d0))) + 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re)));
double tmp;
if (im <= 600.0) {
tmp = 1.0;
} else if (im <= 3.8e+111) {
tmp = t_0;
} else if (im <= 1e+144) {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
} else if (im <= 1.82e+176) {
tmp = t_0;
} else {
tmp = (im * (0.5 + (im * 0.25))) + 2.0;
}
return tmp;
}
def code(re, im): t_0 = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re))) tmp = 0 if im <= 600.0: tmp = 1.0 elif im <= 3.8e+111: tmp = t_0 elif im <= 1e+144: tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) elif im <= 1.82e+176: tmp = t_0 else: tmp = (im * (0.5 + (im * 0.25))) + 2.0 return tmp
function code(re, im) t_0 = Float64(Float64(4.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))) tmp = 0.0 if (im <= 600.0) tmp = 1.0; elseif (im <= 3.8e+111) tmp = t_0; elseif (im <= 1e+144) tmp = Float64(2.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333)))))); elseif (im <= 1.82e+176) tmp = t_0; else tmp = Float64(Float64(im * Float64(0.5 + Float64(im * 0.25))) + 2.0); end return tmp end
function tmp_2 = code(re, im) t_0 = (4.0 + (im * (1.0 + (0.5 * im)))) * (0.5 + (-0.25 * (re * re))); tmp = 0.0; if (im <= 600.0) tmp = 1.0; elseif (im <= 3.8e+111) tmp = t_0; elseif (im <= 1e+144) tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))); elseif (im <= 1.82e+176) tmp = t_0; else tmp = (im * (0.5 + (im * 0.25))) + 2.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(4.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 600.0], 1.0, If[LessEqual[im, 3.8e+111], t$95$0, If[LessEqual[im, 1e+144], N[(2.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.82e+176], t$95$0, N[(N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq 600:\\
\;\;\;\;1\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{+111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 10^{+144}:\\
\;\;\;\;2 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\\
\mathbf{elif}\;im \leq 1.82 \cdot 10^{+176}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 + im \cdot 0.25\right) + 2\\
\end{array}
\end{array}
if im < 600Initial program 100.0%
Taylor expanded in im around 0 61.7%
Taylor expanded in re around 0 33.7%
if 600 < im < 3.79999999999999976e111 or 1.00000000000000002e144 < im < 1.8200000000000001e176Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 8.8%
Taylor expanded in re around 0 26.0%
unpow226.0%
Applied egg-rr26.0%
if 3.79999999999999976e111 < im < 1.00000000000000002e144Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 66.7%
+-commutative66.7%
distribute-lft-in66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in im around 0 66.7%
+-commutative66.7%
*-commutative66.7%
Simplified66.7%
if 1.8200000000000001e176 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 85.7%
+-commutative85.7%
distribute-lft-in85.7%
metadata-eval85.7%
Simplified85.7%
Taylor expanded in im around 0 85.7%
+-commutative85.7%
*-commutative85.7%
Simplified85.7%
Final simplification39.4%
(FPCore (re im) :precision binary64 (if (<= im 15500000000.0) 1.0 (+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))))
double code(double re, double im) {
double tmp;
if (im <= 15500000000.0) {
tmp = 1.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 15500000000.0d0) then
tmp = 1.0d0
else
tmp = 2.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 15500000000.0) {
tmp = 1.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 15500000000.0: tmp = 1.0 else: tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 15500000000.0) tmp = 1.0; else tmp = Float64(2.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333)))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 15500000000.0) tmp = 1.0; else tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 15500000000.0], 1.0, N[(2.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 15500000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;2 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\\
\end{array}
\end{array}
if im < 1.55e10Initial program 100.0%
Taylor expanded in im around 0 60.8%
Taylor expanded in re around 0 33.2%
if 1.55e10 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 72.4%
+-commutative72.4%
distribute-lft-in72.4%
metadata-eval72.4%
Simplified72.4%
Taylor expanded in im around 0 54.5%
+-commutative54.5%
*-commutative54.5%
Simplified54.5%
Final simplification38.1%
(FPCore (re im) :precision binary64 (if (<= im 15500000000.0) 1.0 (+ (* im (+ 0.5 (* im 0.25))) 2.0)))
double code(double re, double im) {
double tmp;
if (im <= 15500000000.0) {
tmp = 1.0;
} else {
tmp = (im * (0.5 + (im * 0.25))) + 2.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 15500000000.0d0) then
tmp = 1.0d0
else
tmp = (im * (0.5d0 + (im * 0.25d0))) + 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 15500000000.0) {
tmp = 1.0;
} else {
tmp = (im * (0.5 + (im * 0.25))) + 2.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 15500000000.0: tmp = 1.0 else: tmp = (im * (0.5 + (im * 0.25))) + 2.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 15500000000.0) tmp = 1.0; else tmp = Float64(Float64(im * Float64(0.5 + Float64(im * 0.25))) + 2.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 15500000000.0) tmp = 1.0; else tmp = (im * (0.5 + (im * 0.25))) + 2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 15500000000.0], 1.0, N[(N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 15500000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 + im \cdot 0.25\right) + 2\\
\end{array}
\end{array}
if im < 1.55e10Initial program 100.0%
Taylor expanded in im around 0 60.8%
Taylor expanded in re around 0 33.2%
if 1.55e10 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 72.4%
+-commutative72.4%
distribute-lft-in72.4%
metadata-eval72.4%
Simplified72.4%
Taylor expanded in im around 0 44.9%
+-commutative44.9%
*-commutative44.9%
Simplified44.9%
(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 47.7%
Taylor expanded in re around 0 26.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 re around 0 62.8%
Applied egg-rr8.6%
metadata-eval8.6%
Applied egg-rr8.6%
herbie shell --seed 2024136
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))