Opened 14 years ago
Closed 14 years ago
#2578 closed defect (fixed)
[with patch, positive review] make bernoulli_polynomial independent of maxima
Reported by: | was | Owned by: | craigcitro |
---|---|---|---|
Priority: | major | Milestone: | sage-3.3 |
Component: | calculus | Keywords: | |
Cc: | mhansen | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
I wanted to verify that Sage could symbolically compute the derivative of Bn(x), the nth Bernoulli polynomial in (x): Dx[Bn(x)]=n*Bn-1(x). The following code causes Sage to lockup:
Bn = bernoulli_polynomial(x,n)
The command "bernpoly(x,n)" in Maxima does not lock up but Maxima will not compute symbolically.
sage: B3 = bernoulli_polynomial(x,3) sage: B4 = bernoulli_polynomial(x,4) sage: DxB4 = diff(B4,x) sage: print expand(DxB4-4*B3) 0 sage: Bn = bernoulli_polynomial(x,n) Traceback (most recent call last): ... KeyboardInterrupt >>> >>>
Attachments (1)
Change History (7)
comment:1 Changed 14 years ago by
- Summary changed from bug in bernoulli_polynomial to bug in bernoulli_polynomial (possibly invalid?)
comment:2 Changed 14 years ago by
- Cc mhansen added
Since combinat.py is involved I am CCind Mike Hansen :)
Cheers,
Michael
comment:3 Changed 14 years ago by
- Summary changed from bug in bernoulli_polynomial (possibly invalid?) to bug in bernoulli_polynomial
Oh, and definitely not invalid.
Cheers,
Michael
comment:4 Changed 14 years ago by
- Owner changed from was to craigcitro
- Status changed from new to assigned
- Summary changed from bug in bernoulli_polynomial to [with patch, needs review] make bernoulli_polynomial independent of maxima
The attached patch rewrites bernoulli_polynomial
to avoid Maxima completely. This gives roughly a factor of 10 speedup.
Unfortunately, the originial request doesn't quite make sense -- bernoulli_polynomial(x,n)
for n
a symbolic variable would have to return a polynomial of variable degree. As it stands, we don't have any sort of "symbolic sum" to use for that kind of thing. I did add the formula for the n
th Bernoulli polynomial to the docstring, though.
Changed 14 years ago by
comment:5 Changed 14 years ago by
- Summary changed from [with patch, needs review] make bernoulli_polynomial independent of maxima to [with patch, positive review] make bernoulli_polynomial independent of maxima
positive review;
it could be optimized by using horner's rule
comment:6 Changed 14 years ago by
- Milestone changed from sage-3.4.1 to sage-3.3
- Resolution set to fixed
- Status changed from assigned to closed
Merged in Sage 3.3.alpha1
I forgot to define (n) as a variable in the above session. Now, Sage does not lockup but instead gives the traceback.