gh-37490: Include `random_element()` method to `LaurentPolynomialRing`
This PR is an attempt to fix issue
https://github.com/sagemath/sage/issues/37454 to add a method for random
sampling for the `LaurentPolynomialRing` class which is causing failure
in some random testings.
This is not an object I have much familiarity with, but essentially I
have followed the usual random sampling for multivariate polynomial
rings and tried to follow the existing function name and arguments.
```py
sage: R = LaurentPolynomialRing(QQ, 2, 'x')
sage: R.random_element()
-2*x0*x1^-1 - 2*x0^-2*x1^2 + 5/2*x0^-1 + x0^-2*x1
sage: R.random_element(-5, 0)
7/61*x0^-3*x1^-4 + 1/3*x0^-4*x1^-4 - 1/2*x0^-5*x1^-4
sage: R.random_element(-5, 10)
1/31*x0^-2*x1^7 - 7*x0^-5*x1^10 + 4*x0^2*x1^-2 + 1/3*x0^-2*x1 -
3/44*x0*x1^-5
```
Included in the doctests is some random testing which tests the
properties I have tried to include in this function:
```py
TESTS::
sage: rings = [QQ, ZZ, GF(13), GF(7^3)]
sage: for ring in rings:
....: d = randint(1, 5)
....: R = LaurentPolynomialRing(ring, d, 'x')
....: for _ in range(100):
....: n, m = randint(0, 10), randint(0, 10)
....: f = R.random_element(-n, m)
....: for x in R.gens():
....: assert f.degree(x) <= m
....: assert f.degree(x) >= -n
```
Fixes https://github.com/sagemath/sage/issues/37454
URL: https://github.com/sagemath/sage/pull/37490
Reported by: Giacomo Pope
Reviewer(s): Giacomo Pope, grhkm21, nbruin, Travis Scrimshaw