# quasi_newton.py
"""Volume 2: Quasi-Newton Methods
"""
def newton_ND(J, H, x0, niter=10, tol=1e-5):
"""
Perform Newton's method in N dimensions.
Inputs:
J (function): Jacobian of the function f for which we are finding roots.
H (function): Hessian of f.
x0 (float): The initial guess.
niter (int): Number of iterations to compute.
tol (float): Stopping criteria for iterations.
Returns:
The approximated root and the number of iterations it took.
"""
return NotImplementedError("Problem 1 Incomplete")
def broyden_ND(J, H, x0, niter=20, tol=1e-5):
"""
Perform Broyden's method in N dimensions.
Inputs:
J (function): Jacobian of the function f for which we are finding roots.
H (function): Hessian of f.
x0 (float): The initial guess.
niter (int): Number of iterations to compute.
tol (float): Stopping criteria for iterations.
Returns:
The approximated root and the number of iterations it took.
"""
return NotImplementedError("Problem 2 Incomplete")
def BFGS(J, H, x0, niter=10, tol=1e-6):
"""
Perform BFGS in N dimensions.
Inputs:
J (function): Jacobian of objective function.
H (function): Hessian of objective function.
x0 (float): The initial guess.
niter (int): Number of iterations to compute.
tol (float): Stopping criteria for iterations.
Returns:
The approximated root and the number of iterations it took.
"""
return NotImplementedError("Problem 3 Incomplete")
def prob4():
"""
Compare the performance of Newton's, Broyden's, and modified Broyden's
methods on the following functions:
f(x,y) = 0.26(x^2 + y^2) - 0.48xy
f(x,y) = sin(x + y) + (x - y)^2 - 1.5x + 2.5y + 1
"""
return NotImplementedError("Problem 4 Incomplete")
def gauss_newton(J, r, x0, niter=10):
"""
Solve a nonlinear least squares problem with Gauss-Newton method.
Inputs:
J (function): Jacobian of the objective function.
r (function): Residual vector.
x0 (float): The initial guess.
niter (int): Number of iterations to compute.
Returns:
The approximated root.
"""
return NotImplementedError("Problem 5 Incomplete")
def prob6():
"""
Compare the least squares regression with 8 years of population data and 16
years of population data.
"""
return NotImplementedError("Problem 6 Incomplete")