# Cayley 1997 Problem 21



The problem involves integers but divides them so that the result is a rational number.
If we use Python `float` numbers then we'll get round-off errors.
Instead, let's use SymPy which can do exact calculations involving rational numbers.

First, let's define some SymPy variables for the positive integers $a$, $b$, and $c$.


```python
from sympy import symbols

a, b, c = symbols('a:c', integer=True, positive=True)
```


```python
a, b, c
```




    (a, b, c)



Next, lets define the equation that constrains the variables.


```python
from sympy import Eq
eq21 = Eq((a/c + a/b + 1)/(b/a + b/c + 1), 11)
eq21
```




$\displaystyle \frac{\frac{a}{c} + \frac{a}{b} + 1}{\frac{b}{c} + 1 + \frac{b}{a}} = 11$




```python
eq21.subs(a, 1).subs(b, 1).subs(c, 1)
```




$\displaystyle \text{False}$




```python
def is_solution(va, vb, vc):
    if va + 2 * vb + vc <= 40:
        return eq21.subs(a, va).subs(b, vb).subs(c, vc)
    return False

is_solution(1, 1, 1)
```




$\displaystyle \text{False}$




```python
def find_all_solutions():
    return [(va, vb, vc)
           for va in range(1, 40)
           for vb in range(1, 20)
           for vc in range(1, 40)
           if is_solution(va, vb, vc)]

solutions = find_all_solutions()
print('Number of solutions is', len(solutions))
```

    Number of solutions is 42


The solutions are:


```python
for s in solutions:
    print(s)
```

    (11, 1, 1)
    (11, 1, 2)
    (11, 1, 3)
    (11, 1, 4)
    (11, 1, 5)
    (11, 1, 6)
    (11, 1, 7)
    (11, 1, 8)
    (11, 1, 9)
    (11, 1, 10)
    (11, 1, 11)
    (11, 1, 12)
    (11, 1, 13)
    (11, 1, 14)
    (11, 1, 15)
    (11, 1, 16)
    (11, 1, 17)
    (11, 1, 18)
    (11, 1, 19)
    (11, 1, 20)
    (11, 1, 21)
    (11, 1, 22)
    (11, 1, 23)
    (11, 1, 24)
    (11, 1, 25)
    (11, 1, 26)
    (11, 1, 27)
    (22, 2, 1)
    (22, 2, 2)
    (22, 2, 3)
    (22, 2, 4)
    (22, 2, 5)
    (22, 2, 6)
    (22, 2, 7)
    (22, 2, 8)
    (22, 2, 9)
    (22, 2, 10)
    (22, 2, 11)
    (22, 2, 12)
    (22, 2, 13)
    (22, 2, 14)
    (33, 3, 1)


1389cb1b1764ea9688e4357d1c947834ad3428b4
ipynb
Jupyter Notebook
Meeting Notes/2020/2020-07-11/cayley-1997-problem-21.ipynb
agryman/sean
11baf69c6eb9308266126bf9c8b1c67c6fd33afc
MIT
2020-03-28T18:17:52.000Z
2020-03-28T18:17:52.000Z
Meeting Notes/2020/2020-07-11/cayley-1997-problem-21.ipynb
agryman/sean
11baf69c6eb9308266126bf9c8b1c67c6fd33afc
MIT
2022-01-21T21:33:00.000Z
2022-01-21T21:33:00.000Z
Meeting Notes/2020/2020-07-11/cayley-1997-problem-21.ipynb
agryman/sean
11baf69c6eb9308266126bf9c8b1c67c6fd33afc
MIT
Qwen/Qwen-72B
1. YES
2. YES