Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def secant(n):
- def function(x):
- f=x-math.cos(x)
- return f
- xold=0.0
- xnow=1.0
- for i in range(n):
- xnew=xnow-function(xnow)((xnow-xold)/(function(xnow)-function(xold))
- xold=xnow
- xnow=xnew
- return xnew
- def main():
- print("The root is",secant(10))
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement