Ticket #5496: trac5496_rationals_to_int.patch

File trac5496_rationals_to_int.patch, 1.3 KB (added by spancratz, 3 years ago)

Three small changes throughout the Sage library

• sage/combinat/combinat.py

```# HG changeset patch
# User Sebastian Pancratz <sage@pancratz.org>
# Date 1263776557 28800
# Node ID 35eeb5638d35ea3e5be154acd3c54233326d169d
# Parent  21efb0b3fc474972b5c7f617d99173536a3d79d0
Small 3-line change conversing rationals to integers.

diff -r 21efb0b3fc47 -r 35eeb5638d35 sage/combinat/combinat.py```
 a :: sage: lucas = lambda n:(5/2)*lucas_number1(n,1,-1)+(1/2)*lucas_number2(n,1,-1) sage: lucas = lambda n : Integers((5/2)*lucas_number1(n,1,-1)+(1/2)*lucas_number2(n,1,-1)) sage: [[lucas(n),is_prime(lucas(n)),n+1,is_prime(n+1)] for n in range(15)] [[1, False, 1, False], [3, True, 2, True],
• sage/rings/arith.py

`diff -r 21efb0b3fc47 -r 35eeb5638d35 sage/rings/arith.py`
 a x = int(sqrt(m)) if mod(x,2) == 0: x = x - 1 p = (m-x**2)/2 p = (m-x**2) // 2 while not is_prime(p): x = x - 2 p = (m-x**2)/2 p = (m-x**2) // 2 if x < 0: # fall back to brute force m = m + d