NumPy allowed · plain Python earns 10 bonus points
θ ← θ − 0.14 · ∂L/∂θ
Execute a single iteration of the linear Conjugate Gradient algorithm for symmetric positive-definite systems.
Implement conjugate_gradient_step(A, b, x, r, p): calculate matrix-vector product A p, step size alpha = (r . r) / (p . A p), updated solution x_next = x + alpha * p, updated residual r_next = r - alpha * A p, conjugate direction factor beta = (r_next . r_next) / (r . r), and new search direction p_next = r_next + beta * p. Return {"x": list, "r": list, "p": list} rounded to 4 decimals.
conjugate_gradient_step(A: list[list[float]], b: list[float], x: list[float], r: list[float], p: list[float]) -> dict[str, list[float]]