49 if (is_exactly_a<numeric>(arg)) {
52 return conjugate_function(arg).hold();
62 c.s <<
"\\bar{"; arg.
print(
c);
c.s <<
"}";
78 vec_arg.push_back(arg);
119 return arg.
info(inf);
137 set_name(
"conjugate",
"conjugate"));
145 if (is_exactly_a<numeric>(arg)) {
146 return ex_to<numeric>(arg).real();
148 return real_part_function(arg).hold();
158 c.s <<
"\\Re"; arg.
print(
c);
c.s <<
"";
163 return real_part_function(arg).hold();
168 return real_part_function(arg).hold();
180 return real_part_function(arg.
diff(s));
183 vec_arg.push_back(arg);
195 set_name(
"real_part",
"real_part"));
203 if (is_exactly_a<numeric>(arg)) {
204 return ex_to<numeric>(arg).imag();
206 return imag_part_function(arg).hold();
216 c.s <<
"\\Im"; arg.
print(
c);
c.s <<
"";
221 return imag_part_function(arg).hold();
226 return imag_part_function(arg).hold();
238 return imag_part_function(arg.
diff(s));
241 vec_arg.push_back(arg);
253 set_name(
"imag_part",
"imag_part"));
261 if (is_exactly_a<numeric>(arg))
262 return abs(ex_to<numeric>(arg));
269 if (is_exactly_a<numeric>(arg))
270 return abs(ex_to<numeric>(arg));
284 if (is_exactly_a<power>(arg)) {
285 const ex& base = arg.
op(0);
286 const ex& exponent = arg.
op(1);
292 return abs(arg.
op(0));
303 && is_exactly_a<mul>(arg)) {
305 prodseq.reserve(arg.
nops());
310 prodseq.push_back(
abs(*i));
323 ex diff_arg = arg.
diff(s);
329 c.s <<
"{|"; arg.
print(
c);
c.s <<
"|}";
334 c.s <<
"fabs("; arg.
print(
c);
c.s <<
")";
370 return arg.
info(inf);
409 if (is_exactly_a<numeric>(arg))
410 return step(ex_to<numeric>(arg));
417 if (is_exactly_a<numeric>(arg))
418 return step(ex_to<numeric>(arg));
420 else if (is_exactly_a<mul>(arg) &&
421 is_exactly_a<numeric>(arg.
op(arg.
nops()-1))) {
451 && ex_to<numeric>(arg_pt).real().is_zero()
453 throw (std::domain_error(
"step_series(): on imaginary axis"));
456 return pseries(rel, std::move(seq));
487 if (is_exactly_a<numeric>(arg))
488 return csgn(ex_to<numeric>(arg));
490 return csgn(arg).hold();
495 if (is_exactly_a<numeric>(arg))
496 return csgn(ex_to<numeric>(arg));
498 else if (is_exactly_a<mul>(arg) &&
499 is_exactly_a<numeric>(arg.
op(arg.
nops()-1))) {
504 return csgn(arg/oc).hold();
507 return -
csgn(arg/oc).hold();
512 return csgn(
I*arg/oc).hold();
515 return -
csgn(
I*arg/oc).hold();
519 return csgn(arg).hold();
529 && ex_to<numeric>(arg_pt).real().is_zero()
531 throw (std::domain_error(
"csgn_series(): on imaginary axis"));
534 return pseries(rel, std::move(seq));
539 return csgn(arg).hold();
544 return csgn(arg).hold();
556 return csgn(arg).hold();
587 const numeric nx = ex_to<numeric>(
x);
588 const numeric ny = ex_to<numeric>(y);
589 const numeric nxy = ex_to<numeric>(
x*y);
601 return eta(
x,y).hold();
612 const numeric nx = ex_to<numeric>(
x);
613 const numeric ny = ex_to<numeric>(y);
614 const numeric nxy = ex_to<numeric>(
x*y);
626 return eta(
x,y).hold();
639 throw (std::domain_error(
"eta_series(): on discontinuity"));
641 return pseries(rel, std::move(seq));
646 return -eta(
x, y).hold();
656 return -
I*eta(
x, y).
hold();
675 if (is_exactly_a<numeric>(
x))
676 return Li2(ex_to<numeric>(
x));
704 return Li2(ex_to<numeric>(
x));
739 for (
int i=1; i<
order; ++i)
745 ser +=
pseries(rel, std::move(nseq));
763 for (
int i=1; i<
order; ++i)
769 ser +=
pseries(rel, std::move(nseq));
775 ex_to<numeric>(x_pt).
is_real() && ex_to<numeric>(x_pt)>1) {
779 const symbol &s = ex_to<symbol>(rel.
lhs());
780 const ex point = rel.
rhs();
787 for (
size_t i=1; i<replarg.
nops()-1; ++i)
791 return pseries(rel, std::move(seq));
805 if (is_exactly_a<numeric>(
x) &&
809 return conjugate_function(
Li2(
x)).hold();
817 latex_name(
"\\mathrm{Li}_2"));
827 return Li3(
x).hold();
831 latex_name(
"\\mathrm{Li}_3"));
845 return zetaderiv(
n,
x).
hold();
852 if (deriv_param==0) {
854 throw(std::logic_error(
"cannot diff zetaderiv(n,x) with respect to n"));
857 return zetaderiv(
n+1,
x);
862 latex_name(
"\\zeta^\\prime"));
875 if (is_exactly_a<numeric>(
x))
883 if (is_exactly_a<symbol>(
x) ||
884 is_exactly_a<constant>(
x) ||
885 is_exactly_a<function>(
x)) {
928 const unsigned N = y.
to_int();
929 if (N == 0)
return _ex1;
930 if (N == 1)
return x;
932 for (
unsigned i = 2; i <= N; ++i)
933 t = (t * (
x + i - y - 1)).
expand() / i;
944 if (is_exactly_a<numeric>(y)) {
945 if (is_exactly_a<numeric>(
x) && ex_to<numeric>(
x).
is_integer())
946 return binomial(ex_to<numeric>(
x), ex_to<numeric>(y));
983 if (is_exactly_a<numeric>(
x)) {
986 return Order(
_ex1).hold();
989 }
else if (is_exactly_a<mul>(
x)) {
990 const mul &
m = ex_to<mul>(
x);
992 if (is_exactly_a<numeric>(
m.op(
m.nops() - 1)))
993 return Order(
x /
m.op(
m.nops() - 1)).hold();
995 return Order(
x).hold();
1002 const symbol &s = ex_to<symbol>(
r.lhs());
1004 return pseries(
r, std::move(new_seq));
1009 return Order(
x).hold();
1014 return Order(
x).hold();
1021 return Order(
x).hold();
1028 return Order(
pow(
x, e));
1040 return Order(arg.
diff(s));
1045 latex_name(
"\\mathcal{O}").
1060 if (is_a<symbol>(e)) {
1063 for (
const ex &sube : e) {
1075 return s.find(e) !=
s.end();
1084 throw(std::invalid_argument(
"lsolve(): 2nd argument must be a symbol"));
1090 return sol.
op(0).
op(1);
1095 throw(std::invalid_argument(
"lsolve(): 1st argument must be a list, a sequence, or an equation"));
1097 for (
size_t i=0; i<eqns.
nops(); i++) {
1099 throw(std::invalid_argument(
"lsolve(): 1st argument must be a list of equations"));
1103 throw(std::invalid_argument(
"lsolve(): 2nd argument must be a list, a sequence, or a symbol"));
1105 for (
size_t i=0; i<symbols.
nops(); i++) {
1107 throw(std::invalid_argument(
"lsolve(): 2nd argument must be a list or a sequence of symbols"));
1116 for (
size_t r=0;
r<eqns.
nops();
r++) {
1120 for (
size_t c=0;
c<symbols.
nops();
c++) {
1123 const ex co = eq.
coeff(ex_to<symbol>(symbols.
op(
c)),1);
1124 linpart -= co*symbols.
op(
c);
1127 linpart = linpart.
expand();
1128 rhs(
r,0) = -linpart;
1134 for (
size_t i=0; i<symbols.
nops(); i++) {
1135 vars(i,0) = symbols.
op(i);
1136 if (sys_syms.
has(symbols.
op(i)))
1137 throw(std::logic_error(
"lsolve: system is not linear"));
1138 if (rhs_syms.
has(symbols.
op(i)))
1139 throw(std::logic_error(
"lsolve: system is not linear"));
1145 }
catch (
const std::runtime_error & e) {
1155 for (
size_t i=0; i<symbols.
nops(); i++)
1156 sollist.
append(symbols.
op(i)==solution(i,0));
1169 throw std::runtime_error(
"fsolve(): interval not bounded by real numbers");
1172 throw std::runtime_error(
"fsolve(): vanishing interval");
1177 numeric xx[2] = { x1<x2 ? x1 : x2,
1180 if (is_a<relational>(f_in)) {
1181 f = f_in.
lhs()-f_in.
rhs();
1187 if (!is_a<numeric>(fx_[0]) || !is_a<numeric>(fx_[1])) {
1188 throw std::runtime_error(
"fsolve(): function does not evaluate numerically");
1190 numeric fx[2] = { ex_to<numeric>(fx_[0]),
1191 ex_to<numeric>(fx_[1]) };
1193 throw std::runtime_error(
"fsolve(): function evaluates to complex values at interval boundaries");
1195 if (fx[0]*fx[1]>=0) {
1196 throw std::runtime_error(
"fsolve(): function does not change sign at interval boundaries");
1209 if (!is_a<numeric>(dx_))
1210 throw std::runtime_error(
"fsolve(): function derivative does not evaluate numerically");
1211 xx[side] += ex_to<numeric>(dx_);
1213 bool bad_shot = (side == 0 && xx[0] < xxprev) ||
1214 (side == 1 && xx[1] > xxprev) || xx[0] > xx[1];
1221 if (!is_a<numeric>(f_x))
1222 throw std::runtime_error(
"fsolve(): function does not evaluate numerically");
1223 fx[side] = ex_to<numeric>(f_x);
1235 if (!is_a<numeric>(dx_))
1236 throw std::runtime_error(
"fsolve(): function derivative does not evaluate numerically [2]");
1237 xx[side] += ex_to<numeric>(dx_);
1240 if (!is_a<numeric>(f_x))
1241 throw std::runtime_error(
"fsolve(): function does not evaluate numerically [2]");
1242 fx[side] = ex_to<numeric>(f_x);
1244 if ((fx[side]<0 && fx[!side]<0) || (fx[side]>0 && fx[!side]>0)) {
1263 constexpr double secant_weight = 0.984375;
1264 numeric xxmid = (1-secant_weight)*0.5*(xx[0]+xx[1])
1265 + secant_weight*(xx[0]+fx[0]*(xx[0]-xx[1])/(fx[1]-fx[0]));
1267 if (!is_a<numeric>(fxmid_))
1268 throw std::runtime_error(
"fsolve(): function does not evaluate numerically [3]");
1269 numeric fxmid = ex_to<numeric>(fxmid_);
1274 if ((fxmid<0 && fx[side]>0) || (fxmid>0 && fx[side]<0)) {
1282 }
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 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)
REGISTER_FUNCTION(conjugate_function, eval_func(conjugate_eval). evalf_func(conjugate_evalf). expl_derivative_func(conjugate_expl_derivative). info_func(conjugate_info). print_func< print_latex >(conjugate_print_latex). conjugate_func(conjugate_conjugate). real_part_func(conjugate_real_part). imag_part_func(conjugate_imag_part). set_name("conjugate","conjugate"))
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...