```python
import cmath
import itertools
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline
```


```python
vecs = [cmath.exp(2 * cmath.pi * i / 6 * 1j) for i in range(6)]
```


```python
vs = [v1 + v2 for v1, v2 in itertools.combinations_with_replacement(vecs, 2)]
vsr = [v.real for v in vs]
vsi = [v.imag for v in vs]

plt.axes().set_aspect('equal')
plt.scatter(vsr, vsi, alpha=0.3, color='red')
plt.show()
```


```python
vs2 = [sum(s) for s in itertools.combinations_with_replacement(vecs, 3)]
vs2r = [v.real for v in vs2]
vs2i = [v.imag for v in vs2]

plt.axes().set_aspect('equal')
plt.scatter(vs2r, vs2i, alpha=0.3, color='red')
plt.show()
```


```python
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True, positive=True)
f, g, h = symbols('f g h', cls=Function)
```


```python
f = binomial(k-1, 2) * (Rational(2, 3))**(k-3) * (Rational(1, 3))**3
f
```




$\displaystyle \frac{\left(\frac{2}{3}\right)^{k - 3} {\binom{k - 1}{2}}}{27}$




```python
f = simplify(f)
f
```




$\displaystyle 2^{k - 4} \cdot 3^{- k} \left(k - 2\right) \left(k - 1\right)$




```python
g = simplify(f.subs([(k, k+1)]) / f)
g
```




$\displaystyle \frac{2 k}{3 \left(k - 2\right)}$




```python
for i in range(3, 12):
    print(f'{i}: {f.subs([(k, i)]).evalf()}')

for i in range(3, 12):
    display(f.subs([(k, i)]))
```

    3: 0.0370370370370370
    4: 0.0740740740740741
    5: 0.0987654320987654
    6: 0.109739368998628
    7: 0.109739368998628
    8: 0.102423411065386
    9: 0.0910430320581212
    10: 0.0780368846212468
    11: 0.0650307371843723



$\displaystyle \frac{1}{27}$



$\displaystyle \frac{2}{27}$



$\displaystyle \frac{8}{81}$



$\displaystyle \frac{80}{729}$



$\displaystyle \frac{80}{729}$



$\displaystyle \frac{224}{2187}$



$\displaystyle \frac{1792}{19683}$



$\displaystyle \frac{512}{6561}$



$\displaystyle \frac{1280}{19683}$



```python
f = (ff(4, 3) * ff(n-4, k-3) * binomial(k-1, 2)) / ff(n, k)
f
```




$\displaystyle \frac{24 {\left(n - 4\right)}_{\left(k - 3\right)} {\binom{k - 1}{2}}}{{\left(n\right)}_{k}}$




```python
f = simplify(f)
f
```




$\displaystyle - \frac{12 \left(k - 2\right) \left(k - 1\right) \left(k - n\right)}{n \left(n - 3\right) \left(n - 2\right) \left(n - 1\right)}$




```python
g = simplify(f.subs([(k, k+1)]) / f)
g
```




$\displaystyle \frac{k \left(k - n + 1\right)}{\left(k - 2\right) \left(k - n\right)}$




```python
h = g - 1
solve(h, k)
```




    [2*n/3]




```python
f.subs([(k, 3)])
```




$\displaystyle - \frac{24 \left(3 - n\right)}{n \left(n - 3\right) \left(n - 2\right) \left(n - 1\right)}$




```python
f.subs([(k, n-1)])
```




$\displaystyle \frac{12}{n \left(n - 1\right)}$




```python
simplify(f.subs([(k, n-1)]) - f.subs([(k, 3)]))
```




$\displaystyle \frac{12 \left(n - 4\right)}{n \left(n - 2\right) \left(n - 1\right)}$




```python

```


```python

```

877acd2a86c2bfab2f54a5da0635ed94dc0580bd
ipynb
Jupyter Notebook
math-test.ipynb
mo-mo-666/hello-sympy
ec9783166ec42615f18b7c77a172b09687d8b143
MIT
math-test.ipynb
mo-mo-666/hello-sympy
ec9783166ec42615f18b7c77a172b09687d8b143
MIT
2020-03-24T17:24:28.000Z
2020-03-31T03:14:26.000Z
math-test.ipynb
mo-mo-666/hello-sympy
ec9783166ec42615f18b7c77a172b09687d8b143
MIT
Qwen/Qwen-72B
1. YES
2. YES