import library as func
#library needed to define the logminussins
import math
def logminussin(x):
    return math.log(x) - math.sin(x)
def xminuscos(x):
    return 0 - x - math.cos(x)
#Question 1a
print("Question 1a:-")
print("********************************************************************************************************************************\n")
print("Bisection Method: ")
print("The root of the function is :", func.bisection(1.5, 2.5, logminussin, 200,"Q1a",10**(-6)))
print('\n')
print("********************************************************************************************************************************\n")
print("Regula Falsi method :")
print("The root of the function is :", func.regulafalsi(1.5, 2.5, logminussin, 200,"Q1a",10**(-6)))
print('\n')
print("********************************************************************************************************************************\n")
print("Newton-Raphson method : ")
print("The root of the function is :", func.newtonraphson(1.5, logminussin, 200,"Q1a",10**(-6)))
print('\n')
print("********************************************************************************************************************************")
print("Question 1b:-")
print("********************************************************************************************************************************\n")
print("Bisection Method: ")
print("The root of the function is :", func.bisection(1.5, 2.5, xminuscos, 200,"Q1b",10**(-6)))
print('\n')
print("********************************************************************************************************************************\n")
print("Regula Falsi method :")
print("The root of the function is :", func.regulafalsi(1.5, 2.5, xminuscos, 200,"Q1b",10**(-6)))
print('\n')
print("********************************************************************************************************************************\n")
print("Newton-Raphson method : ")
print("The root of the function is :", func.newtonraphson(-1.0, xminuscos, 200,"Q1b",10**(-6)))
print('\n')

#Output
'''
Question 1a:-
********************************************************************************************************************************

Bisection Method: 
The root of the function is : 2.219106674194336


********************************************************************************************************************************

Regula Falsi method :
The root of the function is : 2.2191070451360577


********************************************************************************************************************************

Newton-Raphson method :
The root of the function is : 2.2191071502170927


********************************************************************************************************************************
Question 1b:-
********************************************************************************************************************************

Bisection Method:
The root of the function is : -0.739084780216217


********************************************************************************************************************************

Regula Falsi method :
The root of the function is : -0.7390847418148648


********************************************************************************************************************************

Newton-Raphson method :
The root of the function is : -0.7390851333852848
'''
