+
+//////////
+// Eta function: log(x*y) == log(x) + log(y) + eta(x,y).
+//////////
+
+static ex eta_evalf(const ex & x, const ex & y)
+{
+ BEGIN_TYPECHECK
+ TYPECHECK(x,numeric)
+ TYPECHECK(y,numeric)
+ END_TYPECHECK(eta(x,y))
+
+ numeric xim = imag(ex_to_numeric(x));
+ numeric yim = imag(ex_to_numeric(y));
+ numeric xyim = imag(ex_to_numeric(x*y));
+ return evalf(I/4*Pi)*((csgn(-xim)+1)*(csgn(-yim)+1)*(csgn(xyim)+1)-(csgn(xim)+1)*(csgn(yim)+1)*(csgn(-xyim)+1));
+}
+
+static ex eta_eval(const ex & x, const ex & y)
+{
+ if (is_ex_exactly_of_type(x, numeric) &&
+ is_ex_exactly_of_type(y, numeric)) {
+ // don't call eta_evalf here because it would call Pi.evalf()!
+ numeric xim = imag(ex_to_numeric(x));
+ numeric yim = imag(ex_to_numeric(y));
+ numeric xyim = imag(ex_to_numeric(x*y));
+ return (I/4)*Pi*((csgn(-xim)+1)*(csgn(-yim)+1)*(csgn(xyim)+1)-(csgn(xim)+1)*(csgn(yim)+1)*(csgn(-xyim)+1));
+ }
+
+ return eta(x,y).hold();
+}
+
+static ex eta_series(const ex & arg1,
+ const ex & arg2,
+ const relational & rel,
+ int order,
+ unsigned options)
+{
+ const ex arg1_pt = arg1.subs(rel);
+ const ex arg2_pt = arg2.subs(rel);
+ if (ex_to_numeric(arg1_pt).imag().is_zero() ||
+ ex_to_numeric(arg2_pt).imag().is_zero() ||
+ ex_to_numeric(arg1_pt*arg2_pt).imag().is_zero()) {
+ throw (std::domain_error("eta_series(): on discontinuity"));
+ }
+ epvector seq;
+ seq.push_back(expair(eta(arg1_pt,arg2_pt), _ex0()));
+ return pseries(rel,seq);
+}
+
+REGISTER_FUNCTION(eta, eval_func(eta_eval).
+ evalf_func(eta_evalf).
+ series_func(eta_series));
+
+