# COURSE: A deep understanding of deep learning
## SECTION: Math prerequisites
### LECTURE: Derivatives: intuition and polynomials
#### TEACHER: Mike X Cohen, sincxpress.com
##### COURSE URL: udemy.com/course/dudl/?couponCode=202201


```python
import numpy as np
import matplotlib.pyplot as plt

# sympy = symbolic math in Python
import sympy as sym
import sympy.plotting.plot as symplot
```


```python
# create symbolic variables in sympy
x = sym.symbols('x')

# create a function
fx = 2*x**2

# compute its derivative
df = sym.diff(fx,x)

# print them
print(fx)
print(df)
```


```python
# plot them
symplot(fx,(x,-4,4),title='The function')
plt.show()

symplot(df,(x,-4,4),title='Its derivative')
plt.show()

```


```python
# repeat with relu and sigmoid

# create symbolic functions
relu = sym.Max(0,x)
sigmoid = 1 / (1+sym.exp(-x))

# graph the functions
p = symplot(relu,(x,-4,4),label='ReLU',show=False,line_color='blue')
p.extend( symplot(sigmoid,(x,-4,4),label='Sigmoid',show=False,line_color='red') )
p.legend = True
p.title = 'The functions'
p.show()


# graph their derivatives
p = symplot(sym.diff(relu),(x,-4,4),label='df(ReLU)',show=False,line_color='blue')
p.extend( symplot(sym.diff(sigmoid),(x,-4,4),label='df(Sigmoid)',show=False,line_color='red') )
p.legend = True
p.title = 'The derivatives'
p.show()

```

b9e2eaaa14a06e0a03da93d0aeb71bb65058523c
ipynb
Jupyter Notebook
01_math/DUDL_math_derivatives1.ipynb
amitmeel/DUDL
92348d5fc95b179dd2119f35f671366cd73718e6
MIT
01_math/DUDL_math_derivatives1.ipynb
amitmeel/DUDL
92348d5fc95b179dd2119f35f671366cd73718e6
MIT
01_math/DUDL_math_derivatives1.ipynb
amitmeel/DUDL
92348d5fc95b179dd2119f35f671366cd73718e6
MIT
Qwen/Qwen-72B
1. YES
2. YES