# Finding Pattern


```python
import numpy as np
```

## Given this array, find the next number in the sequence


```python
my_teaser_array = np.array([1, 7, 19, 37, 61, 91, 127, 169, 217, 271, 331])
my_teaser_array
```




    array([  1,   7,  19,  37,  61,  91, 127, 169, 217, 271, 331])



##### for information about numpy.diff, please see: http://docs.scipy.org/doc/numpy/reference/generated/numpy.diff.html


```python
np.diff(my_teaser_array)
```




    array([ 6, 12, 18, 24, 30, 36, 42, 48, 54, 60])




```python
np.diff(my_teaser_array, n=2)
```




    array([6, 6, 6, 6, 6, 6, 6, 6, 6])




```python
np.diff(my_teaser_array, n=3)
```




    array([0, 0, 0, 0, 0, 0, 0, 0])



##### Warning: imports should (usually) appear at top of notebook

If SymPy is not included on your computer; open a console and type 'conda sympy'


```python
from sympy import init_session
init_session() 
```

    IPython console for SymPy 1.0 (Python 3.5.2-64-bit) (ground types: python)
    
    These commands were executed:
    >>> from __future__ import division
    >>> from sympy import *
    >>> x, y, z, t = symbols('x y z t')
    >>> k, m, n = symbols('k m n', integer=True)
    >>> f, g, h = symbols('f g h', cls=Function)
    >>> init_printing()
    
    Documentation can be found at http://docs.sympy.org/1.0/



```python
diff(x**3)
```


```python
diff(x**3, x, 2)
```


```python
diff(x**3, x, 3)
```


```python
diff(x**3, x, 4)
```


```python
def my_guess(n):
    return (n+1)**3 - n**3
```


```python
my_guess(np.arange(20))
```




    array([   1,    7,   19,   37,   61,   91,  127,  169,  217,  271,  331,
            397,  469,  547,  631,  721,  817,  919, 1027, 1141], dtype=int32)




```python
my_teaser_array = np.array([1, 7, 19, 37, 61, 91, 127, 169, 217, 271, 331])
my_teaser_array
```




    array([  1,   7,  19,  37,  61,  91, 127, 169, 217, 271, 331])




```python

```

4905bb8680eb01f9b80d911efeb4cd4c40dc72ef
ipynb
Jupyter Notebook
numpy-data-science-essential-training/Ex_Files_NumPy_Data_EssT/Exercise Files/Ch 6/06_04/Finish/Pattern.ipynb
saint1729/in-learning
fe58495846f05e2dcd15d1dbb6ff87535d35d6c5
MIT
numpy-data-science-essential-training/Ex_Files_NumPy_Data_EssT/Exercise Files/Ch 6/06_04/Finish/Pattern.ipynb
saint1729/in-learning
fe58495846f05e2dcd15d1dbb6ff87535d35d6c5
MIT
numpy-data-science-essential-training/Ex_Files_NumPy_Data_EssT/Exercise Files/Ch 6/06_04/Finish/Pattern.ipynb
saint1729/in-learning
fe58495846f05e2dcd15d1dbb6ff87535d35d6c5
MIT
Qwen/Qwen-72B
1. YES
2. YES