48 if (is_exactly_a<numeric>(arg)) {
51 return conjugate_function(arg).hold();
61 c.s <<
"\\bar{"; arg.
print(
c);
c.s <<
"}";
77 vec_arg.push_back(arg);
118 return arg.
info(inf);
136 set_name(
"conjugate",
"conjugate"));
144 if (is_exactly_a<numeric>(arg)) {
145 return ex_to<numeric>(arg).real();
147 return real_part_function(arg).hold();
157 c.s <<
"\\Re"; arg.
print(
c);
c.s <<
"";
162 return real_part_function(arg).hold();
167 return real_part_function(arg).hold();
179 return real_part_function(arg.
diff(s));
182 vec_arg.push_back(arg);
194 set_name(
"real_part",
"real_part"));
202 if (is_exactly_a<numeric>(arg)) {
203 return ex_to<numeric>(arg).imag();
205 return imag_part_function(arg).hold();
215 c.s <<
"\\Im"; arg.
print(
c);
c.s <<
"";
220 return imag_part_function(arg).hold();
225 return imag_part_function(arg).hold();
237 return imag_part_function(arg.
diff(s));
240 vec_arg.push_back(arg);
252 set_name(
"imag_part",
"imag_part"));
260 if (is_exactly_a<numeric>(arg))
261 return abs(ex_to<numeric>(arg));
268 if (is_exactly_a<numeric>(arg))
269 return abs(ex_to<numeric>(arg));
283 if (is_exactly_a<power>(arg)) {
284 const ex& base = arg.
op(0);
285 const ex& exponent = arg.
op(1);
291 return abs(arg.
op(0));
302 && is_exactly_a<mul>(arg)) {
304 prodseq.reserve(arg.
nops());
309 prodseq.push_back(
abs(*i));
322 ex diff_arg = arg.
diff(s);
328 c.s <<
"{|"; arg.
print(
c);
c.s <<
"|}";
333 c.s <<
"fabs("; arg.
print(
c);
c.s <<
")";
369 return arg.
info(inf);
408 if (is_exactly_a<numeric>(arg))
409 return step(ex_to<numeric>(arg));
416 if (is_exactly_a<numeric>(arg))
417 return step(ex_to<numeric>(arg));
419 else if (is_exactly_a<mul>(arg) &&
420 is_exactly_a<numeric>(arg.
op(arg.
nops()-1))) {
450 && ex_to<numeric>(arg_pt).real().is_zero()
452 throw (std::domain_error(
"step_series(): on imaginary axis"));
455 return pseries(rel, std::move(seq));
486 if (is_exactly_a<numeric>(arg))
487 return csgn(ex_to<numeric>(arg));
489 return csgn(arg).hold();
494 if (is_exactly_a<numeric>(arg))
495 return csgn(ex_to<numeric>(arg));
497 else if (is_exactly_a<mul>(arg) &&
498 is_exactly_a<numeric>(arg.
op(arg.
nops()-1))) {
503 return csgn(arg/oc).hold();
506 return -
csgn(arg/oc).hold();
511 return csgn(
I*arg/oc).hold();
514 return -
csgn(
I*arg/oc).hold();
518 return csgn(arg).hold();
528 && ex_to<numeric>(arg_pt).real().is_zero()
530 throw (std::domain_error(
"csgn_series(): on imaginary axis"));
533 return pseries(rel, std::move(seq));
538 return csgn(arg).hold();
543 return csgn(arg).hold();
555 return csgn(arg).hold();
586 const numeric nx = ex_to<numeric>(
x);
587 const numeric ny = ex_to<numeric>(y);
588 const numeric nxy = ex_to<numeric>(
x*y);
600 return eta(
x,y).hold();
611 const numeric nx = ex_to<numeric>(
x);
612 const numeric ny = ex_to<numeric>(y);
613 const numeric nxy = ex_to<numeric>(
x*y);
625 return eta(
x,y).hold();
638 throw (std::domain_error(
"eta_series(): on discontinuity"));
640 return pseries(rel, std::move(seq));
645 return -eta(
x, y).hold();
655 return -
I*eta(
x, y).
hold();
674 if (is_exactly_a<numeric>(
x))
675 return Li2(ex_to<numeric>(
x));
703 return Li2(ex_to<numeric>(
x));
738 for (
int i=1; i<
order; ++i)
744 ser +=
pseries(rel, std::move(nseq));
762 for (
int i=1; i<
order; ++i)
768 ser +=
pseries(rel, std::move(nseq));
774 ex_to<numeric>(x_pt).
is_real() && ex_to<numeric>(x_pt)>1) {
778 const symbol &s = ex_to<symbol>(rel.
lhs());
779 const ex point = rel.
rhs();
786 for (
size_t i=1; i<replarg.
nops()-1; ++i)
790 return pseries(rel, std::move(seq));
804 if (is_exactly_a<numeric>(
x) &&
808 return conjugate_function(
Li2(
x)).hold();
816 latex_name(
"\\mathrm{Li}_2"));
826 return Li3(
x).hold();
830 latex_name(
"\\mathrm{Li}_3"));
844 return zetaderiv(
n,
x).
hold();
851 if (deriv_param==0) {
853 throw(std::logic_error(
"cannot diff zetaderiv(n,x) with respect to n"));
856 return zetaderiv(
n+1,
x);
861 latex_name(
"\\zeta^\\prime"));
874 if (is_exactly_a<numeric>(
x))
882 if (is_exactly_a<symbol>(
x) ||
883 is_exactly_a<constant>(
x) ||
884 is_exactly_a<function>(
x)) {
927 const unsigned N = y.
to_int();
928 if (N == 0)
return _ex1;
929 if (N == 1)
return x;
931 for (
unsigned i = 2; i <= N; ++i)
932 t = (t * (
x + i - y - 1)).
expand() / i;
943 if (is_exactly_a<numeric>(y)) {
944 if (is_exactly_a<numeric>(
x) && ex_to<numeric>(
x).
is_integer())
945 return binomial(ex_to<numeric>(
x), ex_to<numeric>(y));
982 if (is_exactly_a<numeric>(
x)) {
985 return Order(
_ex1).hold();
988 }
else if (is_exactly_a<mul>(
x)) {
989 const mul &
m = ex_to<mul>(
x);
991 if (is_exactly_a<numeric>(
m.op(
m.nops() - 1)))
992 return Order(
x /
m.
op(
m.nops() - 1)).hold();
994 return Order(
x).hold();
1001 const symbol &s = ex_to<symbol>(
r.lhs());
1003 return pseries(
r, std::move(new_seq));
1008 return Order(
x).hold();
1013 return Order(
x).hold();
1020 return Order(
x).hold();
1027 return Order(
pow(
x, e));
1039 return Order(arg.
diff(s));
1044 latex_name(
"\\mathcal{O}").
1059 if (is_a<symbol>(e)) {
1062 for (
const ex &sube : e) {
1074 return s.find(e) !=
s.end();
1083 throw(std::invalid_argument(
"lsolve(): 2nd argument must be a symbol"));
1089 return sol.
op(0).
op(1);
1094 throw(std::invalid_argument(
"lsolve(): 1st argument must be a list, a sequence, or an equation"));
1096 for (
size_t i=0; i<eqns.
nops(); i++) {
1098 throw(std::invalid_argument(
"lsolve(): 1st argument must be a list of equations"));
1102 throw(std::invalid_argument(
"lsolve(): 2nd argument must be a list, a sequence, or a symbol"));
1104 for (
size_t i=0; i<symbols.
nops(); i++) {
1106 throw(std::invalid_argument(
"lsolve(): 2nd argument must be a list or a sequence of symbols"));
1115 for (
size_t r=0;
r<eqns.
nops();
r++) {
1119 for (
size_t c=0;
c<symbols.
nops();
c++) {
1122 const ex co = eq.
coeff(ex_to<symbol>(symbols.
op(
c)),1);
1123 linpart -= co*symbols.
op(
c);
1126 linpart = linpart.
expand();
1127 rhs(
r,0) = -linpart;
1133 for (
size_t i=0; i<symbols.
nops(); i++) {
1134 vars(i,0) = symbols.
op(i);
1135 if (sys_syms.
has(symbols.
op(i)))
1136 throw(std::logic_error(
"lsolve: system is not linear"));
1137 if (rhs_syms.
has(symbols.
op(i)))
1138 throw(std::logic_error(
"lsolve: system is not linear"));
1144 }
catch (
const std::runtime_error & e) {
1154 for (
size_t i=0; i<symbols.
nops(); i++)
1155 sollist.
append(symbols.
op(i)==solution(i,0));
1168 throw std::runtime_error(
"fsolve(): interval not bounded by real numbers");
1171 throw std::runtime_error(
"fsolve(): vanishing interval");
1176 numeric xx[2] = { x1<x2 ? x1 : x2,
1179 if (is_a<relational>(f_in)) {
1180 f = f_in.
lhs()-f_in.
rhs();
1186 if (!is_a<numeric>(fx_[0]) || !is_a<numeric>(fx_[1])) {
1187 throw std::runtime_error(
"fsolve(): function does not evaluate numerically");
1189 numeric fx[2] = { ex_to<numeric>(fx_[0]),
1190 ex_to<numeric>(fx_[1]) };
1192 throw std::runtime_error(
"fsolve(): function evaluates to complex values at interval boundaries");
1194 if (fx[0]*fx[1]>=0) {
1195 throw std::runtime_error(
"fsolve(): function does not change sign at interval boundaries");
1208 if (!is_a<numeric>(dx_))
1209 throw std::runtime_error(
"fsolve(): function derivative does not evaluate numerically");
1210 xx[side] += ex_to<numeric>(dx_);
1212 bool bad_shot = (side == 0 && xx[0] < xxprev) ||
1213 (side == 1 && xx[1] > xxprev) || xx[0] > xx[1];
1220 if (!is_a<numeric>(f_x))
1221 throw std::runtime_error(
"fsolve(): function does not evaluate numerically");
1222 fx[side] = ex_to<numeric>(f_x);
1234 if (!is_a<numeric>(dx_))
1235 throw std::runtime_error(
"fsolve(): function derivative does not evaluate numerically [2]");
1236 xx[side] += ex_to<numeric>(dx_);
1239 if (!is_a<numeric>(f_x))
1240 throw std::runtime_error(
"fsolve(): function does not evaluate numerically [2]");
1241 fx[side] = ex_to<numeric>(f_x);
1243 if ((fx[side]<0 && fx[!side]<0) || (fx[side]>0 && fx[!side]>0)) {
1262 constexpr double secant_weight = 0.984375;
1263 numeric xxmid = (1-secant_weight)*0.5*(xx[0]+xx[1])
1264 + secant_weight*(xx[0]+fx[0]*(xx[0]-xx[1])/(fx[1]-fx[0]));
1266 if (!is_a<numeric>(fxmid_))
1267 throw std::runtime_error(
"fsolve(): function does not evaluate numerically [3]");
1268 numeric fxmid = ex_to<numeric>(fxmid_);
1273 if ((fxmid<0 && fx[side]>0) || (fxmid>0 && fx[side]<0)) {
1281 }
while (xxprev!=xx[side]);
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
const basic & hold() const
Stop further evaluation.
Wrapper template for making GiNaC classes out of STL containers.
container & append(const ex &b)
Add element at back.
Exception class thrown by classes which provide their own series expansion to signal that ordinary Ta...
Lightweight wrapper for GiNaC's symbolic objects.
const_iterator begin() const noexcept
ex diff(const symbol &s, unsigned nth=1) const
Compute partial derivative of an expression.
ex expand(unsigned options=0) const
Expand an expression.
bool is_equal(const ex &other) const
const_iterator end() const noexcept
ex series(const ex &r, int order, unsigned options=0) const
Compute the truncated series expansion of an expression.
ex subs(const exmap &m, unsigned options=0) const
bool info(unsigned inf) const
ex lhs() const
Left hand side of relational expression.
void print(const print_context &c, unsigned level=0) const
Print expression to stream.
int ldegree(const ex &s) const
ex rhs() const
Right hand side of relational expression.
ex coeff(const ex &s, int n=1) const
@ expand_transcendental
expands transcendental functions like log and exp
@ expand_function_args
expands the arguments of functions
This class represents the (abstract) derivative of a symbolic function.
unsigned cols() const
Get number of columns.
matrix solve(const matrix &vars, const matrix &rhs, unsigned algo=solve_algo::automatic) const
Solve a linear system consisting of a m x n matrix and a m x p right hand side by applying an elimina...
unsigned rows() const
Get number of rows.
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
bool info(unsigned inf) const override
Information about the object.
const numeric real() const
Real part of a number.
bool is_nonneg_integer() const
True if object is an exact integer greater or equal zero.
bool is_real() const
True if object is a real integer, rational or float (but not complex).
bool is_integer() const
True if object is a non-complex integer.
bool is_negative() const
True if object is not complex and less than zero.
const numeric imag() const
Imaginary part of a number.
int to_int() const
Converts numeric types to machine's int.
bool is_zero() const
True if object is zero.
This class holds a two-component object, a basis and and exponent representing exponentiation.
Base class for print_contexts.
This class holds a extended truncated power series (positive and negative integer powers).
This class holds a relation consisting of two expressions and a logical relation between them.
@ suppress_branchcut
Suppress branch cuts in series expansion.
@ expanded
.expand(0) has already done its job (other expand() options ignore this flag)
@ no_pattern
disable pattern matching
bool info(unsigned inf) const override
Information about the object.
bool has(const ex &e) const
void insert_symbols(const ex &e)
Interface to GiNaC's constant types and some special constants.
Interface to GiNaC's light-weight expression handles.
Interface to abstract derivatives of functions.
#define REGISTER_FUNCTION(NAME, OPT)
#define is_ex_the_function(OBJ, FUNCNAME)
Interface to GiNaC's initially known functions.
Definition of GiNaC's lst.
Interface to symbolic matrices.
Interface to GiNaC's products of expressions.
static ex csgn_imag_part(const ex &arg)
unsigned force_include_tgamma
const numeric I
Imaginary unit.
static ex step_imag_part(const ex &arg)
static ex imag_part_evalf(const ex &arg)
ex real_part(const ex &thisex)
static ex Order_eval(const ex &x)
const numeric pow(const numeric &x, const numeric &y)
ex lsolve(const ex &eqns, const ex &symbols, unsigned options)
Factorial function.
static ex conjugate_real_part(const ex &arg)
static ex eta_imag_part(const ex &x, const ex &y)
static ex eta_real_part(const ex &x, const ex &y)
static void imag_part_print_latex(const ex &arg, const print_context &c)
static ex abs_eval(const ex &arg)
std::set< ex, ex_is_less > exset
std::vector< expair > epvector
expair-vector
static ex conjugate_eval(const ex &arg)
static bool func_arg_info(const ex &arg, unsigned inf)
static ex step_conjugate(const ex &arg)
const numeric abs(const numeric &x)
Absolute value.
function zeta(const T1 &p1)
static ex abs_power(const ex &arg, const ex &exp)
static ex eta_eval(const ex &x, const ex &y)
static ex abs_expand(const ex &arg, unsigned options)
static ex Order_power(const ex &x, const ex &e)
static ex imag_part_eval(const ex &arg)
const numeric Li2(const numeric &x)
int csgn(const numeric &x)
static void abs_print_csrc_float(const ex &arg, const print_context &c)
static ex binomial_sym(const ex &x, const numeric &y)
static void conjugate_print_latex(const ex &arg, const print_context &c)
static ex imag_part_real_part(const ex &arg)
static ex Order_real_part(const ex &x)
static ex factorial_evalf(const ex &x)
static ex Li2_conjugate(const ex &x)
ex series(const ex &thisex, const ex &r, int order, unsigned options=0)
ex conjugate(const ex &thisex)
static ex abs_real_part(const ex &arg)
const numeric imag(const numeric &x)
const numeric binomial(const numeric &n, const numeric &k)
The Binomial coefficients.
bool abs_info(const ex &arg, unsigned inf)
print_func< print_dflt >(&diracone::do_print). print_func< print_latex >(&diracone
const numeric exp(const numeric &x)
Exponential function.
static ex csgn_power(const ex &arg, const ex &exp)
static ex eta_conjugate(const ex &x, const ex &y)
static ex Li3_eval(const ex &x)
static ex conjugate_expl_derivative(const ex &arg, const symbol &s)
static bool conjugate_info(const ex &arg, unsigned inf)
const numeric factorial(const numeric &n)
Factorial combinatorial function.
ex subs(const ex &thisex, const exmap &m, unsigned options=0)
bool is_even(const numeric &x)
const numeric fsolve(const ex &f_in, const symbol &x, const numeric &x1, const numeric &x2)
Find a real root of real-valued function f(x) numerically within a given interval.
static ex conjugate_conjugate(const ex &arg)
const constant Pi("Pi", PiEvalf, "\\pi", domain::positive)
Pi.
static ex imag_part_expl_derivative(const ex &arg, const symbol &s)
static ex real_part_expl_derivative(const ex &arg, const symbol &s)
static ex csgn_evalf(const ex &arg)
static ex csgn_eval(const ex &arg)
static ex step_real_part(const ex &arg)
static ex factorial_imag_part(const ex &x)
static ex factorial_real_part(const ex &x)
static ex abs_imag_part(const ex &arg)
static ex step_eval(const ex &arg)
static ex zetaderiv_eval(const ex &n, const ex &x)
const numeric log(const numeric &x)
Natural logarithm.
ex evalf(const ex &thisex)
static ex binomial_real_part(const ex &x, const ex &y)
bool is_real(const numeric &x)
static ex Order_series(const ex &x, const relational &r, int order, unsigned options)
static ex Li2_eval(const ex &x)
ex normal(const ex &thisex)
static ex zetaderiv_deriv(const ex &n, const ex &x, unsigned deriv_param)
ex op(const ex &thisex, size_t i)
static void abs_print_latex(const ex &arg, const print_context &c)
static ex imag_part_conjugate(const ex &arg)
static ex real_part_imag_part(const ex &arg)
const constant Catalan("Catalan", CatalanEvalf, "G", domain::positive)
Catalan's constant.
static ex Order_conjugate(const ex &x)
static ex imag_part_imag_part(const ex &arg)
static ex csgn_conjugate(const ex &arg)
static ex real_part_eval(const ex &arg)
static ex real_part_evalf(const ex &arg)
static ex real_part_real_part(const ex &arg)
static ex csgn_real_part(const ex &arg)
static ex binomial_imag_part(const ex &x, const ex &y)
static ex abs_conjugate(const ex &arg)
static ex Li2_evalf(const ex &x)
static ex step_evalf(const ex &arg)
static ex eta_series(const ex &x, const ex &y, const relational &rel, int order, unsigned options)
bool is_integer(const numeric &x)
static ex step_series(const ex &arg, const relational &rel, int order, unsigned options)
bool is_odd(const numeric &x)
static ex factorial_conjugate(const ex &x)
static ex abs_expl_derivative(const ex &arg, const symbol &s)
static ex Order_imag_part(const ex &x)
static ex binomial_evalf(const ex &x, const ex &y)
unsigned force_include_zeta1
static ex Li2_deriv(const ex &x, unsigned deriv_param)
static void factorial_print_dflt_latex(const ex &x, const print_context &c)
static ex binomial_eval(const ex &x, const ex &y)
static void real_part_print_latex(const ex &arg, const print_context &c)
std::vector< ex > exvector
static ex binomial_conjugate(const ex &x, const ex &y)
static ex Li2_series(const ex &x, const relational &rel, int order, unsigned options)
static ex csgn_series(const ex &arg, const relational &rel, int order, unsigned options)
static ex factorial_eval(const ex &x)
ex imag_part(const ex &thisex)
static ex Order_expl_derivative(const ex &arg, const symbol &s)
static ex real_part_conjugate(const ex &arg)
static ex conjugate_imag_part(const ex &arg)
static ex eta_evalf(const ex &x, const ex &y)
numeric step(const numeric &x)
static ex conjugate_evalf(const ex &arg)
static ex abs_evalf(const ex &arg)
Interface to GiNaC's overloaded operators.
Interface to GiNaC's symbolic exponentiation (basis^exponent).
Interface to class for extended truncated power series.
Interface to relations between expressions.
Interface to GiNaC's symbolic objects.
Interface to GiNaC's symmetry definitions.
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...