X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Fseries_expansion.cpp;h=4cd169706d0dd4ca418f5ccdd6c70cd5e68ff9f7;hp=b8e80204606a52620e8b000f331583ed3f49f9df;hb=ff50f412bb89eed2c78adffa0f390341753e8792;hpb=955cb185a85535ab328ffedbfccdc508ce80fa91 diff --git a/check/series_expansion.cpp b/check/series_expansion.cpp index b8e80204..4cd16970 100644 --- a/check/series_expansion.cpp +++ b/check/series_expansion.cpp @@ -3,7 +3,7 @@ * Series expansion test (Laurent and Taylor series). */ /* - * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2000 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 @@ -20,18 +20,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "ginac.h" -#ifndef NO_GINAC_NAMESPACE +#ifndef NO_NAMESPACE_GINAC using namespace GiNaC; -#endif // ndef NO_GINAC_NAMESPACE +#endif // ndef NO_NAMESPACE_GINAC static symbol x("x"); static unsigned check_series(const ex &e, const ex &point, const ex &d, int order = 8) { ex es = e.series(x, point, order); - ex ep = static_cast(es.bp)->convert_to_poly(); + ex ep = ex_to_pseries(es).convert_to_poly(); if (!(ep - d).is_zero()) { clog << "series expansion of " << e << " at " << point << " erroneously returned " << ep << " (instead of " << d @@ -131,12 +131,33 @@ static unsigned series3(void) return result; } -// Series of special functions +// Order term handling static unsigned series4(void) +{ + unsigned result = 0; + ex e, d; + + e = 1 + x + pow(x, 2) + pow(x, 3); + d = Order(1); + result += check_series(e, 0, d, 0); + d = 1 + Order(x); + result += check_series(e, 0, d, 1); + d = 1 + x + Order(pow(x, 2)); + result += check_series(e, 0, d, 2); + d = 1 + x + pow(x, 2) + Order(pow(x, 3)); + result += check_series(e, 0, d, 3); + d = 1 + x + pow(x, 2) + pow(x, 3); + result += check_series(e, 0, d, 4); + return result; +} + +// Series of special functions +static unsigned series5(void) { unsigned result = 0; ex e, d; + // gamma(-1): e = gamma(2*x); d = pow(x+1,-1)*numeric(1,4) + pow(x+1,0)*(numeric(3,4) - @@ -165,6 +186,7 @@ static unsigned series4(void) Order(pow(x+1,4)); result += check_series(e, -1, d, 4); + // tan(Pi/2) e = tan(x*Pi/2); d = pow(x-1,-1)/Pi*(-2) + pow(x-1,1)*Pi/6 + @@ -188,6 +210,7 @@ unsigned series_expansion(void) result += series2(); result += series3(); result += series4(); + result += series5(); if (!result) { cout << " passed ";