Post Reply 
(HP15C)(HP67)(HP41C) Bernoulli Polynomials
08-29-2023, 03:49 PM
Post: #4
RE: (HP15C)(HP67)(HP41C) Bernoulli Polynomials
Hi, Namir

We could trade speed for space getting Stirling number of the 2nd kind.
Code:
SS(n,k) := sum((-1)^(k-j) * comb(k,j)*j^n, j = 0 .. k);
S(n, k) := SS(n,k) / k!;  /* Stiring number 2nd kind */

XCas> [S(5,k) for k in range(1,6)] /* x^5 falling factorial coefficients */

[1, 15, 25, 10, 1]

Bernoulli numbers from Stirling numbers 2nd kind
Code:
B0(m) := {
  local k, t:=1;
  if (m==1) return -1/2;  
  if (odd(m)) return 0;  
  m += 1;
  for(k:=2; k<=m; k+=1) t = SS(m,k)/k^2 - t;
  return t;
}

XCas> map(B0, range(10))

[1, -1/2, 1/6, 0, -1/30, 0, 1/42, 0, -1/30, 0]

Code:
sum_xm(x,m) := {local k, t := 1/(m+1);
  for(k:=m; k>1; k-=1) { t := (x-k)*t + SS(m,k-1)/k!; }
  return x*(x-1)*t;
};

B2(m,x) := sum_xm(x,m-1) * m + B0(m);

XCas> sum_xm(101, 1);                /* = sum(k, k=0 .. 100) */

5050

XCas> sqrt(sum_xm(101, 3));       /* sum of cubes = square of sum */

5050

XCaS> B2(5, 3.5), B2(3, 5.5);       /* OP example */

220.9375, 123.75
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (HP15C)(HP67)(HP41C) Bernoulli Polynomials - Albert Chan - 08-29-2023 03:49 PM



User(s) browsing this thread: 4 Guest(s)