# Ticket #10222(closed defect: fixed)

Opened 3 years ago

## Bernoulli polynomial problem

Reported by: Owned by: davidloeffler malb minor sage-4.6.2 commutative algebra bernoulli craigcitro N/A David Loeffler Francis Clarke sage-4.6.2.alpha3

### Description

The "bernoulli_polynomial" command should return the nth Bernoulli polynomial evaluated at the first argument, but something odd happens when you feed it a polynomial that's not a single variable:

```sage: R.<x> = QQ[]
sage: bernoulli_polynomial(x, 2)
x^2 - x + 1/6
sage: bernoulli_polynomial(x - 1, 2)
x^2 - x + 1/6
sage: bernoulli_polynomial(R(0), 2)
x^2 - x + 1/6
```

## Change History

### comment:1 Changed 3 years ago by fwclarke

• Status changed from new to needs_review
• Authors set to Francis Clarke

In the attached patch I have rewritten most of the `bernoulli_polynomial` code.  This solves this problem.

In the case where the result is a polynomial, direct calculation from the list of coefficients is retained (for speed), but corrected for the case where x is not the variable. This only works when the base ring is a QQ-algebra; previously an error was raised it if wasn't.

A small increase in speed results from the odd Bernoulli numbers being zero, apart from the first. This is more significant in the non-polynomial case.

A couple of new doctests have been added.

### comment:2 Changed 2 years ago by davidloeffler

• Status changed from needs_review to positive_review
• Reviewers set to David Loeffler

With the new patch, it not only gets the right answer, but it does so faster than it previously got the wrong answer. Can't argue with that.

### comment:3 Changed 2 years ago by jdemeyer

• Milestone changed from sage-4.6.1 to sage-4.6.2

### comment:4 Changed 2 years ago by jdemeyer

• Status changed from positive_review to closed
• Resolution set to fixed
• Merged in set to sage-4.6.2.alpha3
Note: See TracTickets for help on using tickets.