Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Covers root finding, numerical integration, ODE solvers, optimization, interpolation and error analysis in Python.
68% 86%+18 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 15 of 22 without it.
In a Python wrapper around scipy.integrate.solve_ivp, what specific dictionary key should store the total number of function evaluations performed by the solver?
The count of function evaluations is stored under the key 'n_evaluations'.
3 of 3 safety checks passed
A skill for applying numerical methods in scientific computing and research. Covers root finding, numerical integration, ODE solvers, optimization, interpolation, and error analysis with practical implementations in Python.
import numpy as np
def newton_method(f, df, x0: float, tol: float = 1e-10,
max_iter: int = 100) -> dict:
"""
Newton's method for finding roots of f(x) = 0.
Args:
f: Function whose root we seek
df: Derivative of f
x0: Initial guess
tol: Convergence tolerance
max_iter: Maximum iterations
"""
x = x0
history = [x]
for i in range(max_iter):
fx = f(x)
dfx = df(x)
if abs(dfx) < 1e-15:
return {"root": x, "converged": False,
"reason": "Zero derivative encountered"}
x_new = x - fx / dfx
history.append(x_new)
if abs(x_new - x) < tol:
return {
Next to this one in the catalogue, plus more from the same author.