
(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-rr51.6%
Final simplification73.7%
(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-rr51.6%
Final simplification73.7%
(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 4.6)
(*
t_1
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 t_0)))
(if (<= im 1.05e+103) (+ (* 0.5 (exp im)) 1.5) (* 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 <= 4.6) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 1.05e+103) {
tmp = (0.5 * exp(im)) + 1.5;
} 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 <= 4.6d0) then
tmp = t_1 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + t_0))
else if (im <= 1.05d+103) then
tmp = (0.5d0 * exp(im)) + 1.5d0
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 <= 4.6) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 1.05e+103) {
tmp = (0.5 * Math.exp(im)) + 1.5;
} 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 <= 4.6: tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)) elif im <= 1.05e+103: tmp = (0.5 * math.exp(im)) + 1.5 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 <= 4.6) 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 <= 1.05e+103) tmp = Float64(Float64(0.5 * exp(im)) + 1.5); 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 <= 4.6) tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)); elseif (im <= 1.05e+103) tmp = (0.5 * exp(im)) + 1.5; 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, 4.6], 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, 1.05e+103], N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 1.5), $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 4.6:\\
\;\;\;\;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 1.05 \cdot 10^{+103}:\\
\;\;\;\;0.5 \cdot e^{im} + 1.5\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(4 + t\_0\right)\\
\end{array}
\end{array}
if im < 4.5999999999999996Initial program 100.0%
Taylor expanded in im around 0 91.7%
Taylor expanded in im around 0 63.0%
*-commutative63.0%
Simplified63.0%
if 4.5999999999999996 < im < 1.0500000000000001e103Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 70.4%
+-commutative70.4%
distribute-lft-in70.4%
metadata-eval70.4%
Simplified70.4%
if 1.0500000000000001e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification69.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= im 3.1)
(*
t_0
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 1.05e+103)
(+ (* 0.5 (exp im)) 1.5)
(*
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 tmp;
if (im <= 3.1) {
tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1.05e+103) {
tmp = (0.5 * exp(im)) + 1.5;
} 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) :: tmp
t_0 = 0.5d0 * cos(re)
if (im <= 3.1d0) then
tmp = t_0 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 1.05d+103) then
tmp = (0.5d0 * exp(im)) + 1.5d0
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 tmp;
if (im <= 3.1) {
tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1.05e+103) {
tmp = (0.5 * Math.exp(im)) + 1.5;
} 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) tmp = 0 if im <= 3.1: tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 1.05e+103: tmp = (0.5 * math.exp(im)) + 1.5 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)) tmp = 0.0 if (im <= 3.1) 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(0.5 * im)))))); elseif (im <= 1.05e+103) tmp = Float64(Float64(0.5 * exp(im)) + 1.5); 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); tmp = 0.0; if (im <= 3.1) tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 1.05e+103) tmp = (0.5 * exp(im)) + 1.5; 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]}, If[LessEqual[im, 3.1], 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[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.05e+103], N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 1.5), $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\\
\mathbf{if}\;im \leq 3.1:\\
\;\;\;\;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 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;0.5 \cdot e^{im} + 1.5\\
\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 < 3.10000000000000009Initial program 100.0%
Taylor expanded in im around 0 91.7%
Taylor expanded in im around 0 91.6%
if 3.10000000000000009 < im < 1.0500000000000001e103Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 70.4%
+-commutative70.4%
distribute-lft-in70.4%
metadata-eval70.4%
Simplified70.4%
if 1.0500000000000001e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification90.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= im 4.0)
(* t_0 (+ (+ 1.0 (* im (+ (* 0.5 im) -1.0))) (+ im 1.0)))
(if (<= im 1.05e+103)
(+ (* 0.5 (exp im)) 1.5)
(*
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 tmp;
if (im <= 4.0) {
tmp = t_0 * ((1.0 + (im * ((0.5 * im) + -1.0))) + (im + 1.0));
} else if (im <= 1.05e+103) {
tmp = (0.5 * exp(im)) + 1.5;
} 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) :: tmp
t_0 = 0.5d0 * cos(re)
if (im <= 4.0d0) then
tmp = t_0 * ((1.0d0 + (im * ((0.5d0 * im) + (-1.0d0)))) + (im + 1.0d0))
else if (im <= 1.05d+103) then
tmp = (0.5d0 * exp(im)) + 1.5d0
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 tmp;
if (im <= 4.0) {
tmp = t_0 * ((1.0 + (im * ((0.5 * im) + -1.0))) + (im + 1.0));
} else if (im <= 1.05e+103) {
tmp = (0.5 * Math.exp(im)) + 1.5;
} 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) tmp = 0 if im <= 4.0: tmp = t_0 * ((1.0 + (im * ((0.5 * im) + -1.0))) + (im + 1.0)) elif im <= 1.05e+103: tmp = (0.5 * math.exp(im)) + 1.5 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)) tmp = 0.0 if (im <= 4.0) tmp = Float64(t_0 * Float64(Float64(1.0 + Float64(im * Float64(Float64(0.5 * im) + -1.0))) + Float64(im + 1.0))); elseif (im <= 1.05e+103) tmp = Float64(Float64(0.5 * exp(im)) + 1.5); 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); tmp = 0.0; if (im <= 4.0) tmp = t_0 * ((1.0 + (im * ((0.5 * im) + -1.0))) + (im + 1.0)); elseif (im <= 1.05e+103) tmp = (0.5 * exp(im)) + 1.5; 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]}, If[LessEqual[im, 4.0], N[(t$95$0 * N[(N[(1.0 + N[(im * N[(N[(0.5 * im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(im + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.05e+103], N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 1.5), $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\\
\mathbf{if}\;im \leq 4:\\
\;\;\;\;t\_0 \cdot \left(\left(1 + im \cdot \left(0.5 \cdot im + -1\right)\right) + \left(im + 1\right)\right)\\
\mathbf{elif}\;im \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;0.5 \cdot e^{im} + 1.5\\
\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 < 4Initial program 100.0%
Taylor expanded in im around 0 91.7%
Taylor expanded in im around 0 91.3%
Taylor expanded in im around 0 84.8%
if 4 < im < 1.0500000000000001e103Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 70.4%
+-commutative70.4%
distribute-lft-in70.4%
metadata-eval70.4%
Simplified70.4%
if 1.0500000000000001e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification85.8%
(FPCore (re im)
:precision binary64
(if (<= im 2.9)
(cos re)
(if (<= im 1.05e+103)
(+ (* 0.5 (exp im)) 1.5)
(*
(* 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 <= 2.9) {
tmp = cos(re);
} else if (im <= 1.05e+103) {
tmp = (0.5 * exp(im)) + 1.5;
} 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 <= 2.9d0) then
tmp = cos(re)
else if (im <= 1.05d+103) then
tmp = (0.5d0 * exp(im)) + 1.5d0
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 <= 2.9) {
tmp = Math.cos(re);
} else if (im <= 1.05e+103) {
tmp = (0.5 * Math.exp(im)) + 1.5;
} 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 <= 2.9: tmp = math.cos(re) elif im <= 1.05e+103: tmp = (0.5 * math.exp(im)) + 1.5 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 <= 2.9) tmp = cos(re); elseif (im <= 1.05e+103) 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(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.9) tmp = cos(re); elseif (im <= 1.05e+103) tmp = (0.5 * exp(im)) + 1.5; 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, 2.9], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.05e+103], 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[(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 2.9:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;0.5 \cdot e^{im} + 1.5\\
\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 < 2.89999999999999991Initial program 100.0%
Taylor expanded in im around 0 63.7%
if 2.89999999999999991 < im < 1.0500000000000001e103Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 70.4%
+-commutative70.4%
distribute-lft-in70.4%
metadata-eval70.4%
Simplified70.4%
if 1.0500000000000001e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
(FPCore (re im)
:precision binary64
(if (<= im 3.2)
(cos re)
(if (<= im 1.85e+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 <= 3.2) {
tmp = cos(re);
} else if (im <= 1.85e+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 <= 3.2d0) then
tmp = cos(re)
else if (im <= 1.85d+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 <= 3.2) {
tmp = Math.cos(re);
} else if (im <= 1.85e+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 <= 3.2: tmp = math.cos(re) elif im <= 1.85e+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 <= 3.2) tmp = cos(re); elseif (im <= 1.85e+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 <= 3.2) tmp = cos(re); elseif (im <= 1.85e+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, 3.2], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.85e+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 3.2:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.85 \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 < 3.2000000000000002Initial program 100.0%
Taylor expanded in im around 0 63.7%
if 3.2000000000000002 < im < 1.84999999999999997e154Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 76.3%
+-commutative76.3%
distribute-lft-in76.3%
metadata-eval76.3%
Simplified76.3%
if 1.84999999999999997e154 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
(FPCore (re im) :precision binary64 (if (<= im 3.0) (cos re) (+ (* 0.5 (exp im)) 1.5)))
double code(double re, double im) {
double tmp;
if (im <= 3.0) {
tmp = cos(re);
} else {
tmp = (0.5 * exp(im)) + 1.5;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3.0d0) then
tmp = cos(re)
else
tmp = (0.5d0 * exp(im)) + 1.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.0) {
tmp = Math.cos(re);
} else {
tmp = (0.5 * Math.exp(im)) + 1.5;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.0: tmp = math.cos(re) else: tmp = (0.5 * math.exp(im)) + 1.5 return tmp
function code(re, im) tmp = 0.0 if (im <= 3.0) tmp = cos(re); else tmp = Float64(Float64(0.5 * exp(im)) + 1.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.0) tmp = cos(re); else tmp = (0.5 * exp(im)) + 1.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.0], N[Cos[re], $MachinePrecision], N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 1.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot e^{im} + 1.5\\
\end{array}
\end{array}
if im < 3Initial program 100.0%
Taylor expanded in im around 0 63.7%
if 3 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 73.9%
+-commutative73.9%
distribute-lft-in73.9%
metadata-eval73.9%
Simplified73.9%
(FPCore (re im)
:precision binary64
(if (<= im 150000.0)
(cos re)
(if (<= im 7.2e+103)
(+ 1.0 (* (* re re) -0.5))
(+ (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))) 2.0))))
double code(double re, double im) {
double tmp;
if (im <= 150000.0) {
tmp = cos(re);
} else if (im <= 7.2e+103) {
tmp = 1.0 + ((re * re) * -0.5);
} else {
tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 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 <= 150000.0d0) then
tmp = cos(re)
else if (im <= 7.2d+103) then
tmp = 1.0d0 + ((re * re) * (-0.5d0))
else
tmp = (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))) + 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 150000.0) {
tmp = Math.cos(re);
} else if (im <= 7.2e+103) {
tmp = 1.0 + ((re * re) * -0.5);
} else {
tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 150000.0: tmp = math.cos(re) elif im <= 7.2e+103: tmp = 1.0 + ((re * re) * -0.5) else: tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 150000.0) tmp = cos(re); elseif (im <= 7.2e+103) tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5)); else tmp = Float64(Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))) + 2.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 150000.0) tmp = cos(re); elseif (im <= 7.2e+103) tmp = 1.0 + ((re * re) * -0.5); else tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 150000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 7.2e+103], N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 150000:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+103}:\\
\;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right) + 2\\
\end{array}
\end{array}
if im < 1.5e5Initial program 100.0%
Taylor expanded in im around 0 63.7%
if 1.5e5 < im < 7.20000000000000033e103Initial program 100.0%
Taylor expanded in im around 0 3.1%
Taylor expanded in re around 0 16.8%
*-commutative16.8%
Simplified16.8%
unpow216.8%
Applied egg-rr16.8%
if 7.20000000000000033e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
metadata-eval78.0%
Simplified78.0%
Taylor expanded in im around 0 78.0%
+-commutative78.0%
*-commutative78.0%
Simplified78.0%
(FPCore (re im)
:precision binary64
(if (<= im 0.0185)
(*
0.5
(+ 2.0 (+ im (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(if (<= im 7.2e+103)
(+ 1.0 (* (* re re) -0.5))
(+ (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))) 2.0))))
double code(double re, double im) {
double tmp;
if (im <= 0.0185) {
tmp = 0.5 * (2.0 + (im + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else if (im <= 7.2e+103) {
tmp = 1.0 + ((re * re) * -0.5);
} else {
tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 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 <= 0.0185d0) then
tmp = 0.5d0 * (2.0d0 + (im + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else if (im <= 7.2d+103) then
tmp = 1.0d0 + ((re * re) * (-0.5d0))
else
tmp = (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))) + 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0185) {
tmp = 0.5 * (2.0 + (im + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else if (im <= 7.2e+103) {
tmp = 1.0 + ((re * re) * -0.5);
} else {
tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0185: tmp = 0.5 * (2.0 + (im + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) elif im <= 7.2e+103: tmp = 1.0 + ((re * re) * -0.5) else: tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0185) tmp = Float64(0.5 * Float64(2.0 + Float64(im + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); elseif (im <= 7.2e+103) tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5)); else tmp = Float64(Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))) + 2.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0185) tmp = 0.5 * (2.0 + (im + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); elseif (im <= 7.2e+103) tmp = 1.0 + ((re * re) * -0.5); else tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0185], N[(0.5 * N[(2.0 + N[(im + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7.2e+103], N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0185:\\
\;\;\;\;0.5 \cdot \left(2 + \left(im + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+103}:\\
\;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right) + 2\\
\end{array}
\end{array}
if im < 0.0184999999999999991Initial program 100.0%
Taylor expanded in im around 0 91.8%
Taylor expanded in im around 0 91.6%
Taylor expanded in re around 0 60.9%
if 0.0184999999999999991 < im < 7.20000000000000033e103Initial program 99.9%
Taylor expanded in im around 0 4.3%
Taylor expanded in re around 0 16.4%
*-commutative16.4%
Simplified16.4%
unpow216.4%
Applied egg-rr16.4%
if 7.20000000000000033e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
metadata-eval78.0%
Simplified78.0%
Taylor expanded in im around 0 78.0%
+-commutative78.0%
*-commutative78.0%
Simplified78.0%
Final simplification58.6%
(FPCore (re im)
:precision binary64
(if (<= im 1.14e-29)
1.0
(if (<= im 7.2e+103)
(+ 1.0 (* (* re re) -0.5))
(+ (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))) 2.0))))
double code(double re, double im) {
double tmp;
if (im <= 1.14e-29) {
tmp = 1.0;
} else if (im <= 7.2e+103) {
tmp = 1.0 + ((re * re) * -0.5);
} else {
tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 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 <= 1.14d-29) then
tmp = 1.0d0
else if (im <= 7.2d+103) then
tmp = 1.0d0 + ((re * re) * (-0.5d0))
else
tmp = (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))) + 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.14e-29) {
tmp = 1.0;
} else if (im <= 7.2e+103) {
tmp = 1.0 + ((re * re) * -0.5);
} else {
tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.14e-29: tmp = 1.0 elif im <= 7.2e+103: tmp = 1.0 + ((re * re) * -0.5) else: tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 1.14e-29) tmp = 1.0; elseif (im <= 7.2e+103) tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5)); else tmp = Float64(Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))) + 2.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.14e-29) tmp = 1.0; elseif (im <= 7.2e+103) tmp = 1.0 + ((re * re) * -0.5); else tmp = (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))) + 2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.14e-29], 1.0, If[LessEqual[im, 7.2e+103], N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.14 \cdot 10^{-29}:\\
\;\;\;\;1\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+103}:\\
\;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right) + 2\\
\end{array}
\end{array}
if im < 1.13999999999999995e-29Initial program 100.0%
Taylor expanded in im around 0 63.1%
Taylor expanded in re around 0 36.4%
if 1.13999999999999995e-29 < im < 7.20000000000000033e103Initial program 100.0%
Taylor expanded in im around 0 17.1%
Taylor expanded in re around 0 24.6%
*-commutative24.6%
Simplified24.6%
unpow224.6%
Applied egg-rr24.6%
if 7.20000000000000033e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
metadata-eval78.0%
Simplified78.0%
Taylor expanded in im around 0 78.0%
+-commutative78.0%
*-commutative78.0%
Simplified78.0%
(FPCore (re im)
:precision binary64
(if (<= im 1.14e-29)
1.0
(if (<= im 1.14e+105)
(+ 1.0 (* (* re re) -0.5))
(+ 2.0 (* im (+ 0.5 (* im 0.25)))))))
double code(double re, double im) {
double tmp;
if (im <= 1.14e-29) {
tmp = 1.0;
} else if (im <= 1.14e+105) {
tmp = 1.0 + ((re * re) * -0.5);
} else {
tmp = 2.0 + (im * (0.5 + (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 <= 1.14d-29) then
tmp = 1.0d0
else if (im <= 1.14d+105) then
tmp = 1.0d0 + ((re * re) * (-0.5d0))
else
tmp = 2.0d0 + (im * (0.5d0 + (im * 0.25d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.14e-29) {
tmp = 1.0;
} else if (im <= 1.14e+105) {
tmp = 1.0 + ((re * re) * -0.5);
} else {
tmp = 2.0 + (im * (0.5 + (im * 0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.14e-29: tmp = 1.0 elif im <= 1.14e+105: tmp = 1.0 + ((re * re) * -0.5) else: tmp = 2.0 + (im * (0.5 + (im * 0.25))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.14e-29) tmp = 1.0; elseif (im <= 1.14e+105) tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5)); else tmp = Float64(2.0 + Float64(im * Float64(0.5 + Float64(im * 0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.14e-29) tmp = 1.0; elseif (im <= 1.14e+105) tmp = 1.0 + ((re * re) * -0.5); else tmp = 2.0 + (im * (0.5 + (im * 0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.14e-29], 1.0, If[LessEqual[im, 1.14e+105], N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.14 \cdot 10^{-29}:\\
\;\;\;\;1\\
\mathbf{elif}\;im \leq 1.14 \cdot 10^{+105}:\\
\;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;2 + im \cdot \left(0.5 + im \cdot 0.25\right)\\
\end{array}
\end{array}
if im < 1.13999999999999995e-29Initial program 100.0%
Taylor expanded in im around 0 63.1%
Taylor expanded in re around 0 36.4%
if 1.13999999999999995e-29 < im < 1.13999999999999997e105Initial program 100.0%
Taylor expanded in im around 0 17.1%
Taylor expanded in re around 0 24.6%
*-commutative24.6%
Simplified24.6%
unpow224.6%
Applied egg-rr24.6%
if 1.13999999999999997e105 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
metadata-eval78.0%
Simplified78.0%
Taylor expanded in im around 0 55.4%
+-commutative55.4%
*-commutative55.4%
Simplified55.4%
Final simplification37.9%
(FPCore (re im) :precision binary64 (if (<= im 1.14e-29) 1.0 (+ 1.0 (* (* re re) -0.5))))
double code(double re, double im) {
double tmp;
if (im <= 1.14e-29) {
tmp = 1.0;
} else {
tmp = 1.0 + ((re * re) * -0.5);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.14d-29) then
tmp = 1.0d0
else
tmp = 1.0d0 + ((re * re) * (-0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.14e-29) {
tmp = 1.0;
} else {
tmp = 1.0 + ((re * re) * -0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.14e-29: tmp = 1.0 else: tmp = 1.0 + ((re * re) * -0.5) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.14e-29) tmp = 1.0; else tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.14e-29) tmp = 1.0; else tmp = 1.0 + ((re * re) * -0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.14e-29], 1.0, N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.14 \cdot 10^{-29}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
\end{array}
\end{array}
if im < 1.13999999999999995e-29Initial program 100.0%
Taylor expanded in im around 0 63.1%
Taylor expanded in re around 0 36.4%
if 1.13999999999999995e-29 < im Initial program 100.0%
Taylor expanded in im around 0 9.5%
Taylor expanded in re around 0 21.6%
*-commutative21.6%
Simplified21.6%
unpow221.6%
Applied egg-rr21.6%
(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.4%
Taylor expanded in re around 0 27.8%
(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 68.8%
Applied egg-rr8.9%
metadata-eval8.9%
Applied egg-rr8.9%
herbie shell --seed 2024144
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))