```python
from sympy import *
init_printing(use_latex='mathjax')
```


```python
def get_diff(symbol, expression):
    return diff(expression, symbol)
```


```python
x = symbols('x')
get_diff(x, (x + 2) * (3 * x - 3))
```




$$6 x + 3$$




```python
x = symbols('x')
get_diff(x, exp(x) * ( x ** 2 + 7 * x - 3 - sin(x) ))
```




$$\left(2 x - \cos{\left (x \right )} + 7\right) e^{x} + \left(x^{2} + 7 x - \sin{\left (x \right )} - 3\right) e^{x}$$




```python
f =  (x**2 - 2 * x + 5)
```


```python
g = (sin(x) + cos(x))
```


```python
x = symbols('x')
fp=get_diff(x, f)
```


```python
x = symbols('x')
gp=get_diff(x, g)
```


```python
f * gp + g * fp
```




$$\left(2 x - 2\right) \left(\sin{\left (x \right )} + \cos{\left (x \right )}\right) + \left(- \sin{\left (x \right )} + \cos{\left (x \right )}\right) \left(x^{2} - 2 x + 5\right)$$




```python
x = symbols('x')
fp = get_diff(x, exp(x) * (3 * x - 2 ) * sin(x))
factor(simplify(fp))
```




$$\left(3 x \sin{\left (x \right )} + 3 x \cos{\left (x \right )} + \sin{\left (x \right )} - 2 \cos{\left (x \right )}\right) e^{x}$$




```python
x = symbols('x')
fp = get_diff(x, - 1 / 3 * ( exp(x) - 1) ** 2 + (exp(x) - 1) + 1/5)
simplify(fp)
```




$$\left(- 0.666666666666667 e^{x} + 1.66666666666667\right) e^{x}$$




```python
x = symbols('x')
fp = get_diff(x, sqrt(x ** 3 - 2 * x ) )
fp
```




$$\frac{\frac{3 x^{2}}{2} - 1}{\sqrt{x^{3} - 2 x}}$$




```python
x = symbols('x')
fp = get_diff(x, exp(x ** 3 - 3 ))
fp
```




$$3 x^{2} e^{x^{3} - 3}$$




```python
x = symbols('x')
fp = get_diff(x, sqrt(exp(x + 2)))
simplify(fp)
```




$$\frac{1}{2} \sqrt{e^{x + 2}}$$




```python
x = symbols('x')
fp = get_diff(x, x ** (3/2) + pi * x ** 2 + sqrt(7))
fp
```




$$1.5 x^{0.5} + 2 \pi x$$




```python
x = symbols('x')
fp = get_diff(x, x ** 3 * cos(x) * exp(x))
fp
```




$$- x^{3} e^{x} \sin{\left (x \right )} + x^{3} e^{x} \cos{\left (x \right )} + 3 x^{2} e^{x} \cos{\left (x \right )}$$




```python
x = symbols('x')
fp = get_diff(x, exp((x + 1) ** 2))
fp
```




$$\left(2 x + 2\right) e^{\left(x + 1\right)^{2}}$$




```python
x = symbols('x')
fp = get_diff(x, x ** 2 * cos(x ** 3))
fp
```




$$- 3 x^{4} \sin{\left (x^{3} \right )} + 2 x \cos{\left (x^{3} \right )}$$




```python
x = symbols('x')
fp = get_diff(x, sin(x) * exp(cos(x)))
fp
```




$$- e^{\cos{\left (x \right )}} \sin^{2}{\left (x \right )} + e^{\cos{\left (x \right )}} \cos{\left (x \right )}$$




```python
fp.evalf(subs={x: pi})
```




$$-0.367879441171442$$




```python
nsimplify(6.28, [pi], tolerance=0.01)
```




$$2 \pi$$




```python
(1 / exp(1)).evalf()
```




$$0.367879441171442$$




```python

```

245826173219a3900496e21780aa06a2b8abaaa1
ipynb
Jupyter Notebook
Certification 2/Week1.1 - Differential.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
2018-04-16T02:53:59.000Z
2021-05-16T06:51:57.000Z
Certification 2/Week1.1 - Differential.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
Certification 2/Week1.1 - Differential.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
2019-05-20T02:06:55.000Z
2020-05-18T06:21:41.000Z
Qwen/Qwen-72B
1. YES
2. YES