1/* 2 * bernpoly - Bernoulli polynomials B_n(z) for arbitrary n,z.. 3 * 4 * Copyright (C) 2013,2021 Christoph Zurnieden 5 * 6 * Calc is open software; you can redistribute it and/or modify it under 7 * the terms of the version 2.1 of the GNU Lesser General Public License 8 * as published by the Free Software Foundation. 9 * 10 * Calc is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 13 * Public License for more details. 14 * 15 * A copy of version 2.1 of the GNU Lesser General Public License is 16 * distributed with calc under the filename COPYING-LGPL. You should have 17 * received a copy with calc; if not, write to Free Software Foundation, Inc. 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 * 20 * Under source code control: 2013/08/11 01:31:28 21 * File existed as early as: 2013 22 */ 23 24 25static resource_debug_level; 26resource_debug_level = config("resource_debug", 0); 27 28 29read -once zeta2 30 31 32/* Idea by Don Zagier */ 33define bernpoly(n,z){ 34 local h s c k; 35 if(isint(n) && n>=0){ 36 h=0;s=0;c=-1; 37 for(k=1;k<=n+1;k++){ 38 c*=1-(n+2)/k; 39 s+=z^n; 40 z++; 41 h+=c*s/k; 42 } 43 return h; 44 } 45 else return -n*hurwitzzeta(1-n,z); 46} 47 48 49/* 50 * restore internal function from resource debugging 51 */ 52config("resource_debug", resource_debug_level),; 53if (config("resource_debug") & 3) { 54 print "bernpoly(n,z)"; 55} 56