3 * Interface to GiNaC's initially known functions. */
6 * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef __GINAC_INIFCNS_H__
24 #define __GINAC_INIFCNS_H__
32 /** Complex conjugate. */
33 DECLARE_FUNCTION_1P(conjugate_function)
35 /** Absolute value. */
36 DECLARE_FUNCTION_1P(abs)
39 DECLARE_FUNCTION_1P(step)
42 DECLARE_FUNCTION_1P(csgn)
44 /** Eta function: log(a*b) == log(a) + log(b) + eta(a, b). */
45 DECLARE_FUNCTION_2P(eta)
48 DECLARE_FUNCTION_1P(sin)
51 DECLARE_FUNCTION_1P(cos)
54 DECLARE_FUNCTION_1P(tan)
56 /** Exponential function. */
57 DECLARE_FUNCTION_1P(exp)
59 /** Natural logarithm. */
60 DECLARE_FUNCTION_1P(log)
62 /** Inverse sine (arc sine). */
63 DECLARE_FUNCTION_1P(asin)
65 /** Inverse cosine (arc cosine). */
66 DECLARE_FUNCTION_1P(acos)
68 /** Inverse tangent (arc tangent). */
69 DECLARE_FUNCTION_1P(atan)
71 /** Inverse tangent with two arguments. */
72 DECLARE_FUNCTION_2P(atan2)
74 /** Hyperbolic Sine. */
75 DECLARE_FUNCTION_1P(sinh)
77 /** Hyperbolic Cosine. */
78 DECLARE_FUNCTION_1P(cosh)
80 /** Hyperbolic Tangent. */
81 DECLARE_FUNCTION_1P(tanh)
83 /** Inverse hyperbolic Sine (area hyperbolic sine). */
84 DECLARE_FUNCTION_1P(asinh)
86 /** Inverse hyperbolic Cosine (area hyperbolic cosine). */
87 DECLARE_FUNCTION_1P(acosh)
89 /** Inverse hyperbolic Tangent (area hyperbolic tangent). */
90 DECLARE_FUNCTION_1P(atanh)
93 DECLARE_FUNCTION_1P(Li2)
96 DECLARE_FUNCTION_1P(Li3)
98 /** Derivatives of Riemann's Zeta-function. */
99 DECLARE_FUNCTION_2P(zetaderiv)
101 // overloading at work: we cannot use the macros here
102 /** Multiple zeta value including Riemann's zeta-function. */
103 class zeta1_SERIAL { public: static unsigned serial; };
104 template<typename T1>
105 inline function zeta(const T1& p1) {
106 return function(zeta1_SERIAL::serial, ex(p1));
108 /** Alternating Euler sum or colored MZV. */
109 class zeta2_SERIAL { public: static unsigned serial; };
110 template<typename T1, typename T2>
111 inline function zeta(const T1& p1, const T2& p2) {
112 return function(zeta2_SERIAL::serial, ex(p1), ex(p2));
115 template<> inline bool is_the_function<zeta_SERIAL>(const ex& x)
117 return is_the_function<zeta1_SERIAL>(x) || is_the_function<zeta2_SERIAL>(x);
120 // overloading at work: we cannot use the macros here
121 /** Generalized multiple polylogarithm. */
122 class G2_SERIAL { public: static unsigned serial; };
123 template<typename T1, typename T2>
124 inline function G(const T1& x, const T2& y) {
125 return function(G2_SERIAL::serial, ex(x), ex(y));
127 /** Generalized multiple polylogarithm with explicit imaginary parts. */
128 class G3_SERIAL { public: static unsigned serial; };
129 template<typename T1, typename T2, typename T3>
130 inline function G(const T1& x, const T2& s, const T3& y) {
131 return function(G3_SERIAL::serial, ex(x), ex(s), ex(y));
134 template<> inline bool is_the_function<G_SERIAL>(const ex& x)
136 return is_the_function<G2_SERIAL>(x) || is_the_function<G3_SERIAL>(x);
139 /** Polylogarithm and multiple polylogarithm. */
140 DECLARE_FUNCTION_2P(Li)
142 /** Nielsen's generalized polylogarithm. */
143 DECLARE_FUNCTION_3P(S)
145 /** Harmonic polylogarithm. */
146 DECLARE_FUNCTION_2P(H)
148 /** Gamma-function. */
149 DECLARE_FUNCTION_1P(lgamma)
150 DECLARE_FUNCTION_1P(tgamma)
152 /** Beta-function. */
153 DECLARE_FUNCTION_2P(beta)
155 // overloading at work: we cannot use the macros here
156 /** Psi-function (aka digamma-function). */
157 class psi1_SERIAL { public: static unsigned serial; };
158 template<typename T1>
159 inline function psi(const T1 & p1) {
160 return function(psi1_SERIAL::serial, ex(p1));
162 /** Derivatives of Psi-function (aka polygamma-functions). */
163 class psi2_SERIAL { public: static unsigned serial; };
164 template<typename T1, typename T2>
165 inline function psi(const T1 & p1, const T2 & p2) {
166 return function(psi2_SERIAL::serial, ex(p1), ex(p2));
169 template<> inline bool is_the_function<psi_SERIAL>(const ex & x)
171 return is_the_function<psi1_SERIAL>(x) || is_the_function<psi2_SERIAL>(x);
174 /** Factorial function. */
175 DECLARE_FUNCTION_1P(factorial)
177 /** Binomial function. */
178 DECLARE_FUNCTION_2P(binomial)
180 /** Order term function (for truncated power series). */
181 DECLARE_FUNCTION_1P(Order)
183 ex lsolve(const ex &eqns, const ex &symbols, unsigned options = solve_algo::automatic);
185 /** Find a real root of real-valued function f(x) numerically within a given
186 * interval. The function must change sign across interval. Uses Newton-
187 * Raphson method combined with bisection in order to guarantee convergence.
189 * @param f Function f(x)
190 * @param x Symbol f(x)
191 * @param x1 lower interval limit
192 * @param x2 upper interval limit
193 * @exception runtime_error (if interval is invalid). */
194 const numeric fsolve(const ex& f, const symbol& x, const numeric& x1, const numeric& x2);
196 /** Check whether a function is the Order (O(n)) function. */
197 inline bool is_order_function(const ex & e)
199 return is_ex_the_function(e, Order);
202 /** Converts a given list containing parameters for H in Remiddi/Vermaseren notation into
203 * the corresponding GiNaC functions.
205 ex convert_H_to_Li(const ex& parameterlst, const ex& arg);
209 #endif // ndef __GINAC_INIFCNS_H__