Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make bernoulli_polynomial independent of maxima #2578

Closed
williamstein opened this issue Mar 17, 2008 · 6 comments
Closed

make bernoulli_polynomial independent of maxima #2578

williamstein opened this issue Mar 17, 2008 · 6 comments

Comments

@williamstein
Copy link
Contributor

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
>>>
>>>

CC: @mwhansen

Component: calculus

Issue created by migration from https://trac.sagemath.org/ticket/2578

@williamstein williamstein added this to the sage-3.4.1 milestone Mar 17, 2008
@williamstein williamstein self-assigned this Mar 17, 2008
@williamstein
Copy link
Contributor Author

comment:1

I forgot to define (n) as a variable in the above session.
Now, Sage does not lockup but instead gives the traceback.

var('y,x,n')
y = bernoulli_polynomial(x,n)

Exception (click to the left for traceback):
...
NameError: name 'bernpoly' is not defined

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/home/server2/sage_notebook/worksheets/5463/24/code/18.py",
line 7, in <module>
   y = bernoulli_polynomial(x,n)
 File "/usr/local/sage/local/lib/python2.5/site-packages/sympy/
plotting/", line 1, in <module>

 File "/usr/local/sage/local/lib/python2.5/site-packages/sage/
combinat/combinat.py", line 1806, in bernoulli_polynomial
   return sage_eval(maxima.eval("bernpoly(x,%s)"%n), {'x':x})
 File "/usr/local/sage/local/lib/python2.5/site-packages/sage/misc/
sage_eval.py", line 110, in sage_eval
   return eval(p, sage.all.__dict__, locals)
 File "<string>", line 1, in <module>
NameError: name 'bernpoly' is not defined

@williamstein williamstein changed the title bug in bernoulli_polynomial bug in bernoulli_polynomial (possibly invalid?) Mar 17, 2008
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Sep 14, 2008

comment:2

Since combinat.py is involved I am CCind Mike Hansen :)

Cheers,

Michael

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Sep 14, 2008

comment:3

Oh, and definitely not invalid.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin changed the title bug in bernoulli_polynomial (possibly invalid?) bug in bernoulli_polynomial Sep 14, 2008
@craigcitro
Copy link
Member

comment:4

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 nth Bernoulli polynomial to the docstring, though.

@craigcitro craigcitro changed the title bug in bernoulli_polynomial make bernoulli_polynomial independent of maxima Jan 23, 2009
@williamstein
Copy link
Contributor Author

comment:5

Attachment: trac-2578.patch.gz

positive review;

it could be optimized by using horner's rule

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 23, 2009

comment:6

Merged in Sage 3.3.alpha1

@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-3.4.1, sage-3.3 Jan 23, 2009
@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Jan 23, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants