
(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 20 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.6%
if 4 < (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
Applied egg-rr50.0%
Final simplification76.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.6%
Taylor expanded in im around 0 99.6%
*-commutative99.6%
Simplified99.6%
if 4 < (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
Applied egg-rr50.0%
Final simplification76.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 0.0065)
(*
t_1
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 t_0)))
(if (<= im 1e+103)
(* 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.0065) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 1e+103) {
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.0065d0) then
tmp = t_1 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + t_0))
else if (im <= 1d+103) 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.0065) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 1e+103) {
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.0065: tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)) elif im <= 1e+103: 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.0065) 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 <= 1e+103) 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.0065) tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)); elseif (im <= 1e+103) 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.0065], 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, 1e+103], 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.0065:\\
\;\;\;\;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 10^{+103}:\\
\;\;\;\;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.0064999999999999997Initial program 100.0%
Taylor expanded in im around 0 90.3%
Taylor expanded in im around 0 69.3%
*-commutative69.3%
Simplified69.3%
if 0.0064999999999999997 < im < 1e103Initial program 100.0%
Taylor expanded in re around 0 55.6%
if 1e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification73.0%
(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 5.2)
(*
t_1
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 t_0)))
(if (<= im 1e+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 <= 5.2) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 1e+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 <= 5.2d0) then
tmp = t_1 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + t_0))
else if (im <= 1d+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 <= 5.2) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 1e+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 <= 5.2: tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)) elif im <= 1e+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 <= 5.2) 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 <= 1e+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 <= 5.2) tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)); elseif (im <= 1e+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, 5.2], 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, 1e+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 5.2:\\
\;\;\;\;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 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 < 5.20000000000000018Initial program 100.0%
Taylor expanded in im around 0 90.3%
Taylor expanded in im around 0 69.3%
*-commutative69.3%
Simplified69.3%
if 5.20000000000000018 < im < 1e103Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 55.6%
+-commutative55.6%
distribute-lft-in55.6%
metadata-eval55.6%
Simplified55.6%
if 1e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification73.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re)))
(t_1 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))
(if (<= im 0.0065)
(* t_0 (+ (+ 1.0 t_1) (+ 1.0 (* im (+ (* 0.5 im) -1.0)))))
(if (<= im 1e+103)
(*
0.5
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(* t_0 (+ 4.0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double tmp;
if (im <= 0.0065) {
tmp = t_0 * ((1.0 + t_1) + (1.0 + (im * ((0.5 * im) + -1.0))));
} else if (im <= 1e+103) {
tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (4.0 + t_1);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * cos(re)
t_1 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
if (im <= 0.0065d0) then
tmp = t_0 * ((1.0d0 + t_1) + (1.0d0 + (im * ((0.5d0 * im) + (-1.0d0)))))
else if (im <= 1d+103) then
tmp = 0.5d0 * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = t_0 * (4.0d0 + t_1)
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 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double tmp;
if (im <= 0.0065) {
tmp = t_0 * ((1.0 + t_1) + (1.0 + (im * ((0.5 * im) + -1.0))));
} else if (im <= 1e+103) {
tmp = 0.5 * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (4.0 + t_1);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) tmp = 0 if im <= 0.0065: tmp = t_0 * ((1.0 + t_1) + (1.0 + (im * ((0.5 * im) + -1.0)))) elif im <= 1e+103: tmp = 0.5 * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = t_0 * (4.0 + t_1) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) tmp = 0.0 if (im <= 0.0065) tmp = Float64(t_0 * Float64(Float64(1.0 + t_1) + Float64(1.0 + Float64(im * Float64(Float64(0.5 * im) + -1.0))))); elseif (im <= 1e+103) 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(t_0 * Float64(4.0 + t_1)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); tmp = 0.0; if (im <= 0.0065) tmp = t_0 * ((1.0 + t_1) + (1.0 + (im * ((0.5 * im) + -1.0)))); elseif (im <= 1e+103) tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = t_0 * (4.0 + t_1); 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[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0065], N[(t$95$0 * N[(N[(1.0 + t$95$1), $MachinePrecision] + N[(1.0 + N[(im * N[(N[(0.5 * im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+103], 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[(t$95$0 * N[(4.0 + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
t_1 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;im \leq 0.0065:\\
\;\;\;\;t\_0 \cdot \left(\left(1 + t\_1\right) + \left(1 + im \cdot \left(0.5 \cdot im + -1\right)\right)\right)\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;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}:\\
\;\;\;\;t\_0 \cdot \left(4 + t\_1\right)\\
\end{array}
\end{array}
if im < 0.0064999999999999997Initial program 100.0%
Taylor expanded in im around 0 90.3%
Taylor expanded in im around 0 69.3%
*-commutative69.3%
Simplified69.3%
Taylor expanded in im around 0 68.9%
if 0.0064999999999999997 < im < 1e103Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 55.6%
if 1e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification72.7%
(FPCore (re im)
:precision binary64
(if (<= im 0.000116)
(cos re)
(if (<= im 1e+103)
(*
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.000116) {
tmp = cos(re);
} else if (im <= 1e+103) {
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.000116d0) then
tmp = cos(re)
else if (im <= 1d+103) 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.000116) {
tmp = Math.cos(re);
} else if (im <= 1e+103) {
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.000116: tmp = math.cos(re) elif im <= 1e+103: 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.000116) tmp = cos(re); elseif (im <= 1e+103) 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.000116) tmp = cos(re); elseif (im <= 1e+103) 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.000116], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1e+103], 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.000116:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;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 < 1.16e-4Initial program 100.0%
Taylor expanded in im around 0 86.0%
+-commutative86.0%
unpow286.0%
fma-define86.0%
Simplified86.0%
Taylor expanded in im around 0 69.6%
if 1.16e-4 < im < 1e103Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 55.6%
if 1e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification73.2%
(FPCore (re im)
:precision binary64
(if (<= im 3.9)
(cos re)
(if (<= im 5.7e+153)
(+ (* 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.9) {
tmp = cos(re);
} else if (im <= 5.7e+153) {
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.9d0) then
tmp = cos(re)
else if (im <= 5.7d+153) 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.9) {
tmp = Math.cos(re);
} else if (im <= 5.7e+153) {
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.9: tmp = math.cos(re) elif im <= 5.7e+153: 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.9) tmp = cos(re); elseif (im <= 5.7e+153) 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.9) tmp = cos(re); elseif (im <= 5.7e+153) 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.9], N[Cos[re], $MachinePrecision], If[LessEqual[im, 5.7e+153], 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.9:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 5.7 \cdot 10^{+153}:\\
\;\;\;\;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.89999999999999991Initial program 100.0%
Taylor expanded in im around 0 86.0%
+-commutative86.0%
unpow286.0%
fma-define86.0%
Simplified86.0%
Taylor expanded in im around 0 69.6%
if 3.89999999999999991 < im < 5.69999999999999987e153Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 67.8%
+-commutative67.8%
distribute-lft-in67.8%
metadata-eval67.8%
Simplified67.8%
if 5.69999999999999987e153 < 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.6) (cos re) (+ (* 0.5 (exp im)) 1.5)))
double code(double re, double im) {
double tmp;
if (im <= 3.6) {
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.6d0) 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.6) {
tmp = Math.cos(re);
} else {
tmp = (0.5 * Math.exp(im)) + 1.5;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.6: 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.6) 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.6) tmp = cos(re); else tmp = (0.5 * exp(im)) + 1.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.6], 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.6:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot e^{im} + 1.5\\
\end{array}
\end{array}
if im < 3.60000000000000009Initial program 100.0%
Taylor expanded in im around 0 86.0%
+-commutative86.0%
unpow286.0%
fma-define86.0%
Simplified86.0%
Taylor expanded in im around 0 69.6%
if 3.60000000000000009 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 70.2%
+-commutative70.2%
distribute-lft-in70.2%
metadata-eval70.2%
Simplified70.2%
(FPCore (re im)
:precision binary64
(if (<= im 4.5e+33)
(cos re)
(if (<= im 6.2e+100)
(- (* -0.5 (* re re)) 2.0)
(+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333)))))))))
double code(double re, double im) {
double tmp;
if (im <= 4.5e+33) {
tmp = cos(re);
} else if (im <= 6.2e+100) {
tmp = (-0.5 * (re * re)) - 2.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 <= 4.5d+33) then
tmp = cos(re)
else if (im <= 6.2d+100) then
tmp = ((-0.5d0) * (re * re)) - 2.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 <= 4.5e+33) {
tmp = Math.cos(re);
} else if (im <= 6.2e+100) {
tmp = (-0.5 * (re * re)) - 2.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 4.5e+33: tmp = math.cos(re) elif im <= 6.2e+100: tmp = (-0.5 * (re * re)) - 2.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 <= 4.5e+33) tmp = cos(re); elseif (im <= 6.2e+100) tmp = Float64(Float64(-0.5 * Float64(re * re)) - 2.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 <= 4.5e+33) tmp = cos(re); elseif (im <= 6.2e+100) tmp = (-0.5 * (re * re)) - 2.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, 4.5e+33], N[Cos[re], $MachinePrecision], If[LessEqual[im, 6.2e+100], N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], 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 4.5 \cdot 10^{+33}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 6.2 \cdot 10^{+100}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot re\right) - 2\\
\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 < 4.5e33Initial program 100.0%
Taylor expanded in im around 0 82.8%
+-commutative82.8%
unpow282.8%
fma-define82.8%
Simplified82.8%
Taylor expanded in im around 0 67.0%
if 4.5e33 < im < 6.20000000000000014e100Initial program 100.0%
Taylor expanded in im around 0 4.5%
+-commutative4.5%
unpow24.5%
fma-define4.5%
Simplified4.5%
Applied egg-rr2.3%
+-commutative2.3%
Simplified2.3%
Taylor expanded in re around 0 56.2%
unpow256.2%
Applied egg-rr56.2%
if 6.20000000000000014e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.5%
+-commutative77.5%
distribute-lft-in77.5%
metadata-eval77.5%
Simplified77.5%
Taylor expanded in im around 0 75.4%
*-commutative75.4%
Simplified75.4%
(FPCore (re im)
:precision binary64
(if (<= im 1.5e+29)
(*
0.5
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))
(if (<= im 9.2e+101)
(- (* -0.5 (* re re)) 2.0)
(+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333)))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.5e+29) {
tmp = 0.5 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
} else if (im <= 9.2e+101) {
tmp = (-0.5 * (re * re)) - 2.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 <= 1.5d+29) then
tmp = 0.5d0 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))))
else if (im <= 9.2d+101) then
tmp = ((-0.5d0) * (re * re)) - 2.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 <= 1.5e+29) {
tmp = 0.5 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
} else if (im <= 9.2e+101) {
tmp = (-0.5 * (re * re)) - 2.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.5e+29: tmp = 0.5 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))) elif im <= 9.2e+101: tmp = (-0.5 * (re * re)) - 2.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 <= 1.5e+29) tmp = Float64(0.5 * 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)))))))); elseif (im <= 9.2e+101) tmp = Float64(Float64(-0.5 * Float64(re * re)) - 2.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 <= 1.5e+29) tmp = 0.5 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))); elseif (im <= 9.2e+101) tmp = (-0.5 * (re * re)) - 2.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, 1.5e+29], N[(0.5 * 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], If[LessEqual[im, 9.2e+101], N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], 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 1.5 \cdot 10^{+29}:\\
\;\;\;\;0.5 \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{elif}\;im \leq 9.2 \cdot 10^{+101}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot re\right) - 2\\
\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.5e29Initial program 100.0%
Taylor expanded in im around 0 90.5%
Taylor expanded in re around 0 52.1%
Taylor expanded in im around 0 37.2%
*-commutative67.7%
Simplified37.2%
if 1.5e29 < im < 9.2000000000000005e101Initial program 100.0%
Taylor expanded in im around 0 4.3%
+-commutative4.3%
unpow24.3%
fma-define4.3%
Simplified4.3%
Applied egg-rr2.1%
+-commutative2.1%
Simplified2.1%
Taylor expanded in re around 0 42.5%
unpow242.5%
Applied egg-rr42.5%
if 9.2000000000000005e101 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.5%
+-commutative77.5%
distribute-lft-in77.5%
metadata-eval77.5%
Simplified77.5%
Taylor expanded in im around 0 75.4%
*-commutative75.4%
Simplified75.4%
Final simplification43.4%
(FPCore (re im)
:precision binary64
(if (<= im 185.0)
(*
0.5
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 3.55e+101)
(- (* -0.5 (* re re)) 2.0)
(+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333)))))))))
double code(double re, double im) {
double tmp;
if (im <= 185.0) {
tmp = 0.5 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 3.55e+101) {
tmp = (-0.5 * (re * re)) - 2.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 <= 185.0d0) then
tmp = 0.5d0 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 3.55d+101) then
tmp = ((-0.5d0) * (re * re)) - 2.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 <= 185.0) {
tmp = 0.5 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 3.55e+101) {
tmp = (-0.5 * (re * re)) - 2.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 185.0: tmp = 0.5 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 3.55e+101: tmp = (-0.5 * (re * re)) - 2.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 <= 185.0) tmp = Float64(0.5 * 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 <= 3.55e+101) tmp = Float64(Float64(-0.5 * Float64(re * re)) - 2.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 <= 185.0) tmp = 0.5 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 3.55e+101) tmp = (-0.5 * (re * re)) - 2.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, 185.0], N[(0.5 * 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, 3.55e+101], N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], 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 185:\\
\;\;\;\;0.5 \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 3.55 \cdot 10^{+101}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot re\right) - 2\\
\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 < 185Initial program 100.0%
Taylor expanded in im around 0 90.3%
Taylor expanded in re around 0 51.2%
Taylor expanded in im around 0 51.0%
if 185 < im < 3.55000000000000026e101Initial program 100.0%
Taylor expanded in im around 0 4.1%
+-commutative4.1%
unpow24.1%
fma-define4.1%
Simplified4.1%
Applied egg-rr1.7%
+-commutative1.7%
Simplified1.7%
Taylor expanded in re around 0 32.0%
unpow232.0%
Applied egg-rr32.0%
if 3.55000000000000026e101 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.5%
+-commutative77.5%
distribute-lft-in77.5%
metadata-eval77.5%
Simplified77.5%
Taylor expanded in im around 0 75.4%
*-commutative75.4%
Simplified75.4%
Final simplification53.7%
(FPCore (re im)
:precision binary64
(if (<= im 9.2e+30)
(* 0.5 (+ (+ 1.0 (* im (+ (* im 0.5277777777777778) -1.0))) (+ im 1.0)))
(if (<= im 5.3e+100)
(- (* -0.5 (* re re)) 2.0)
(+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333)))))))))
double code(double re, double im) {
double tmp;
if (im <= 9.2e+30) {
tmp = 0.5 * ((1.0 + (im * ((im * 0.5277777777777778) + -1.0))) + (im + 1.0));
} else if (im <= 5.3e+100) {
tmp = (-0.5 * (re * re)) - 2.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 <= 9.2d+30) then
tmp = 0.5d0 * ((1.0d0 + (im * ((im * 0.5277777777777778d0) + (-1.0d0)))) + (im + 1.0d0))
else if (im <= 5.3d+100) then
tmp = ((-0.5d0) * (re * re)) - 2.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 <= 9.2e+30) {
tmp = 0.5 * ((1.0 + (im * ((im * 0.5277777777777778) + -1.0))) + (im + 1.0));
} else if (im <= 5.3e+100) {
tmp = (-0.5 * (re * re)) - 2.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 9.2e+30: tmp = 0.5 * ((1.0 + (im * ((im * 0.5277777777777778) + -1.0))) + (im + 1.0)) elif im <= 5.3e+100: tmp = (-0.5 * (re * re)) - 2.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 <= 9.2e+30) tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(im * Float64(Float64(im * 0.5277777777777778) + -1.0))) + Float64(im + 1.0))); elseif (im <= 5.3e+100) tmp = Float64(Float64(-0.5 * Float64(re * re)) - 2.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 <= 9.2e+30) tmp = 0.5 * ((1.0 + (im * ((im * 0.5277777777777778) + -1.0))) + (im + 1.0)); elseif (im <= 5.3e+100) tmp = (-0.5 * (re * re)) - 2.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, 9.2e+30], N[(0.5 * N[(N[(1.0 + N[(im * N[(N[(im * 0.5277777777777778), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(im + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.3e+100], N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], 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 9.2 \cdot 10^{+30}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + im \cdot \left(im \cdot 0.5277777777777778 + -1\right)\right) + \left(im + 1\right)\right)\\
\mathbf{elif}\;im \leq 5.3 \cdot 10^{+100}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot re\right) - 2\\
\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 < 9.2e30Initial program 100.0%
Taylor expanded in im around 0 90.6%
Taylor expanded in re around 0 52.1%
Taylor expanded in im around 0 49.4%
Applied egg-rr47.1%
if 9.2e30 < im < 5.2999999999999998e100Initial program 100.0%
Taylor expanded in im around 0 4.4%
+-commutative4.4%
unpow24.4%
fma-define4.4%
Simplified4.4%
Applied egg-rr2.1%
+-commutative2.1%
Simplified2.1%
Taylor expanded in re around 0 50.6%
unpow250.6%
Applied egg-rr50.6%
if 5.2999999999999998e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.5%
+-commutative77.5%
distribute-lft-in77.5%
metadata-eval77.5%
Simplified77.5%
Taylor expanded in im around 0 75.4%
*-commutative75.4%
Simplified75.4%
Final simplification51.7%
(FPCore (re im)
:precision binary64
(if (<= im 1e+32)
(* 0.5 (+ (+ 1.0 (* im (+ (* 0.5 im) -1.0))) (+ im 1.0)))
(if (<= im 5.2e+100)
(- (* -0.5 (* re re)) 2.0)
(+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333)))))))))
double code(double re, double im) {
double tmp;
if (im <= 1e+32) {
tmp = 0.5 * ((1.0 + (im * ((0.5 * im) + -1.0))) + (im + 1.0));
} else if (im <= 5.2e+100) {
tmp = (-0.5 * (re * re)) - 2.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 <= 1d+32) then
tmp = 0.5d0 * ((1.0d0 + (im * ((0.5d0 * im) + (-1.0d0)))) + (im + 1.0d0))
else if (im <= 5.2d+100) then
tmp = ((-0.5d0) * (re * re)) - 2.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 <= 1e+32) {
tmp = 0.5 * ((1.0 + (im * ((0.5 * im) + -1.0))) + (im + 1.0));
} else if (im <= 5.2e+100) {
tmp = (-0.5 * (re * re)) - 2.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1e+32: tmp = 0.5 * ((1.0 + (im * ((0.5 * im) + -1.0))) + (im + 1.0)) elif im <= 5.2e+100: tmp = (-0.5 * (re * re)) - 2.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 <= 1e+32) tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(im * Float64(Float64(0.5 * im) + -1.0))) + Float64(im + 1.0))); elseif (im <= 5.2e+100) tmp = Float64(Float64(-0.5 * Float64(re * re)) - 2.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 <= 1e+32) tmp = 0.5 * ((1.0 + (im * ((0.5 * im) + -1.0))) + (im + 1.0)); elseif (im <= 5.2e+100) tmp = (-0.5 * (re * re)) - 2.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, 1e+32], N[(0.5 * 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, 5.2e+100], N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], 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 10^{+32}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + im \cdot \left(0.5 \cdot im + -1\right)\right) + \left(im + 1\right)\right)\\
\mathbf{elif}\;im \leq 5.2 \cdot 10^{+100}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot re\right) - 2\\
\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.00000000000000005e32Initial program 100.0%
Taylor expanded in im around 0 90.6%
Taylor expanded in re around 0 52.1%
Taylor expanded in im around 0 49.4%
Taylor expanded in im around 0 47.1%
if 1.00000000000000005e32 < im < 5.2000000000000003e100Initial program 100.0%
Taylor expanded in im around 0 4.4%
+-commutative4.4%
unpow24.4%
fma-define4.4%
Simplified4.4%
Applied egg-rr2.1%
+-commutative2.1%
Simplified2.1%
Taylor expanded in re around 0 50.6%
unpow250.6%
Applied egg-rr50.6%
if 5.2000000000000003e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.5%
+-commutative77.5%
distribute-lft-in77.5%
metadata-eval77.5%
Simplified77.5%
Taylor expanded in im around 0 75.4%
*-commutative75.4%
Simplified75.4%
Final simplification51.7%
(FPCore (re im)
:precision binary64
(if (<= im 1.5e+29)
1.0
(if (<= im 1.7e+100)
(- (* -0.5 (* re re)) 2.0)
(+ 2.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333)))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.5e+29) {
tmp = 1.0;
} else if (im <= 1.7e+100) {
tmp = (-0.5 * (re * re)) - 2.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 <= 1.5d+29) then
tmp = 1.0d0
else if (im <= 1.7d+100) then
tmp = ((-0.5d0) * (re * re)) - 2.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 <= 1.5e+29) {
tmp = 1.0;
} else if (im <= 1.7e+100) {
tmp = (-0.5 * (re * re)) - 2.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.5e+29: tmp = 1.0 elif im <= 1.7e+100: tmp = (-0.5 * (re * re)) - 2.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 <= 1.5e+29) tmp = 1.0; elseif (im <= 1.7e+100) tmp = Float64(Float64(-0.5 * Float64(re * re)) - 2.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 <= 1.5e+29) tmp = 1.0; elseif (im <= 1.7e+100) tmp = (-0.5 * (re * re)) - 2.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, 1.5e+29], 1.0, If[LessEqual[im, 1.7e+100], N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], 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 1.5 \cdot 10^{+29}:\\
\;\;\;\;1\\
\mathbf{elif}\;im \leq 1.7 \cdot 10^{+100}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot re\right) - 2\\
\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.5e29Initial program 100.0%
Taylor expanded in im around 0 68.0%
Taylor expanded in re around 0 37.4%
if 1.5e29 < im < 1.69999999999999997e100Initial program 100.0%
Taylor expanded in im around 0 4.3%
+-commutative4.3%
unpow24.3%
fma-define4.3%
Simplified4.3%
Applied egg-rr2.1%
+-commutative2.1%
Simplified2.1%
Taylor expanded in re around 0 42.5%
unpow242.5%
Applied egg-rr42.5%
if 1.69999999999999997e100 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.5%
+-commutative77.5%
distribute-lft-in77.5%
metadata-eval77.5%
Simplified77.5%
Taylor expanded in im around 0 75.4%
*-commutative75.4%
Simplified75.4%
(FPCore (re im)
:precision binary64
(if (<= im 1.5e+29)
1.0
(if (<= im 6.8e+117)
(- (* -0.5 (* re re)) 2.0)
(+ 2.0 (* im (+ 0.5 (* im 0.25)))))))
double code(double re, double im) {
double tmp;
if (im <= 1.5e+29) {
tmp = 1.0;
} else if (im <= 6.8e+117) {
tmp = (-0.5 * (re * re)) - 2.0;
} 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.5d+29) then
tmp = 1.0d0
else if (im <= 6.8d+117) then
tmp = ((-0.5d0) * (re * re)) - 2.0d0
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.5e+29) {
tmp = 1.0;
} else if (im <= 6.8e+117) {
tmp = (-0.5 * (re * re)) - 2.0;
} else {
tmp = 2.0 + (im * (0.5 + (im * 0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.5e+29: tmp = 1.0 elif im <= 6.8e+117: tmp = (-0.5 * (re * re)) - 2.0 else: tmp = 2.0 + (im * (0.5 + (im * 0.25))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.5e+29) tmp = 1.0; elseif (im <= 6.8e+117) tmp = Float64(Float64(-0.5 * Float64(re * re)) - 2.0); 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.5e+29) tmp = 1.0; elseif (im <= 6.8e+117) tmp = (-0.5 * (re * re)) - 2.0; else tmp = 2.0 + (im * (0.5 + (im * 0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.5e+29], 1.0, If[LessEqual[im, 6.8e+117], N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 2.0), $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.5 \cdot 10^{+29}:\\
\;\;\;\;1\\
\mathbf{elif}\;im \leq 6.8 \cdot 10^{+117}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot re\right) - 2\\
\mathbf{else}:\\
\;\;\;\;2 + im \cdot \left(0.5 + im \cdot 0.25\right)\\
\end{array}
\end{array}
if im < 1.5e29Initial program 100.0%
Taylor expanded in im around 0 68.0%
Taylor expanded in re around 0 37.4%
if 1.5e29 < im < 6.8000000000000002e117Initial program 100.0%
Taylor expanded in im around 0 4.8%
+-commutative4.8%
unpow24.8%
fma-define4.8%
Simplified4.8%
Applied egg-rr1.8%
+-commutative1.8%
Simplified1.8%
Taylor expanded in re around 0 36.0%
unpow236.0%
Applied egg-rr36.0%
if 6.8000000000000002e117 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.1%
+-commutative77.1%
distribute-lft-in77.1%
metadata-eval77.1%
Simplified77.1%
Taylor expanded in im around 0 56.1%
*-commutative56.1%
Simplified56.1%
(FPCore (re im) :precision binary64 (if (<= im 1.5e+29) 1.0 (- (* -0.5 (* re re)) 2.0)))
double code(double re, double im) {
double tmp;
if (im <= 1.5e+29) {
tmp = 1.0;
} else {
tmp = (-0.5 * (re * re)) - 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.5d+29) then
tmp = 1.0d0
else
tmp = ((-0.5d0) * (re * re)) - 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.5e+29) {
tmp = 1.0;
} else {
tmp = (-0.5 * (re * re)) - 2.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.5e+29: tmp = 1.0 else: tmp = (-0.5 * (re * re)) - 2.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 1.5e+29) tmp = 1.0; else tmp = Float64(Float64(-0.5 * Float64(re * re)) - 2.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.5e+29) tmp = 1.0; else tmp = (-0.5 * (re * re)) - 2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.5e+29], 1.0, N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.5 \cdot 10^{+29}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot re\right) - 2\\
\end{array}
\end{array}
if im < 1.5e29Initial program 100.0%
Taylor expanded in im around 0 68.0%
Taylor expanded in re around 0 37.4%
if 1.5e29 < im Initial program 100.0%
Taylor expanded in im around 0 53.0%
+-commutative53.0%
unpow253.0%
fma-define53.0%
Simplified53.0%
Applied egg-rr1.4%
+-commutative1.4%
Simplified1.4%
Taylor expanded in re around 0 21.9%
unpow221.9%
Applied egg-rr21.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 54.8%
Taylor expanded in re around 0 30.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 61.9%
Applied egg-rr9.6%
metadata-eval9.6%
Applied egg-rr9.6%
(FPCore (re im) :precision binary64 -2.0)
double code(double re, double im) {
return -2.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -2.0d0
end function
public static double code(double re, double im) {
return -2.0;
}
def code(re, im): return -2.0
function code(re, im) return -2.0 end
function tmp = code(re, im) tmp = -2.0; end
code[re_, im_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 77.7%
+-commutative77.7%
unpow277.7%
fma-define77.7%
Simplified77.7%
Applied egg-rr3.5%
+-commutative3.5%
Simplified3.5%
Taylor expanded in re around 0 3.7%
herbie shell --seed 2024145
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))