]> www.ginac.de Git - ginac.git/blob - ginac/inifcns.h
* Make fsolve() accept relational objects as first arguments.
[ginac.git] / ginac / inifcns.h
1 /** @file inifcns.h
2  *
3  *  Interface to GiNaC's initially known functions. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #ifndef __GINAC_INIFCNS_H__
24 #define __GINAC_INIFCNS_H__
25
26 #include "numeric.h"
27 #include "function.h"
28 #include "ex.h"
29
30 namespace GiNaC {
31
32 /** Complex conjugate. */
33 DECLARE_FUNCTION_1P(conjugate_function)
34         
35 /** Absolute value. */
36 DECLARE_FUNCTION_1P(abs)
37         
38 /** Complex sign. */
39 DECLARE_FUNCTION_1P(csgn)
40
41 /** Eta function: log(a*b) == log(a) + log(b) + eta(a, b). */
42 DECLARE_FUNCTION_2P(eta)
43
44 /** Sine. */
45 DECLARE_FUNCTION_1P(sin)
46
47 /** Cosine. */
48 DECLARE_FUNCTION_1P(cos)
49
50 /** Tangent. */
51 DECLARE_FUNCTION_1P(tan)
52
53 /** Exponential function. */
54 DECLARE_FUNCTION_1P(exp)
55
56 /** Natural logarithm. */
57 DECLARE_FUNCTION_1P(log)
58
59 /** Inverse sine (arc sine). */
60 DECLARE_FUNCTION_1P(asin)
61
62 /** Inverse cosine (arc cosine). */
63 DECLARE_FUNCTION_1P(acos)
64
65 /** Inverse tangent (arc tangent). */
66 DECLARE_FUNCTION_1P(atan)
67
68 /** Inverse tangent with two arguments. */
69 DECLARE_FUNCTION_2P(atan2)
70
71 /** Hyperbolic Sine. */
72 DECLARE_FUNCTION_1P(sinh)
73
74 /** Hyperbolic Cosine. */
75 DECLARE_FUNCTION_1P(cosh)
76
77 /** Hyperbolic Tangent. */
78 DECLARE_FUNCTION_1P(tanh)
79
80 /** Inverse hyperbolic Sine (area hyperbolic sine). */
81 DECLARE_FUNCTION_1P(asinh)
82
83 /** Inverse hyperbolic Cosine (area hyperbolic cosine). */
84 DECLARE_FUNCTION_1P(acosh)
85
86 /** Inverse hyperbolic Tangent (area hyperbolic tangent). */
87 DECLARE_FUNCTION_1P(atanh)
88
89 /** Dilogarithm. */
90 DECLARE_FUNCTION_1P(Li2)
91
92 /** Trilogarithm. */
93 DECLARE_FUNCTION_1P(Li3)
94
95 /** Derivatives of Riemann's Zeta-function. */
96 DECLARE_FUNCTION_2P(zetaderiv)
97
98 // overloading at work: we cannot use the macros here
99 /** Multiple zeta value including Riemann's zeta-function. */
100 class zeta1_SERIAL { public: static unsigned serial; };
101 template<typename T1>
102 inline function zeta(const T1& p1) {
103         return function(zeta1_SERIAL::serial, ex(p1));
104 }
105 /** Alternating Euler sum or colored MZV. */
106 class zeta2_SERIAL { public: static unsigned serial; };
107 template<typename T1, typename T2>
108 inline function zeta(const T1& p1, const T2& p2) {
109         return function(zeta2_SERIAL::serial, ex(p1), ex(p2));
110 }
111 class zeta_SERIAL;
112 template<> inline bool is_the_function<zeta_SERIAL>(const ex& x)
113 {
114         return is_the_function<zeta1_SERIAL>(x) || is_the_function<zeta2_SERIAL>(x);
115 }
116
117 // overloading at work: we cannot use the macros here
118 /** Generalized multiple polylogarithm. */
119 class G2_SERIAL { public: static unsigned serial; };
120 template<typename T1, typename T2>
121 inline function G(const T1& x, const T2& y) {
122         return function(G2_SERIAL::serial, ex(x), ex(y));
123 }
124 /** Generalized multiple polylogarithm with explicit imaginary parts. */
125 class G3_SERIAL { public: static unsigned serial; };
126 template<typename T1, typename T2, typename T3>
127 inline function G(const T1& x, const T2& s, const T3& y) {
128         return function(G3_SERIAL::serial, ex(x), ex(s), ex(y));
129 }
130 class G_SERIAL;
131 template<> inline bool is_the_function<G_SERIAL>(const ex& x)
132 {
133         return is_the_function<G2_SERIAL>(x) || is_the_function<G3_SERIAL>(x);
134 }
135
136 /** Polylogarithm and multiple polylogarithm. */
137 DECLARE_FUNCTION_2P(Li)
138
139 /** Nielsen's generalized polylogarithm. */
140 DECLARE_FUNCTION_3P(S)
141
142 /** Harmonic polylogarithm. */
143 DECLARE_FUNCTION_2P(H)
144
145 /** Gamma-function. */
146 DECLARE_FUNCTION_1P(lgamma)
147 DECLARE_FUNCTION_1P(tgamma)
148
149 /** Beta-function. */
150 DECLARE_FUNCTION_2P(beta)
151
152 // overloading at work: we cannot use the macros here
153 /** Psi-function (aka digamma-function). */
154 class psi1_SERIAL { public: static unsigned serial; };
155 template<typename T1>
156 inline function psi(const T1 & p1) {
157         return function(psi1_SERIAL::serial, ex(p1));
158 }
159 /** Derivatives of Psi-function (aka polygamma-functions). */
160 class psi2_SERIAL { public: static unsigned serial; };
161 template<typename T1, typename T2>
162 inline function psi(const T1 & p1, const T2 & p2) {
163         return function(psi2_SERIAL::serial, ex(p1), ex(p2));
164 }
165 class psi_SERIAL;
166 template<> inline bool is_the_function<psi_SERIAL>(const ex & x)
167 {
168         return is_the_function<psi1_SERIAL>(x) || is_the_function<psi2_SERIAL>(x);
169 }
170         
171 /** Factorial function. */
172 DECLARE_FUNCTION_1P(factorial)
173
174 /** Binomial function. */
175 DECLARE_FUNCTION_2P(binomial)
176
177 /** Order term function (for truncated power series). */
178 DECLARE_FUNCTION_1P(Order)
179
180 ex lsolve(const ex &eqns, const ex &symbols, unsigned options = solve_algo::automatic);
181
182 /** Find a real root of real-valued function f(x) numerically within a given
183  *  interval. The function must change sign across interval. Uses Newton-
184  *  Raphson method combined with bisection in order to guarantee convergence.
185  *
186  *  @param f  Function f(x)
187  *  @param x  Symbol f(x)
188  *  @param x1  lower interval limit
189  *  @param x2  upper interval limit
190  *  @exception runtime_error (if interval is invalid). */
191 const numeric fsolve(const ex& f, const symbol& x, const numeric& x1, const numeric& x2);
192
193 /** Check whether a function is the Order (O(n)) function. */
194 inline bool is_order_function(const ex & e)
195 {
196         return is_ex_the_function(e, Order);
197 }
198
199 /** Converts a given list containing parameters for H in Remiddi/Vermaseren notation into
200  *  the corresponding GiNaC functions.
201  */
202 ex convert_H_to_Li(const ex& parameterlst, const ex& arg);
203
204 } // namespace GiNaC
205
206 #endif // ndef __GINAC_INIFCNS_H__