Answers for "what is the secant method example"

1

secant method

def secant_method(f, x0, x1, iterations):
    """Return the root calculated using the secant method."""
    for i in range(iterations):
        x2 = x1 - f(x1) * (x1 - x0) / float(f(x1) - f(x0))
        x0, x1 = x1, x2
    return x2

def f_example(x):
    return x ** 2 - 612

root = secant_method(f_example, 10, 30, 5)

print("Root: {}".format(root))  # Root: 24.738633748750722
Posted by: Guest on March-15-2021
0

secant method

x(i+1) = x(i-1)f(xi)-x(i)f(xi-1)/f(xi)-f(xi-1)
Posted by: Guest on June-11-2020

Code answers related to "what is the secant method example"

Python Answers by Framework

Browse Popular Code Answers by Language