<jupyter_start><jupyter_text>Problem 4 Part CMaking a Contuor Plot with overlaid quiver plot of the gradient<jupyter_code>#Calculate vector Values
import numpy as np
import matplotlib.pyplot as plt

def f(x):
    return 3*x[1]**2+4*x[0]*x[1]-16*x[0]-16*x[1]+24
def grad0(x):
    return 4*x[1]-16
def grad1(x):
    return 6*x[1] + 4*x[0] -16

min = -1
max = 1

npoints = 20
x0Vals = np.linspace(min, max, npoints)
x1Vals = np.linspace(min, max, npoints)
fVals = np.zeros([x0Vals.size, x1Vals.size])
grad0Vals = np.zeros_like(fVals)
grad1Vals = np.zeros_like(fVals)

for i0 in range(x0Vals.size):
    for i1 in range(x1Vals.size):
        x = np.array([x0Vals[i0], x1Vals[i1]])
        fVals[i0, i1] = f(x)
        grad0Vals[i0, i1] = grad0(x)
        grad1Vals[i0, i1] = grad1(x)
#Make the plot
plt.contourf(x0Vals, x1Vals, fVals)
plt.colorbar()
plt.quiver(x0Vals, x1Vals, grad0Vals, grad1Vals)
plt.title('Problem 4.c Contour and Gradient', fontsize=25)
plt.xlabel('x0')
plt.ylabel('x1')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15579357351509251, 'fraction_numerical': 0.06426484907497566, 'mean_word_length': 4.468085106382978, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '656961', 'license': 'MIT', 'n_tokens_mistral': 508, 'n_tokens_neox': 481, 'n_words': 99, 'path': 'Python/TannerSpicerCalcHomework3.ipynb', 'repo_name': 'Rowdyboy6/HomeWork', 'size': '1027'}