```python
import numpy as np
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import sympy as sym

```

QUESTÃO 1 


```python
x = sym.symbols('x') 
F = x**3 - 7.5*x**2 + 18*x - 10 
Fdiff = sym.expand(sym.diff(F, x))
roots = sym.solve(Fdiff, x)
display(Math(sym.latex('Roots:') + sym.latex(roots)))
```


$$Roots:\left [ 2.0, \quad 3.0\right ]$$


    QUESTÃO 2 


```python
# The local minimum of $f(x)=x^4-3x^3+2$ is at x=9/4 - f(x)=x^3 - 7.5x^2 + 18x - 10

cur_x = 6               # The algorithm starts at x=6
gamma = 0.01            # step size multiplier
precision = 0.00001
step_size = 1           # initial step size
max_iters = 10000       # maximum number of iterations
iters = 0               # iteration counter

f  = lambda x: x**3 - 7.5*x**2 + 18*x - 10  # lambda function for f(x) #Aqui você coloca sua função f
df = lambda x: 3*x**2 - 15*x + 18    # lambda function for the gradient of f(x) #Aqui você coloca sua derivada (faz regra do tombo mesmo)

while (step_size > precision) & (iters < max_iters):
    prev_x = cur_x
    cur_x -= gamma*df(prev_x)
    step_size = abs(cur_x - prev_x)
    iters+=1

print('True local minimum at {} with function value {}.'.format(9/4, f(9/4)))
print('Local minimum by gradient descent at {} with function value {}.'.format(cur_x, f(cur_x)))
```

    True local minimum at 2.25 with function value 3.921875.
    Local minimum by gradient descent at 3.000323195755751 with function value 3.5000001567170003.



```python

```

4f0b9ec333797bc8c9673e3d4d977fdc35dc4f15
ipynb
Jupyter Notebook
courses/modsim2018/talitapinheiro/Task19_Talita.ipynb
talitapinheiro/bmc
ae9442261be09f528ce895f7a14edad1a62f8d41
MIT
courses/modsim2018/talitapinheiro/Task19_Talita.ipynb
talitapinheiro/bmc
ae9442261be09f528ce895f7a14edad1a62f8d41
MIT
courses/modsim2018/talitapinheiro/Task19_Talita.ipynb
talitapinheiro/bmc
ae9442261be09f528ce895f7a14edad1a62f8d41
MIT
Qwen/Qwen-72B
1. YES
2. YES