Post Reply 
(HP15C)(HP67)(HP41C) Bernoulli Polynomials
08-30-2023, 11:59 PM
Post: #12
RE: (HP15C)(HP67)(HP41C) Bernoulli Polynomials
(08-30-2023 04:30 PM)Albert Chan Wrote:  B(6) = [1/2, 31/3, 90/4, 65/5, 15/6, 1/7] * [-1!, 2!, -3!, 4!, -5!, 6!] = 1/42

We could use horner's rule, and remove factorial function.

B(6) = -(1/2 - 2*(31/3 - 3*(90/4 - 4*(65/5 - 5*(15/6 - 6*(1/7))))))

Code is simpler, calculations faster, and slightly more accurate.

Code:
B0(m) := {
  local k, t:=1/(m+1);
  if (m<=1) return 1 - 3/2*m;
  if (remain(m,2)) return 0;  
  for(k:=m; k>2; k-=1) t := S(m,k-1)/k - k*t;
  return 2*t - 1/2;
};

XCas> map(B0, range(10))

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

XCas> float(B0(16)), B0(float(16))

-7.09215686275, -7.43446095788
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-30-2023 11:59 PM



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