```python
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 3, 100)
y = -1*(x**2) + x*3 - 1
plt.plot(x,y)
```


```python
def slope(x1,x2,y1,y2):
    rc = (y2 - y1)/(x2 - x1)
    return rc
slope_one = slope(0,4,1,13)
slope_two = slope(5,-1,16,-2)

print(slope_one)
print(slope_two)
```

    3.0
    3.0



```python
import seaborn
seaborn.set(style='darkgrid')

def draw_secant(x_values):
    
    x = np.linspace(-20,30,100)
    y = -1*(x**2) + x*3 - 1
    plt.plot(x,y)
    
    x_0 = x_values[0]
    x_1 = x_values[1]
    y_0 = -1*(x_0**2) + x_0*3 - 1
    y_1 = -1*(x_1**2) + x_1*3 - 1
    m = (y_1 - y_0) / (x_1 - x_0)
    b = y_1 - m*x_1
    
    y_secant = x*m + b
    plt.plot(x, y_secant, c='green')
    plt.show()
draw_secant([3,5])
draw_secant([3,10])
draw_secant([3,15])
```


```python
import sympy
x2,y = sympy.symbols('x2 y')
limit_one = sympy.limit((-x2**2 +3*x2-1+1)/(x2-3) , x2, 2.9)
print(limit_one)
```

    -2.89999999999999



```python
x,y = sympy.symbols('x y')
y = 3*(x**2) + 3*x - 3
limit_two = sympy.limit(y, x, 1)
print(limit_two)
```

    3



```python
y = x**3 + 2*(x**2) - x*10
limit_three = sympy.limit(y, x, -1)
print(limit_three)
```

    11



```python
x2, y = sympy.symbols('x2 y')
y = (-x2**2 +3*x2 -1 + 1)/(x2 - 3)
limit_four = sympy.limit(y, x2, 3)
print(limit_four)
```

    -3



```python
x = np.linspace(-5,6,110)
y = -2*x +3
plt.plot(x,y)
```


```python

```

b56764d6d90c1451ed857837064146de0db7e914
ipynb
Jupyter Notebook
6.2 Calculus for Machine Learning/Linear & Non-linear functions.ipynb
orspain/Dataquest
8d6817e89afd7e88397a76c2a638aa5aca77d99f
Apache-2.0
2020-04-16T17:23:53.000Z
2021-09-25T13:59:10.000Z
6.2 Calculus for Machine Learning/Linear & Non-linear functions.ipynb
orspain/Dataquest
8d6817e89afd7e88397a76c2a638aa5aca77d99f
Apache-2.0
6.2 Calculus for Machine Learning/Linear & Non-linear functions.ipynb
orspain/Dataquest
8d6817e89afd7e88397a76c2a638aa5aca77d99f
Apache-2.0
2019-12-15T19:52:27.000Z
2022-02-28T19:22:15.000Z
Qwen/Qwen-72B
1. YES
2. YES