Problem 1 (20 points)
Show that the stationary point (zero gradient) of the function$$
\begin{aligned}
    f=2x_{1}^{2} - 4x_1 x_2+ 1.5x^{2}_{2}+ x_2
\end{aligned}
$$is a saddle (with indefinite Hessian). Find the directions of downslopes away from the saddle. Hint: Use Taylor's expansion at the saddle point. Find directions that reduce $f$


```python
import sympy as sym


x1, x2 = sym.symbols("x1 x2")  # variables to be used in the function
f = 2*(x1)**2 - (4 * x1 * x2) + (1.5 * (x2)**2) + x2  # Declaring the function

gradient = sym.derive_by_array(f, (x1, x2))  # Finding the gradient of the function

hessian = sym.Matrix(sym.derive_by_array(gradient, (x1, x2)))  # Finding Hessian of the function

stationary_points = sym.solve(gradient, (x1, x2))  
print(f'Stationary points are:\n {stationary_points}')

value = f.subs({x1: stationary_points[x1], x2: stationary_points[x2]})
print(f'Value of the function at stationary point: {value}')

egnval = hessian.eigenvals()  # Finding the eigenvalues of the Hessian
e_val = list(egnval.keys())
print("The eigenvales are:")
print(*e_val)


# checking for the nature of he Hessain
posi = zo = nposi = 0

for val in e_val:
    val = float(val)
    if val > 0:
        posi += 1
    elif val == 0:
        zo += 1
    else:
        nposi += 1

if posi == len(e_val):
    print("Positive Definite Hessian")
elif zo == len(e_val):
    print("Undertimed Eigen Values are zero")
elif nposi == len(e_val):
    print("Negative Definite Hessian")
else:
    print("Indefinite Hessian")
```

    Stationary points are:
     {x1: 1.00000000000000, x2: 1.00000000000000}
    Value of the function at stationary point: 0.500000000000000
    The eigenvales are:
    7.53112887414927 -0.531128874149275
    Indefinite Hessian


be4f3179814a85fb033775235e3b5f496402857c
ipynb
Jupyter Notebook
Imcomplete_HW2.ipynb
MrNobodyInCamelCase/Trail_repo
2508eef78e9793945d46c2394a61633e693387b7
Apache-2.0
Imcomplete_HW2.ipynb
MrNobodyInCamelCase/Trail_repo
2508eef78e9793945d46c2394a61633e693387b7
Apache-2.0
Imcomplete_HW2.ipynb
MrNobodyInCamelCase/Trail_repo
2508eef78e9793945d46c2394a61633e693387b7
Apache-2.0
Qwen/Qwen-72B
1. YES
2. YES