Project 3: Cost Function Minimizer
Scientific Computing
Builds on these lessons
Current Task
Objective
scipy.optimize.minimize() searches for the input that minimizes a function you provide — the foundation of SciPy's optimization tools.
Task: minimize a simple cost function and print the result's x value.
index.py
from scipy.optimize import minimize
def cost(x):
return (x[0] - 3) ** 2
result = minimize(cost, x0=[0])
print(result.x)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview