
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Initial program 100.0%
(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.9%
if 4 < (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
Applied egg-rr52.4%
Final simplification76.9%
(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.9%
Taylor expanded in im around 0 99.9%
*-commutative99.9%
Simplified99.9%
if 4 < (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
Applied egg-rr52.4%
Final simplification76.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
(t_1 (* 0.5 (cos re)))
(t_2
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(if (<= im 7.4)
(* t_1 (+ t_2 (+ 1.0 t_0)))
(if (<= im 1e+103) (* 0.5 (+ (exp im) t_2)) (* t_1 (+ 4.0 t_0))))))
double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * cos(re);
double t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 7.4) {
tmp = t_1 * (t_2 + (1.0 + t_0));
} else if (im <= 1e+103) {
tmp = 0.5 * (exp(im) + t_2);
} else {
tmp = t_1 * (4.0 + t_0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
t_1 = 0.5d0 * cos(re)
t_2 = 1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))
if (im <= 7.4d0) then
tmp = t_1 * (t_2 + (1.0d0 + t_0))
else if (im <= 1d+103) then
tmp = 0.5d0 * (exp(im) + t_2)
else
tmp = t_1 * (4.0d0 + t_0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * Math.cos(re);
double t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 7.4) {
tmp = t_1 * (t_2 + (1.0 + t_0));
} else if (im <= 1e+103) {
tmp = 0.5 * (Math.exp(im) + t_2);
} else {
tmp = t_1 * (4.0 + t_0);
}
return tmp;
}
def code(re, im): t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) t_1 = 0.5 * math.cos(re) t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) tmp = 0 if im <= 7.4: tmp = t_1 * (t_2 + (1.0 + t_0)) elif im <= 1e+103: tmp = 0.5 * (math.exp(im) + t_2) else: tmp = t_1 * (4.0 + t_0) return tmp
function code(re, im) t_0 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) t_1 = Float64(0.5 * cos(re)) t_2 = Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) tmp = 0.0 if (im <= 7.4) tmp = Float64(t_1 * Float64(t_2 + Float64(1.0 + t_0))); elseif (im <= 1e+103) tmp = Float64(0.5 * Float64(exp(im) + t_2)); else tmp = Float64(t_1 * Float64(4.0 + t_0)); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); t_1 = 0.5 * cos(re); t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)); tmp = 0.0; if (im <= 7.4) tmp = t_1 * (t_2 + (1.0 + t_0)); elseif (im <= 1e+103) tmp = 0.5 * (exp(im) + t_2); else tmp = t_1 * (4.0 + t_0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 7.4], N[(t$95$1 * N[(t$95$2 + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+103], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(4.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
t_1 := 0.5 \cdot \cos re\\
t_2 := 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\\
\mathbf{if}\;im \leq 7.4:\\
\;\;\;\;t\_1 \cdot \left(t\_2 + \left(1 + t\_0\right)\right)\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + t\_2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(4 + t\_0\right)\\
\end{array}
\end{array}
if im < 7.4000000000000004Initial program 100.0%
Taylor expanded in im around 0 84.3%
Taylor expanded in im around 0 68.7%
*-commutative68.7%
Simplified68.7%
if 7.4000000000000004 < im < 1e103Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 92.3%
if 1e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification75.6%
(FPCore (re im)
:precision binary64
(if (<= im 6.5)
(* 0.5 (* (cos re) (+ 2.0 (+ im (* im (+ im -1.0))))))
(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 <= 6.5) {
tmp = 0.5 * (cos(re) * (2.0 + (im + (im * (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 = (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 <= 6.5d0) then
tmp = 0.5d0 * (cos(re) * (2.0d0 + (im + (im * (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 = (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 <= 6.5) {
tmp = 0.5 * (Math.cos(re) * (2.0 + (im + (im * (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 = (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 <= 6.5: tmp = 0.5 * (math.cos(re) * (2.0 + (im + (im * (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 = (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 <= 6.5) tmp = Float64(0.5 * Float64(cos(re) * Float64(2.0 + Float64(im + Float64(im * Float64(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(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 <= 6.5) tmp = 0.5 * (cos(re) * (2.0 + (im + (im * (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 = (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, 6.5], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(2.0 + N[(im + N[(im * N[(im + -1.0), $MachinePrecision]), $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[(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 6.5:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(2 + \left(im + im \cdot \left(im + -1\right)\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}:\\
\;\;\;\;\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 < 6.5Initial program 100.0%
Taylor expanded in im around 0 84.3%
Taylor expanded in im around 0 84.1%
Applied egg-rr80.2%
Taylor expanded in re around inf 80.2%
if 6.5 < im < 1e103Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 92.3%
if 1e103 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification84.3%
(FPCore (re im)
:precision binary64
(if (<= im 5.0)
(* 0.5 (* (cos re) (+ 2.0 (+ im (* im (+ im -1.0))))))
(if (<= im 2.7e+154)
(* 0.5 (+ (exp im) (- 1.0 im)))
(* (cos re) (+ 2.0 (* im (+ 0.5 (* im 0.25))))))))
double code(double re, double im) {
double tmp;
if (im <= 5.0) {
tmp = 0.5 * (cos(re) * (2.0 + (im + (im * (im + -1.0)))));
} else if (im <= 2.7e+154) {
tmp = 0.5 * (exp(im) + (1.0 - im));
} else {
tmp = cos(re) * (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 <= 5.0d0) then
tmp = 0.5d0 * (cos(re) * (2.0d0 + (im + (im * (im + (-1.0d0))))))
else if (im <= 2.7d+154) then
tmp = 0.5d0 * (exp(im) + (1.0d0 - im))
else
tmp = cos(re) * (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 <= 5.0) {
tmp = 0.5 * (Math.cos(re) * (2.0 + (im + (im * (im + -1.0)))));
} else if (im <= 2.7e+154) {
tmp = 0.5 * (Math.exp(im) + (1.0 - im));
} else {
tmp = Math.cos(re) * (2.0 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.0: tmp = 0.5 * (math.cos(re) * (2.0 + (im + (im * (im + -1.0))))) elif im <= 2.7e+154: tmp = 0.5 * (math.exp(im) + (1.0 - im)) else: tmp = math.cos(re) * (2.0 + (im * (0.5 + (im * 0.25)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.0) tmp = Float64(0.5 * Float64(cos(re) * Float64(2.0 + Float64(im + Float64(im * Float64(im + -1.0)))))); elseif (im <= 2.7e+154) tmp = Float64(0.5 * Float64(exp(im) + Float64(1.0 - im))); else tmp = Float64(cos(re) * 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 <= 5.0) tmp = 0.5 * (cos(re) * (2.0 + (im + (im * (im + -1.0))))); elseif (im <= 2.7e+154) tmp = 0.5 * (exp(im) + (1.0 - im)); else tmp = cos(re) * (2.0 + (im * (0.5 + (im * 0.25)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.0], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(2.0 + N[(im + N[(im * N[(im + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.7e+154], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(2.0 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(2 + \left(im + im \cdot \left(im + -1\right)\right)\right)\right)\\
\mathbf{elif}\;im \leq 2.7 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + \left(1 - im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(2 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 5Initial program 100.0%
Taylor expanded in im around 0 84.3%
Taylor expanded in im around 0 84.1%
Applied egg-rr80.2%
Taylor expanded in re around inf 80.2%
if 5 < im < 2.70000000000000006e154Initial program 100.0%
Taylor expanded in re around 0 93.9%
Taylor expanded in im around 0 93.9%
neg-mul-193.9%
unsub-neg93.9%
Simplified93.9%
if 2.70000000000000006e154 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
distribute-lft-in100.0%
associate-*r*100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
*-commutative100.0%
distribute-lft-out100.0%
+-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification84.3%
(FPCore (re im)
:precision binary64
(if (<= im 1.7)
(cos re)
(if (<= im 2.7e+154)
(* 0.5 (+ (exp im) (- 1.0 im)))
(* (cos re) (+ 2.0 (* im (+ 0.5 (* im 0.25))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.7) {
tmp = cos(re);
} else if (im <= 2.7e+154) {
tmp = 0.5 * (exp(im) + (1.0 - im));
} else {
tmp = cos(re) * (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.7d0) then
tmp = cos(re)
else if (im <= 2.7d+154) then
tmp = 0.5d0 * (exp(im) + (1.0d0 - im))
else
tmp = cos(re) * (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.7) {
tmp = Math.cos(re);
} else if (im <= 2.7e+154) {
tmp = 0.5 * (Math.exp(im) + (1.0 - im));
} else {
tmp = Math.cos(re) * (2.0 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.7: tmp = math.cos(re) elif im <= 2.7e+154: tmp = 0.5 * (math.exp(im) + (1.0 - im)) else: tmp = math.cos(re) * (2.0 + (im * (0.5 + (im * 0.25)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.7) tmp = cos(re); elseif (im <= 2.7e+154) tmp = Float64(0.5 * Float64(exp(im) + Float64(1.0 - im))); else tmp = Float64(cos(re) * 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.7) tmp = cos(re); elseif (im <= 2.7e+154) tmp = 0.5 * (exp(im) + (1.0 - im)); else tmp = cos(re) * (2.0 + (im * (0.5 + (im * 0.25)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.7], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.7e+154], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(2.0 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.7:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.7 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + \left(1 - im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(2 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 1.69999999999999996Initial program 100.0%
Taylor expanded in im around 0 69.2%
if 1.69999999999999996 < im < 2.70000000000000006e154Initial program 100.0%
Taylor expanded in re around 0 93.9%
Taylor expanded in im around 0 93.9%
neg-mul-193.9%
unsub-neg93.9%
Simplified93.9%
if 2.70000000000000006e154 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
distribute-lft-in100.0%
associate-*r*100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
*-commutative100.0%
distribute-lft-out100.0%
+-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification76.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 69.2%
if 3.60000000000000009 < im Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 79.4%
+-commutative79.4%
distribute-lft-in79.4%
metadata-eval79.4%
Simplified79.4%
(FPCore (re im) :precision binary64 (if (<= im 2.6) (cos re) (* 0.5 (+ (exp im) 1.0))))
double code(double re, double im) {
double tmp;
if (im <= 2.6) {
tmp = cos(re);
} else {
tmp = 0.5 * (exp(im) + 1.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.6d0) then
tmp = cos(re)
else
tmp = 0.5d0 * (exp(im) + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.6) {
tmp = Math.cos(re);
} else {
tmp = 0.5 * (Math.exp(im) + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.6: tmp = math.cos(re) else: tmp = 0.5 * (math.exp(im) + 1.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.6) tmp = cos(re); else tmp = Float64(0.5 * Float64(exp(im) + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.6) tmp = cos(re); else tmp = 0.5 * (exp(im) + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.6], N[Cos[re], $MachinePrecision], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.6:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + 1\right)\\
\end{array}
\end{array}
if im < 2.60000000000000009Initial program 100.0%
Taylor expanded in im around 0 69.2%
if 2.60000000000000009 < im Initial program 100.0%
Taylor expanded in re around 0 79.4%
Taylor expanded in im around 0 79.4%
neg-mul-179.4%
unsub-neg79.4%
Simplified79.4%
Taylor expanded in im around 0 79.4%
Final simplification71.7%
(FPCore (re im)
:precision binary64
(if (<= im 8.0)
(cos re)
(*
0.5
(+ 1.0 (+ 1.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (im <= 8.0) {
tmp = cos(re);
} else {
tmp = 0.5 * (1.0 + (1.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 <= 8.0d0) then
tmp = cos(re)
else
tmp = 0.5d0 * (1.0d0 + (1.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 <= 8.0) {
tmp = Math.cos(re);
} else {
tmp = 0.5 * (1.0 + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 8.0: tmp = math.cos(re) else: tmp = 0.5 * (1.0 + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 8.0) tmp = cos(re); else tmp = Float64(0.5 * Float64(1.0 + Float64(1.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 <= 8.0) tmp = cos(re); else tmp = 0.5 * (1.0 + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 8.0], N[Cos[re], $MachinePrecision], N[(0.5 * N[(1.0 + 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 8:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(1 + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\right)\\
\end{array}
\end{array}
if im < 8Initial program 100.0%
Taylor expanded in im around 0 69.2%
if 8 < im Initial program 100.0%
Taylor expanded in re around 0 79.4%
Taylor expanded in im around 0 79.4%
neg-mul-179.4%
unsub-neg79.4%
Simplified79.4%
Taylor expanded in im around 0 43.5%
*-commutative0.7%
Simplified43.5%
Taylor expanded in im around 0 43.5%
(FPCore (re im) :precision binary64 (* 0.5 (+ (+ 1.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))) (- 1.0 im))))
double code(double re, double im) {
return 0.5 * ((1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) + (1.0 - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * ((1.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) + (1.0d0 - im))
end function
public static double code(double re, double im) {
return 0.5 * ((1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) + (1.0 - im));
}
def code(re, im): return 0.5 * ((1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) + (1.0 - im))
function code(re, im) return Float64(0.5 * Float64(Float64(1.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) + Float64(1.0 - im))) end
function tmp = code(re, im) tmp = 0.5 * ((1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) + (1.0 - im)); end
code[re_, im_] := N[(0.5 * N[(N[(1.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) + \left(1 - im\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 66.7%
Taylor expanded in im around 0 48.4%
neg-mul-148.4%
unsub-neg48.4%
Simplified48.4%
Taylor expanded in im around 0 41.1%
*-commutative52.0%
Simplified41.1%
Final simplification41.1%
(FPCore (re im) :precision binary64 (* 0.5 (+ 1.0 (+ 1.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))
double code(double re, double im) {
return 0.5 * (1.0 + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (1.0d0 + (1.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))))
end function
public static double code(double re, double im) {
return 0.5 * (1.0 + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
}
def code(re, im): return 0.5 * (1.0 + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))))
function code(re, im) return Float64(0.5 * Float64(1.0 + Float64(1.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))))) end
function tmp = code(re, im) tmp = 0.5 * (1.0 + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))); end
code[re_, im_] := N[(0.5 * N[(1.0 + 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]
\begin{array}{l}
\\
0.5 \cdot \left(1 + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 66.7%
Taylor expanded in im around 0 48.4%
neg-mul-148.4%
unsub-neg48.4%
Simplified48.4%
Taylor expanded in im around 0 41.1%
*-commutative52.0%
Simplified41.1%
Taylor expanded in im around 0 40.8%
(FPCore (re im) :precision binary64 (* 0.5 (+ 2.0 (+ im (* im (+ im -1.0))))))
double code(double re, double im) {
return 0.5 * (2.0 + (im + (im * (im + -1.0))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (2.0d0 + (im + (im * (im + (-1.0d0)))))
end function
public static double code(double re, double im) {
return 0.5 * (2.0 + (im + (im * (im + -1.0))));
}
def code(re, im): return 0.5 * (2.0 + (im + (im * (im + -1.0))))
function code(re, im) return Float64(0.5 * Float64(2.0 + Float64(im + Float64(im * Float64(im + -1.0))))) end
function tmp = code(re, im) tmp = 0.5 * (2.0 + (im + (im * (im + -1.0)))); end
code[re_, im_] := N[(0.5 * N[(2.0 + N[(im + N[(im * N[(im + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(2 + \left(im + im \cdot \left(im + -1\right)\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 73.7%
Taylor expanded in im around 0 63.4%
Applied egg-rr72.9%
Taylor expanded in re around 0 43.2%
Final simplification43.2%
(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 re around 0 66.7%
Taylor expanded in im around 0 29.2%
(FPCore (re im) :precision binary64 -27.0)
double code(double re, double im) {
return -27.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -27.0d0
end function
public static double code(double re, double im) {
return -27.0;
}
def code(re, im): return -27.0
function code(re, im) return -27.0 end
function tmp = code(re, im) tmp = -27.0; end
code[re_, im_] := -27.0
\begin{array}{l}
\\
-27
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 72.9%
+-commutative72.9%
unpow272.9%
fma-define72.9%
Simplified72.9%
Applied egg-rr3.4%
+-commutative3.4%
Simplified3.4%
Taylor expanded in re around 0 3.4%
herbie shell --seed 2024141
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))