#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 13 14:19:07 2024

@author: sam
"""

import numpy as np

h = 1e-15 #step in h

'''define functions'''
def f(x):
    return x - np.cos(x)

def dfdx(x):
    return (f(x+h)-f(x))/h

def N(x):
    while abs(f(x)) >= 0.00001: #checks for tolerance range
        x = x - f(x)/dfdx(x) #Newton's Method formula
    return x



print(N(0.5))