From: Richard Kreckel Date: Tue, 21 Mar 2000 19:30:22 +0000 (+0000) Subject: - gamma() -> Gamma(). X-Git-Tag: release_0-6-0~56 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=61434b009f39c40ea85ae7bb4ec14d8d203e2a85;ds=sidebyside - gamma() -> Gamma(). - EulerGamma -> gamma. - beta() -> Beta(). - Version -> 0.6.0 in order to make it clear there were *real* changes. --- diff --git a/NEWS b/NEWS index 4467ebcd..0824232a 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ This file records noteworthy changes. +0.6.0 (...) +* Important interface changes: + gamma() -> Gamma() + EulerGamma -> gamma + beta() -> Beta() + 0.5.4 (15 March 2000) * Some algorithms in class matrix (notably determinant) were replaced by less brain-dead ones and should now have much better performance. diff --git a/check/exam_inifcns.cpp b/check/exam_inifcns.cpp index d91c02c0..16788c54 100644 --- a/check/exam_inifcns.cpp +++ b/check/exam_inifcns.cpp @@ -100,37 +100,37 @@ static unsigned inifcns_consist_gamma(void) unsigned result = 0; ex e; - e = gamma(ex(1)); + e = Gamma(ex(1)); for (int i=2; i<8; ++i) - e += gamma(ex(i)); + e += Gamma(ex(i)); if (e != numeric(874)) { - clog << "gamma(1)+...+gamma(7) erroneously returned " + clog << "Gamma(1)+...+Gamma(7) erroneously returned " << e << " instead of 874" << endl; ++result; } - e = gamma(ex(1)); + e = Gamma(ex(1)); for (int i=2; i<8; ++i) - e *= gamma(ex(i)); + e *= Gamma(ex(i)); if (e != numeric(24883200)) { - clog << "gamma(1)*...*gamma(7) erroneously returned " + clog << "Gamma(1)*...*Gamma(7) erroneously returned " << e << " instead of 24883200" << endl; ++result; } - e = gamma(ex(numeric(5, 2)))*gamma(ex(numeric(9, 2)))*64; + e = Gamma(ex(numeric(5, 2)))*Gamma(ex(numeric(9, 2)))*64; if (e != 315*Pi) { - clog << "64*gamma(5/2)*gamma(9/2) erroneously returned " + clog << "64*Gamma(5/2)*Gamma(9/2) erroneously returned " << e << " instead of 315*Pi" << endl; ++result; } - e = gamma(ex(numeric(-13, 2))); + e = Gamma(ex(numeric(-13, 2))); for (int i=-13; i<7; i=i+2) - e += gamma(ex(numeric(i, 2))); - e = (e*gamma(ex(numeric(15, 2)))*numeric(512)); + e += Gamma(ex(numeric(i, 2))); + e = (e*Gamma(ex(numeric(15, 2)))*numeric(512)); if (e != numeric(633935)*Pi) { - clog << "512*(gamma(-13/2)+...+gamma(5/2))*gamma(15/2) erroneously returned " + clog << "512*(Gamma(-13/2)+...+Gamma(5/2))*Gamma(15/2) erroneously returned " << e << " instead of 633935*Pi" << endl; ++result; } @@ -147,11 +147,11 @@ static unsigned inifcns_consist_psi(void) ex e, f; // We check psi(1) and psi(1/2) implicitly by calculating the curious - // little identity gamma(1)'/gamma(1) - gamma(1/2)'/gamma(1/2) == 2*log(2). - e += (gamma(x).diff(x)/gamma(x)).subs(x==numeric(1)); - e -= (gamma(x).diff(x)/gamma(x)).subs(x==numeric(1,2)); + // little identity Gamma(1)'/Gamma(1) - Gamma(1/2)'/Gamma(1/2) == 2*log(2). + e += (Gamma(x).diff(x)/Gamma(x)).subs(x==numeric(1)); + e -= (Gamma(x).diff(x)/Gamma(x)).subs(x==numeric(1,2)); if (e!=2*log(2)) { - clog << "gamma(1)'/gamma(1) - gamma(1/2)'/gamma(1/2) erroneously returned " + clog << "Gamma(1)'/Gamma(1) - Gamma(1/2)'/Gamma(1/2) erroneously returned " << e << " instead of 2*log(2)" << endl; ++result; } diff --git a/check/exam_pseries.cpp b/check/exam_pseries.cpp index efcc0fc1..a5625efa 100644 --- a/check/exam_pseries.cpp +++ b/check/exam_pseries.cpp @@ -153,32 +153,32 @@ static unsigned exam_series5(void) unsigned result = 0; ex e, d; - // gamma(-1): - e = gamma(2*x); + // Gamma(-1): + e = Gamma(2*x); d = pow(x+1,-1)*numeric(1,4) + pow(x+1,0)*(numeric(3,4) - - numeric(1,2)*EulerGamma) + + numeric(1,2)*gamma) + pow(x+1,1)*(numeric(7,4) - - numeric(3,2)*EulerGamma + - numeric(1,2)*pow(EulerGamma,2) + + numeric(3,2)*gamma + + numeric(1,2)*pow(gamma,2) + numeric(1,12)*pow(Pi,2)) + pow(x+1,2)*(numeric(15,4) - - numeric(7,2)*EulerGamma - - numeric(1,3)*pow(EulerGamma,3) + + numeric(7,2)*gamma - + numeric(1,3)*pow(gamma,3) + numeric(1,4)*pow(Pi,2) + - numeric(3,2)*pow(EulerGamma,2) - - numeric(1,6)*pow(Pi,2)*EulerGamma - + numeric(3,2)*pow(gamma,2) - + numeric(1,6)*pow(Pi,2)*gamma - numeric(2,3)*zeta(3)) + - pow(x+1,3)*(numeric(31,4) - pow(EulerGamma,3) - - numeric(15,2)*EulerGamma + - numeric(1,6)*pow(EulerGamma,4) + - numeric(7,2)*pow(EulerGamma,2) + + pow(x+1,3)*(numeric(31,4) - pow(gamma,3) - + numeric(15,2)*gamma + + numeric(1,6)*pow(gamma,4) + + numeric(7,2)*pow(gamma,2) + numeric(7,12)*pow(Pi,2) - - numeric(1,2)*pow(Pi,2)*EulerGamma - + numeric(1,2)*pow(Pi,2)*gamma - numeric(2)*zeta(3) + - numeric(1,6)*pow(EulerGamma,2)*pow(Pi,2) + + numeric(1,6)*pow(gamma,2)*pow(Pi,2) + numeric(1,40)*pow(Pi,4) + - numeric(4,3)*zeta(3)*EulerGamma) + + numeric(4,3)*zeta(3)*gamma) + Order(pow(x+1,4)); result += check_series(e, -1, d, 4); diff --git a/check/time_gammaseries.cpp b/check/time_gammaseries.cpp index 6da460f6..5fb3ddc9 100644 --- a/check/time_gammaseries.cpp +++ b/check/time_gammaseries.cpp @@ -1,6 +1,6 @@ /** @file time_gammaseries.cpp * - * Some timings on series expansion of the gamma function around a pole. */ + * Some timings on series expansion of the Gamma function around a pole. */ /* * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany @@ -22,12 +22,12 @@ #include "times.h" -unsigned gammaseries(unsigned order) +unsigned Gammaseries(unsigned order) { unsigned result = 0; symbol x; - ex myseries = series(gamma(x),x,0,order); + ex myseries = series(Gamma(x),x,0,order); // compute the last coefficient numerically: ex last_coeff = myseries.coeff(x,order-1).evalf(); // compute a bound for that coefficient using a variation of the leading @@ -35,7 +35,7 @@ unsigned gammaseries(unsigned order) ex bound = evalf(exp(ex(-.57721566490153286*(order-1)))/(order-1)); if (evalf(abs((last_coeff-pow(-1,order))/bound)) > numeric(1)) { clog << "The " << order-1 - << "th order coefficient in the power series expansion of gamma(0) was erroneously found to be " + << "th order coefficient in the power series expansion of Gamma(0) was erroneously found to be " << last_coeff << ", violating a simple estimate." << endl; ++result; } @@ -47,8 +47,8 @@ unsigned time_gammaseries(void) { unsigned result = 0; - cout << "timing Laurent series expansion of gamma function" << flush; - clog << "-------Laurent series expansion of gamma function:" << endl; + cout << "timing Laurent series expansion of Gamma function" << flush; + clog << "-------Laurent series expansion of Gamma function:" << endl; vector sizes; vector times; @@ -61,7 +61,7 @@ unsigned time_gammaseries(void) for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) { omega.start(); - result += gammaseries(*i); + result += Gammaseries(*i); times.push_back(omega.read()); cout << '.' << flush; } diff --git a/check/times.ref b/check/times.ref index abadcbe4..e45683b7 100644 --- a/check/times.ref +++ b/check/times.ref @@ -1,6 +1,6 @@ -------commutative expansion and substitution: (no output) --------Laurent series expansion of gamma function: +-------Laurent series expansion of Gamma function: (no output) -------determinant of univariate symbolic Vandermonde matrices: (no output) diff --git a/configure b/configure index a48a9513..ca421d09 100755 --- a/configure +++ b/configure @@ -544,10 +544,10 @@ fi GINACLIB_MAJOR_VERSION=0 -GINACLIB_MINOR_VERSION=5 -GINACLIB_MICRO_VERSION=4 -GINACLIB_INTERFACE_AGE=4 -GINACLIB_BINARY_AGE=4 +GINACLIB_MINOR_VERSION=6 +GINACLIB_MICRO_VERSION=0 +GINACLIB_INTERFACE_AGE=0 +GINACLIB_BINARY_AGE=0 GINACLIB_VERSION=$GINACLIB_MAJOR_VERSION.$GINACLIB_MINOR_VERSION.$GINACLIB_MICRO_VERSION diff --git a/configure.in b/configure.in index d203c3ac..432ca153 100644 --- a/configure.in +++ b/configure.in @@ -18,10 +18,10 @@ dnl autoconf sees "AC_MAJOR_VERSION" and complains about an undefined macro dnl (don't we all *love* M4?)... GINACLIB_MAJOR_VERSION=0 -GINACLIB_MINOR_VERSION=5 -GINACLIB_MICRO_VERSION=4 -GINACLIB_INTERFACE_AGE=4 -GINACLIB_BINARY_AGE=4 +GINACLIB_MINOR_VERSION=6 +GINACLIB_MICRO_VERSION=0 +GINACLIB_INTERFACE_AGE=0 +GINACLIB_BINARY_AGE=0 GINACLIB_VERSION=$GINACLIB_MAJOR_VERSION.$GINACLIB_MINOR_VERSION.$GINACLIB_MICRO_VERSION AC_SUBST(GINACLIB_MAJOR_VERSION) diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index 1d060689..89a7b29d 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -387,15 +387,15 @@ tan(x)^2+1 x-1/6*x^3+Order(x^4) > series(1/tan(x),x,0,4); x^(-1)-1/3*x+Order(x^2) -> series(gamma(x),x,0,3); -x^(-1)-EulerGamma+(1/12*Pi^2+1/2*EulerGamma^2)*x -+(-1/3*zeta(3)-1/12*Pi^2*EulerGamma-1/6*EulerGamma^3)*x^2+Order(x^3) +> series(Gamma(x),x,0,3); +x^(-1)-gamma+(1/12*Pi^2+1/2*gamma^2)*x+ +(-1/3*zeta(3)-1/12*Pi^2*gamma-1/6*gamma^3)*x^2+Order(x^3) > evalf("); x^(-1)-0.5772156649015328606+(0.9890559953279725555)*x -(0.90747907608088628905)*x^2+Order(x^3) -> series(gamma(2*sin(x)-2),x,Pi/2,6); --(x-1/2*Pi)^(-2)+(-1/12*Pi^2-1/2*EulerGamma^2-1/240)*(x-1/2*Pi)^2 --EulerGamma-1/12+Order((x-1/2*Pi)^3) +> series(Gamma(2*sin(x)-2),x,Pi/2,6); +-(x-1/2*Pi)^(-2)+(-1/12*Pi^2-1/2*gamma^2-1/240)*(x-1/2*Pi)^2 +-gamma-1/12+Order((x-1/2*Pi)^3) @end example Here we have made use of the @command{ginsh}-command @code{"} to pop the @@ -1013,7 +1013,7 @@ following table. @cindex @code{Pi} @cindex @code{Catalan} -@cindex @code{EulerGamma} +@cindex @code{gamma} @cindex @code{evalf()} Constants behave pretty much like symbols except that they return some specific number when the method @code{.evalf()} is called. @@ -1029,7 +1029,7 @@ The predefined known constants are: @item @code{Catalan} @tab Catalan's constant @tab 0.91596559417721901505460351493238411 -@item @code{EulerGamma} +@item @code{gamma} @tab Euler's (or Euler-Mascheroni) constant @tab 0.57721566490153286060651209008240243 @end multitable @@ -1146,11 +1146,11 @@ int main() symbol x("x"), y("y"); ex foo = x+y/2; - cout << "gamma(" << foo << ") -> " << gamma(foo) << endl; + cout << "Gamma(" << foo << ") -> " << Gamma(foo) << endl; ex bar = foo.subs(y==1); - cout << "gamma(" << bar << ") -> " << gamma(bar) << endl; + cout << "Gamma(" << bar << ") -> " << Gamma(bar) << endl; ex foobar = bar.subs(x==7); - cout << "gamma(" << foobar << ") -> " << gamma(foobar) << endl; + cout << "Gamma(" << foobar << ") -> " << Gamma(foobar) << endl; // ... @} @end example @@ -1159,9 +1159,9 @@ This program shows how the function returns itself twice and finally an expression that may be really useful: @example -gamma(x+(1/2)*y) -> gamma(x+(1/2)*y) -gamma(x+1/2) -> gamma(x+1/2) -gamma(15/2) -> (135135/128)*Pi^(1/2) +Gamma(x+(1/2)*y) -> Gamma(x+(1/2)*y) +Gamma(x+1/2) -> Gamma(x+1/2) +Gamma(15/2) -> (135135/128)*Pi^(1/2) @end example @cindex branch cut diff --git a/ginac/constant.cpp b/ginac/constant.cpp index b8543092..b1b9237a 100644 --- a/ginac/constant.cpp +++ b/ginac/constant.cpp @@ -125,8 +125,8 @@ ex constant::unarchive(const archive_node &n, const lst &sym_lst) return Pi; else if (s == Catalan.name) return Catalan; - else if (s == EulerGamma.name) - return EulerGamma; + else if (s == gamma.name) + return gamma; else throw (std::runtime_error("unknown constant '" + s + "' in archive")); } else @@ -244,7 +244,7 @@ const type_info & typeid_constant=typeid(some_constant); /** Pi. (3.14159...) Diverts straight into CLN for evalf(). */ const constant Pi("Pi", PiEvalf); /** Catalan's constant. (0.91597...) Diverts straight into CLN for evalf(). */ -const constant EulerGamma("EulerGamma", EulerGammaEvalf); +const constant gamma("gamma", gammaEvalf); /** Euler's constant. (0.57721...) Sometimes called Euler-Mascheroni constant. * Diverts straight into CLN for evalf(). */ const constant Catalan("Catalan", CatalanEvalf); diff --git a/ginac/constant.h b/ginac/constant.h index 91ede282..aa917e54 100644 --- a/ginac/constant.h +++ b/ginac/constant.h @@ -95,7 +95,7 @@ extern const type_info & typeid_constant; // extern const numeric I; extern const constant Pi; extern const constant Catalan; -extern const constant EulerGamma; +extern const constant gamma; #ifndef NO_NAMESPACE_GINAC } // namespace GiNaC diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index e9e2cad1..e8531a06 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -321,7 +321,7 @@ ex ncpower(const ex &basis, unsigned exponent) /** Force inclusion of functions from initcns_gamma and inifcns_zeta * for static lib (so ginsh will see them). */ -unsigned force_include_gamma = function_index_gamma; +unsigned force_include_gamma = function_index_Gamma; unsigned force_include_zeta1 = function_index_zeta1; #ifndef NO_NAMESPACE_GINAC diff --git a/ginac/inifcns.h b/ginac/inifcns.h index 176f6794..5dfbdaa9 100644 --- a/ginac/inifcns.h +++ b/ginac/inifcns.h @@ -97,10 +97,10 @@ inline function zeta(const ex & p1, const ex & p2) { } /** Gamma-function. */ -DECLARE_FUNCTION_1P(gamma) +DECLARE_FUNCTION_1P(Gamma) /** Beta-function. */ -DECLARE_FUNCTION_2P(beta) +DECLARE_FUNCTION_2P(Beta) // overloading at work: we cannot use the macros /** Psi-function (aka digamma-function). */ diff --git a/ginac/inifcns_gamma.cpp b/ginac/inifcns_gamma.cpp index 7480bf20..fe059a44 100644 --- a/ginac/inifcns_gamma.cpp +++ b/ginac/inifcns_gamma.cpp @@ -42,37 +42,37 @@ namespace GiNaC { // Gamma-function ////////// -static ex gamma_evalf(const ex & x) +static ex Gamma_evalf(const ex & x) { BEGIN_TYPECHECK TYPECHECK(x,numeric) - END_TYPECHECK(gamma(x)) + END_TYPECHECK(Gamma(x)) - return gamma(ex_to_numeric(x)); + return Gamma(ex_to_numeric(x)); } -/** Evaluation of gamma(x). Knows about integer arguments, half-integer +/** Evaluation of Gamma(x). Knows about integer arguments, half-integer * arguments and that's it. Somebody ought to provide some good numerical * evaluation some day... * - * @exception std::domain_error("gamma_eval(): simple pole") */ -static ex gamma_eval(const ex & x) + * @exception std::domain_error("Gamma_eval(): simple pole") */ +static ex Gamma_eval(const ex & x) { if (x.info(info_flags::numeric)) { // trap integer arguments: if (x.info(info_flags::integer)) { - // gamma(n+1) -> n! for postitive n + // Gamma(n+1) -> n! for postitive n if (x.info(info_flags::posint)) { return factorial(ex_to_numeric(x).sub(_num1())); } else { - throw (std::domain_error("gamma_eval(): simple pole")); + throw (std::domain_error("Gamma_eval(): simple pole")); } } // trap half integer arguments: if ((x*2).info(info_flags::integer)) { // trap positive x==(n+1/2) - // gamma(n+1/2) -> Pi^(1/2)*(1*3*..*(2*n-1))/(2^n) + // Gamma(n+1/2) -> Pi^(1/2)*(1*3*..*(2*n-1))/(2^n) if ((x*_ex2()).info(info_flags::posint)) { numeric n = ex_to_numeric(x).sub(_num1_2()); numeric coefficient = doublefactorial(n.mul(_num2()).sub(_num1())); @@ -80,40 +80,40 @@ static ex gamma_eval(const ex & x) return coefficient * pow(Pi,_ex1_2()); } else { // trap negative x==(-n+1/2) - // gamma(-n+1/2) -> Pi^(1/2)*(-2)^n/(1*3*..*(2*n-1)) + // Gamma(-n+1/2) -> Pi^(1/2)*(-2)^n/(1*3*..*(2*n-1)) numeric n = abs(ex_to_numeric(x).sub(_num1_2())); numeric coefficient = pow(_num_2(), n); coefficient = coefficient.div(doublefactorial(n.mul(_num2()).sub(_num1())));; return coefficient*power(Pi,_ex1_2()); } } - // gamma_evalf should be called here once it becomes available + // Gamma_evalf should be called here once it becomes available } - return gamma(x).hold(); + return Gamma(x).hold(); } -static ex gamma_deriv(const ex & x, unsigned deriv_param) +static ex Gamma_deriv(const ex & x, unsigned deriv_param) { GINAC_ASSERT(deriv_param==0); - // d/dx log(gamma(x)) -> psi(x) - // d/dx gamma(x) -> psi(x)*gamma(x) - return psi(x)*gamma(x); + // d/dx log(Gamma(x)) -> psi(x) + // d/dx Gamma(x) -> psi(x)*Gamma(x) + return psi(x)*Gamma(x); } -static ex gamma_series(const ex & x, const symbol & s, const ex & pt, int order) +static ex Gamma_series(const ex & x, const symbol & s, const ex & pt, int order) { // method: // Taylor series where there is no pole falls back to psi function // evaluation. // On a pole at -m use the recurrence relation - // gamma(x) == gamma(x+1) / x + // Gamma(x) == Gamma(x+1) / x // from which follows - // series(gamma(x),x,-m,order) == - // series(gamma(x+m+1)/(x*(x+1)*...*(x+m)),x,-m,order+1); + // series(Gamma(x),x,-m,order) == + // series(Gamma(x+m+1)/(x*(x+1)*...*(x+m)),x,-m,order+1); const ex x_pt = x.subs(s==pt); if (!x_pt.info(info_flags::integer) || x_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() @@ -122,54 +122,54 @@ static ex gamma_series(const ex & x, const symbol & s, const ex & pt, int order) ex ser_denom = _ex1(); for (numeric p; p<=m; ++p) ser_denom *= x+p; - return (gamma(x+m+_ex1())/ser_denom).series(s, pt, order+1); + return (Gamma(x+m+_ex1())/ser_denom).series(s, pt, order+1); } -REGISTER_FUNCTION(gamma, eval_func(gamma_eval). - evalf_func(gamma_evalf). - derivative_func(gamma_deriv). - series_func(gamma_series)); +REGISTER_FUNCTION(Gamma, eval_func(Gamma_eval). + evalf_func(Gamma_evalf). + derivative_func(Gamma_deriv). + series_func(Gamma_series)); ////////// // Beta-function ////////// -static ex beta_evalf(const ex & x, const ex & y) +static ex Beta_evalf(const ex & x, const ex & y) { BEGIN_TYPECHECK TYPECHECK(x,numeric) TYPECHECK(y,numeric) - END_TYPECHECK(beta(x,y)) + END_TYPECHECK(Beta(x,y)) - return gamma(ex_to_numeric(x))*gamma(ex_to_numeric(y))/gamma(ex_to_numeric(x+y)); + return Gamma(ex_to_numeric(x))*Gamma(ex_to_numeric(y))/Gamma(ex_to_numeric(x+y)); } -static ex beta_eval(const ex & x, const ex & y) +static ex Beta_eval(const ex & x, const ex & y) { if (x.info(info_flags::numeric) && y.info(info_flags::numeric)) { - // treat all problematic x and y that may not be passed into gamma, - // because they would throw there although beta(x,y) is well-defined - // using the formula beta(x,y) == (-1)^y * beta(1-x-y, y) + // treat all problematic x and y that may not be passed into Gamma, + // because they would throw there although Beta(x,y) is well-defined + // using the formula Beta(x,y) == (-1)^y * Beta(1-x-y, y) numeric nx(ex_to_numeric(x)); numeric ny(ex_to_numeric(y)); if (nx.is_real() && nx.is_integer() && ny.is_real() && ny.is_integer()) { if (nx.is_negative()) { if (nx<=-ny) - return pow(_num_1(), ny)*beta(1-x-y, y); + return pow(_num_1(), ny)*Beta(1-x-y, y); else - throw (std::domain_error("beta_eval(): simple pole")); + throw (std::domain_error("Beta_eval(): simple pole")); } if (ny.is_negative()) { if (ny<=-nx) - return pow(_num_1(), nx)*beta(1-y-x, x); + return pow(_num_1(), nx)*Beta(1-y-x, x); else - throw (std::domain_error("beta_eval(): simple pole")); + throw (std::domain_error("Beta_eval(): simple pole")); } - return gamma(x)*gamma(y)/gamma(x+y); + return Gamma(x)*Gamma(y)/Gamma(x+y); } // no problem in numerator, but denominator has pole: if ((nx+ny).is_real() && @@ -177,34 +177,34 @@ static ex beta_eval(const ex & x, const ex & y) !(nx+ny).is_positive()) return _ex0(); // everything is ok: - return gamma(x)*gamma(y)/gamma(x+y); + return Gamma(x)*Gamma(y)/Gamma(x+y); } - return beta(x,y).hold(); + return Beta(x,y).hold(); } -static ex beta_deriv(const ex & x, const ex & y, unsigned deriv_param) +static ex Beta_deriv(const ex & x, const ex & y, unsigned deriv_param) { GINAC_ASSERT(deriv_param<2); ex retval; - // d/dx beta(x,y) -> (psi(x)-psi(x+y)) * beta(x,y) + // d/dx Beta(x,y) -> (psi(x)-psi(x+y)) * Beta(x,y) if (deriv_param==0) - retval = (psi(x)-psi(x+y))*beta(x,y); - // d/dy beta(x,y) -> (psi(y)-psi(x+y)) * beta(x,y) + retval = (psi(x)-psi(x+y))*Beta(x,y); + // d/dy Beta(x,y) -> (psi(y)-psi(x+y)) * Beta(x,y) if (deriv_param==1) - retval = (psi(y)-psi(x+y))*beta(x,y); + retval = (psi(y)-psi(x+y))*Beta(x,y); return retval; } -static ex beta_series(const ex & x, const ex & y, const symbol & s, const ex & pt, int order) +static ex Beta_series(const ex & x, const ex & y, const symbol & s, const ex & pt, int order) { // method: - // Taylor series where there is no pole of one of the gamma functions - // falls back to beta function evaluation. Otherwise, fall back to - // gamma series directly. + // Taylor series where there is no pole of one of the Gamma functions + // falls back to Beta function evaluation. Otherwise, fall back to + // Gamma series directly. // FIXME: this could need some testing, maybe it's wrong in some cases? const ex x_pt = x.subs(s==pt); const ex y_pt = y.subs(s==pt); @@ -214,28 +214,28 @@ static ex beta_series(const ex & x, const ex & y, const symbol & s, const ex & p throw do_taylor(); // caught by function::series() // trap the case where x is on a pole directly: if (x.info(info_flags::integer) && !x.info(info_flags::positive)) - x_ser = gamma(x+s).series(s,pt,order); + x_ser = Gamma(x+s).series(s,pt,order); else - x_ser = gamma(x).series(s,pt,order); + x_ser = Gamma(x).series(s,pt,order); // trap the case where y is on a pole directly: if (y.info(info_flags::integer) && !y.info(info_flags::positive)) - y_ser = gamma(y+s).series(s,pt,order); + y_ser = Gamma(y+s).series(s,pt,order); else - y_ser = gamma(y).series(s,pt,order); + y_ser = Gamma(y).series(s,pt,order); // trap the case where y is on a pole directly: if ((x+y).info(info_flags::integer) && !(x+y).info(info_flags::positive)) - xy_ser = gamma(y+x+s).series(s,pt,order); + xy_ser = Gamma(y+x+s).series(s,pt,order); else - xy_ser = gamma(y+x).series(s,pt,order); + xy_ser = Gamma(y+x).series(s,pt,order); // compose the result: return (x_ser*y_ser/xy_ser).series(s,pt,order); } -REGISTER_FUNCTION(beta, eval_func(beta_eval). - evalf_func(beta_evalf). - derivative_func(beta_deriv). - series_func(beta_series)); +REGISTER_FUNCTION(Beta, eval_func(Beta_eval). + evalf_func(Beta_evalf). + derivative_func(Beta_deriv). + series_func(Beta_series)); ////////// @@ -260,11 +260,11 @@ static ex psi1_eval(const ex & x) if (nx.is_integer()) { // integer case if (nx.is_positive()) { - // psi(n) -> 1 + 1/2 +...+ 1/(n-1) - EulerGamma + // psi(n) -> 1 + 1/2 +...+ 1/(n-1) - gamma numeric rat(0); for (numeric i(nx+_num_1()); i.is_positive(); --i) rat += i.inverse(); - return rat-EulerGamma; + return rat-gamma; } else { // for non-positive integers there is a pole: throw (std::domain_error("psi_eval(): simple pole")); @@ -273,11 +273,11 @@ static ex psi1_eval(const ex & x) if ((_num2()*nx).is_integer()) { // half integer case if (nx.is_positive()) { - // psi((2m+1)/2) -> 2/(2m+1) + 2/2m +...+ 2/1 - EulerGamma - 2log(2) + // psi((2m+1)/2) -> 2/(2m+1) + 2/2m +...+ 2/1 - gamma - 2log(2) numeric rat(0); for (numeric i((nx+_num_1())*_num2()); i.is_positive(); i-=_num2()) rat += _num2()*i.inverse(); - return rat-EulerGamma-_ex2()*log(_ex2()); + return rat-gamma-_ex2()*log(_ex2()); } else { // use the recurrence relation // psi(-m-1/2) == psi(-m-1/2+1) - 1 / (-m-1/2) @@ -354,9 +354,9 @@ static ex psi2_eval(const ex & n, const ex & x) // psi(0,x) -> psi(x) if (n.is_zero()) return psi(x); - // psi(-1,x) -> log(gamma(x)) + // psi(-1,x) -> log(Gamma(x)) if (n.is_equal(_ex_1())) - return log(gamma(x)); + return log(Gamma(x)); if (n.info(info_flags::numeric) && n.info(info_flags::posint) && x.info(info_flags::numeric)) { numeric nn = ex_to_numeric(n); diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index e5611eaf..c0649f6f 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -1382,11 +1382,11 @@ const numeric zeta(const numeric & x) } -/** The gamma function. +/** The Gamma function. * This is only a stub! */ -const numeric gamma(const numeric & x) +const numeric Gamma(const numeric & x) { - clog << "gamma(" << x + clog << "Gamma(" << x << "): Does anybody know good way to calculate this numerically?" << endl; return numeric(0); @@ -1732,7 +1732,7 @@ ex PiEvalf(void) /** Floating point evaluation of Euler's constant Gamma. */ -ex EulerGammaEvalf(void) +ex gammaEvalf(void) { return numeric(::cl_eulerconst(cl_default_float_format)); // -> CLN } diff --git a/ginac/numeric.h b/ginac/numeric.h index 95ba4419..bd05bf66 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -232,7 +232,7 @@ const numeric asinh(const numeric & x); const numeric acosh(const numeric & x); const numeric atanh(const numeric & x); const numeric zeta(const numeric & x); -const numeric gamma(const numeric & x); +const numeric Gamma(const numeric & x); const numeric psi(const numeric & x); const numeric psi(const numeric & n, const numeric & x); const numeric factorial(const numeric & n); @@ -322,7 +322,7 @@ inline numeric denom(const numeric & x) // numeric evaluation functions for class constant objects: ex PiEvalf(void); -ex EulerGammaEvalf(void); +ex gammaEvalf(void); ex CatalanEvalf(void); diff --git a/ginsh/ginsh.1 b/ginsh/ginsh.1 index 9df41f77..414f95b4 100644 --- a/ginsh/ginsh.1 +++ b/ginsh/ginsh.1 @@ -82,7 +82,7 @@ Archimedes' Constant .B Catalan Catalan's Constant .TP -.B EulerGamma +.B gamma Euler-Mascheroni Constant .TP .B I diff --git a/ginsh/ginsh_lexer.ll b/ginsh/ginsh_lexer.ll index fddc0b37..94bff017 100644 --- a/ginsh/ginsh_lexer.ll +++ b/ginsh/ginsh_lexer.ll @@ -59,7 +59,7 @@ AN [0-9a-zA-Z_] /* special values */ Pi yylval = Pi; return T_LITERAL; -EulerGamma yylval = EulerGamma; return T_LITERAL; +gamma yylval = gamma; return T_LITERAL; Catalan yylval = Catalan; return T_LITERAL; FAIL yylval = *new fail(); return T_LITERAL; I yylval = I; return T_NUMBER; diff --git a/ginsh/ginsh_parser.yy b/ginsh/ginsh_parser.yy index 6697d6f0..77d21e72 100644 --- a/ginsh/ginsh_parser.yy +++ b/ginsh/ginsh_parser.yy @@ -773,13 +773,13 @@ int main(int argc, char **argv) insert_fcn_help("atan", "inverse tangent function"); insert_fcn_help("atan2", "inverse tangent function with two arguments"); insert_fcn_help("atanh", "inverse hyperbolic tangent function"); - insert_fcn_help("beta", "beta function"); + insert_fcn_help("Beta", "Beta function"); insert_fcn_help("binomial", "binomial function"); insert_fcn_help("cos", "cosine function"); insert_fcn_help("cosh", "hyperbolic cosine function"); insert_fcn_help("exp", "exponential function"); insert_fcn_help("factorial", "factorial function"); - insert_fcn_help("gamma", "gamma function"); + insert_fcn_help("Gamma", "Gamma function"); insert_fcn_help("log", "natural logarithm"); insert_fcn_help("psi", "psi function\npsi(x) is the digamma function, psi(n,x) the nth polygamma function"); insert_fcn_help("sin", "sine function");