<jupyter_start><jupyter_text>Question 1  Finding the root using the Bisection method<jupyter_code>import math
from functionLibrary import rootBisec

y = lambda x: math.log(x/2) - math.sin(5*x/2) #defining the function

a = float(input("Enter first approx: "))
b = float(input("Enter second approx: "))

rootBisec(y, a, b)<jupyter_output>Required root is:  2.623137969970703<jupyter_text>Finding the root using the Regula Falsi method<jupyter_code>import math
from functionLibrary import rootRegFalsi

y = lambda x: math.log(x/2) - math.sin(5*x/2) #defining the function

a = float(input("Enter first approx: "))
b = float(input("Enter second approx: "))

rootRegFalsi(y, a, b)<jupyter_output>Required root is:  2.623140463495963<jupyter_text>Question 2  Finding the root using the Bisection method<jupyter_code>import math
from functionLibrary import rootBisec

y = lambda x: -x - math.cos(x) #defining the function

a = float(input("Enter first approx: "))
b = float(input("Enter second approx: "))

rootBisec(y, a, b)<jupyter_output>Required root is:  -0.7390867996215817<jupyter_text>Finding the root using the Regula Falsi method<jupyter_code>import math
from functionLibrary import rootRegFalsi

y = lambda x: -x - math.cos(x) #defining the function

a = float(input("Enter first approx: "))
b = float(input("Enter second approx: "))

rootRegFalsi(y, a, b)<jupyter_output>Required root is:  -0.7390835727489464<jupyter_text>Finding the root using the Newton-Raphson method with initial guess x = 0.0<jupyter_code>import math
import matplotlib.pyplot as plt
from functionLibrary import newRaph


h = 0.00001 #defining the h that will be used to calculate first derivative of y using first principle
x0 = 0.0 #dummy variable for root


y = lambda x: -x - math.cos(x) #defining the function
dy = lambda x: (y(x+h)-y(x-h))/(2*h) #defining the first derivative of the function using first principle

x, n = newRaph(y, dy, x0, h, 100)
print("The root is %f at %d iterations." %(x, n)) #printing the results<jupyter_output><empty_output><jupyter_text>Question 3<jupyter_code>import math
from functionLibrary import polyRoots

guess = float(input("Enter initial guess: "))
a = [4.0, 0.0, -5.0, 0.0, 1.0] #the co-efficients of the polynomial are fed to the function
                               #in this way. the lowest power (the constant) is written first. 

print("The required roots are: ") #printing the accompanying result statement
polyRoots(guess, a)<jupyter_output>The required roots are:
{'fraction_non_alphanumeric': 0.10361067503924647, 'fraction_numerical': 0.039638932496075356, 'mean_word_length': 4.505399568034557, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '313075', 'license': 'Apache-2.0', 'n_tokens_mistral': 967, 'n_tokens_neox': 887, 'n_words': 275, 'path': 'assignment-5/assignment-5.ipynb', 'repo_name': 'peakcipher/p346-computational-lab', 'size': '2548'}