* some related stuff. */
/*
- * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "numeric.h"
#include "power.h"
#include "relational.h"
+#include "operators.h"
#include "symbol.h"
#include "symmetry.h"
#include "utils.h"
// from which follows
// series(lgamma(x),x==-m,order) ==
// series(lgamma(x+m+1)-log(x)...-log(x+m)),x==-m,order);
- const ex arg_pt = arg.subs(rel);
+ const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive))
throw do_taylor(); // caught by function::series()
// if we got here we have to care for a simple pole of tgamma(-m):
// from which follows
// series(tgamma(x),x==-m,order) ==
// series(tgamma(x+m+1)/(x*(x+1)*...*(x+m)),x==-m,order+1);
- const ex arg_pt = arg.subs(rel);
+ const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive))
throw do_taylor(); // caught by function::series()
// if we got here we have to care for a simple pole at -m:
static ex beta_eval(const ex & x, const ex & y)
{
+ if (x.is_equal(_ex1))
+ return 1/y;
+ if (y.is_equal(_ex1))
+ return 1/x;
if (x.info(info_flags::numeric) && y.info(info_flags::numeric)) {
// treat all problematic x and y that may not be passed into tgamma,
// 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)
- const numeric nx = ex_to<numeric>(x);
- const numeric ny = ex_to<numeric>(y);
+ const numeric &nx = ex_to<numeric>(x);
+ const numeric &ny = ex_to<numeric>(y);
if (nx.is_real() && nx.is_integer() &&
ny.is_real() && ny.is_integer()) {
if (nx.is_negative()) {
// Taylor series where there is no pole of one of the tgamma functions
// falls back to beta function evaluation. Otherwise, fall back to
// tgamma series directly.
- const ex arg1_pt = arg1.subs(rel);
- const ex arg2_pt = arg2.subs(rel);
- GINAC_ASSERT(is_exactly_a<symbol>(rel.lhs()));
+ const ex arg1_pt = arg1.subs(rel, subs_options::no_pattern);
+ const ex arg2_pt = arg2.subs(rel, subs_options::no_pattern);
+ GINAC_ASSERT(is_a<symbol>(rel.lhs()));
const symbol &s = ex_to<symbol>(rel.lhs());
ex arg1_ser, arg2_ser, arg1arg2_ser;
if ((!arg1_pt.info(info_flags::integer) || arg1_pt.info(info_flags::positive)) &&
static ex psi1_eval(const ex & x)
{
if (x.info(info_flags::numeric)) {
- const numeric nx = ex_to<numeric>(x);
+ const numeric &nx = ex_to<numeric>(x);
if (nx.is_integer()) {
// integer case
if (nx.is_positive()) {
// from which follows
// series(psi(x),x==-m,order) ==
// series(psi(x+m+1) - 1/x - 1/(x+1) - 1/(x+m)),x==-m,order);
- const ex arg_pt = arg.subs(rel);
+ const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive))
throw do_taylor(); // caught by function::series()
// if we got here we have to care for a simple pole at -m:
return (psi(arg+m+_ex1)-recur).series(rel, order, options);
}
-const unsigned function_index_psi1 =
+unsigned psi1_SERIAL::serial =
function::register_new(function_options("psi").
eval_func(psi1_eval).
evalf_func(psi1_evalf).
return log(tgamma(x));
if (n.info(info_flags::numeric) && n.info(info_flags::posint) &&
x.info(info_flags::numeric)) {
- const numeric nn = ex_to<numeric>(n);
- const numeric nx = ex_to<numeric>(x);
+ const numeric &nn = ex_to<numeric>(n);
+ const numeric &nx = ex_to<numeric>(x);
if (nx.is_integer()) {
// integer case
if (nx.is_equal(_num1))
// series(psi(x),x==-m,order) ==
// series(psi(x+m+1) - (-1)^n * n! * ((x)^(-n-1) + (x+1)^(-n-1) + ...
// ... + (x+m)^(-n-1))),x==-m,order);
- const ex arg_pt = arg.subs(rel);
+ const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive))
throw do_taylor(); // caught by function::series()
// if we got here we have to care for a pole of order n+1 at -m:
return (psi(n, arg+m+_ex1)-recur).series(rel, order, options);
}
-const unsigned function_index_psi2 =
+unsigned psi2_SERIAL::serial =
function::register_new(function_options("psi").
eval_func(psi2_eval).
evalf_func(psi2_evalf).