# Ticket #9020(closed enhancement: fixed)

Opened 3 years ago

## random degrees for random_element()s univariate polynomial rings

Reported by: Owned by: burcin AlexGhitza major sage-4.4.4 basic arithmetic N/A John Cremona Burcin Erocal sage-4.4.4.alpha0

### Description

Attached patch allows using a tuple as the degree argument when calling the random_element() method of univariate polynomial rings. The tuple specifies the minimum and maximum degrees so we don't always get polynomials of the same degree:

```sage: R.<x> = ZZ[]
sage: R.random_element(degree=(0,8))
2*x^7 - x^5 + 4*x^4 - 5*x^3 + x^2 + 14*x - 1
sage: R.random_element(degree=(0,8))
-2*x^3 + x^2 + x + 4
```

This is also directly usable by matrices:

```sage: M = Matrix(R,2,2)
sage: M.randomize(degree=(0,6))
sage: M
[              -40*x^3 - 3*x^2 - 5*x            -x^4 + 476*x^3 - 3*x + 3]
[-12*x^6 + 2*x^4 - x^3 + x^2 + x - 1                           -52*x + 5]
```

## Change History

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

• Status changed from new to needs_review
• Authors set to Burcin Erocal

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

• Status changed from needs_review to positive_review
• Reviewers set to John Cremona

Good idea. Patch applies fine to 4.4.3.alpha0 and all tests in sage/rings/polynomials/ pass.

### comment:3 Changed 3 years ago by mhansen

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