AMATH Quiz 7

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:31 AM on 2/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

24 Terms

1
New cards

What is the “objective function” in an optimization problem?

The function that you are trying to maximize or minimize.

2
New cards

What is argmin?

The x value at which the minimum occurs.

3
New cards

What is minimum?

THe minimum value of the output of the function.

4
New cards

What is argmax?

The x value at which the maximum occurs.

5
New cards

What is maximum?

The maximum value of the output of the function.

6
New cards

Solve maximization problems by recasting as a minimization problem and using a minimization technique.

max(g(x))=min(h(x))\max\left(g\left(x\right)\right)=-\min\left(-h\left(x\right)\right)

7
New cards

What is the FIRST step to minimize functions using scipy.optimize.fsolve to find the root of the derivative of the function.

Take the derivative of the function analytically.

8
New cards

What is the SECOND step to minimize functions using scipy.optimize.fsolve to find the root of the derivative of the function.

Find the root numerically using scipy.optimize.fsolve .

9
New cards

What is the FINAL step to minimize functions using scipy.optimize.fsolve to find the root of the derivative of the function.

Check to see if it’s a max or min by checking a nearby point or looking at a graph.

10
New cards

Show an example of minimizing functions using scipy.optimize.fsolve to find the root of the derivative of the function.

import numpy as np
import matplotlib.pyplot as plt
f = lambda x: x**2*np.sin(x)
f_prime_factor = lambda x: x*np.cos(x) + 2*np.sin(x)
from scipy.optimize import fsolve
crit_point = fsolve(f_prime_factor, -2)[0]
print("Minimizer = ", crit_point)
print("Minimum =", f(crit_point))

11
New cards

What is the syntax for fminbound?

scipy.optimize.fminbound(function, a, b)

12
New cards

Give an example of scipy.optimize.fminbound being used.

import numpy as np
import matplotlib.pyplot as plt
f = lambda x: x**2*np.sin(x)
xplot = np.linspace(-5, 5, 200)
fig, ax = plt.subplots() 
ax.plot(xplot, f(xplot), linewidth=3, label=r"$f(x)$")
ax.legend()
plt.xlim([-3, -1]) # Restrict the x range for the plot
plt.ylim([-5, 0])  # Restrict the y range for the plot
from scipy.optimize import fminbound
argmin = fminbound(f, -3, -1) # Syntax is fminbound(function, left_bound, right_bound)
print("Minimizer = ", argmin)
print("Minimum =", f(argmin))
plt.show()

13
New cards

What is the FIRST step to recognize and explain the steps of the gradient descent algorithm.

Calculate the gradient, Δf(p0)\Delta f\left(p_0\right).

14
New cards

What is the SECOND step to recognize and explain the steps of the gradient descent algorithm.

Define the line in the negative direction of the gradient, Φ(t)=p0tΔf(p0)\Phi\left(t\right)=p_0-t\cdot\Delta f\left(p_0\right).

15
New cards

What is the THIRD step to recognize and explain the steps of the gradient descent algorithm.

Define the function of heights along the line, f(Φ(t))f\left(\Phi\left(t\right)\right).

16
New cards

What is the FOURTH step to recognize and explain the steps of the gradient descent algorithm.

Use fminbound to find t*, the minimizer of the heights along the line f(Φ(t))f\left(\Phi\left(t\right)\right).

17
New cards

What is the FINAL step to recognize and explain the steps of the gradient descent algorithm.

Define p1=f(Φ(t))p_1=f\left(\Phi\left(t^{\ast}\right)\right).

18
New cards

Give an example of meshes being created from two arrays using np.meshgrid .

import numpy as np
x = np.linspace(-2, 1, 4)
y = np.linspace(-4, 4, 3)

X_grid, Y_grid = np.meshgrid(x,y)

19
New cards

Give an example of a contour plot of 2-dimensional functions being created.

# Create our function
f = lambda x, y: (x-2)**2 + (y+1)**2 + 5*np.sin(x)*np.sin(y) + 100 

fig, ax = plt.subplots()

# 🚨 Create the contour plot
ax.contour(X_grid, Y_grid, f(X_grid, Y_grid))

20
New cards

Give an example of a surface plot of 2-dimensional functions being created.

# Create our function
f = lambda x, y: (x-2)**2 + (y+1)**2 + 5*np.sin(x)*np.sin(y) + 100 

# 🚨 Tell matplotlib we are making a 3D plot
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
# 🚨 Plot the surface by evaluating f on the grid.
ax.plot_surface(X_grid, Y_grid, f(X_grid, Y_grid))

21
New cards

What is the standard format for the while function?

while condition:
# some action

22
New cards

What does numpy.linalg.norm do?

Calculates vector and matrix norms.

23
New cards

What is the standard format for linalg.norm ?

numpy.linalg.norm(x)

24
New cards

What is the standard format for optimize.fmin ?

argmin = scipy.optimize.fmin(function, [0, 0])