<jupyter_start><jupyter_text>Root Finding  Bisection Method<jupyter_code>def bisect(a, b): 
    p = (a + b)/2
    fa, fb, fp = f(a), f(p), f(b) 

    print(a,  "\t", p,  "\t",  b)
    print(fa, "\t", fb, "\t", fp)
    return p
def f(x): 
    return x ** 2 - 36 
# initial values
a = 1
b = 10 
fa = f(a) 
fb = f(b) 
fa, fb
a, b = a, b
p = bisect(a, b)
a, b = p, b
p = bisect(a, b)
a, b = a, p
p = bisect(a, b)
a, b = a, p
p = bisect(a, b)
a, b = a, p
p = bisect(a, b)
a, b = p, b
p = bisect(a, b)
a, b = p, b
p = bisect(a, b)
a, b = p, b
p = bisect(a, b)
a, b = a, p
p = bisect(a, b)
a, b = a, p
p = bisect(a, b)<jupyter_output><empty_output><jupyter_text>Newton's Method<jupyter_code>def f(x): 
    return x ** 2 - 36 
def fp(x): 
    return 2 * x 
def new_val(x): 
    return x - (   f(x) / fp(x)    )
x = 2
x = new_val(x)
x
x = new_val(x)
x
x = new_val(x)
x
x = new_val(x)
x
x = new_val(x)
x
x = new_val(x)
x















def new_val(x, f, fp): 
    return x - ( f(x) / fp(x) )
def root_81(x): 
    return x**2 - 81 
def root_81_p(x): 
    return 2*x
initial_value = 7
x = new_val(initial_value, root_81, root_81_p)
print(x)
x = new_val(x, root_81, root_81_p)
print(x)
x = new_val(x, root_81, root_81_p)
print(x)
def g(x): 
    return (x+2)**2 - 81 
def gp(x): 
    return 2 * (x+2)
x = new_val(11, g, gp)
print(x)
x = new_val(x, g, gp)
print(x)
x = new_val(x, g, gp)
print(x)
x = new_val(x, g, gp)
print(x)<jupyter_output>7.000021496685752
{'fraction_non_alphanumeric': 0.19182825484764543, 'fraction_numerical': 0.039473684210526314, 'mean_word_length': 2.7146529562982007, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '447870', 'license': 'Apache-2.0', 'n_tokens_mistral': 811, 'n_tokens_neox': 749, 'n_words': 216, 'path': 'Notebooks/07-root-finding.ipynb', 'repo_name': 'jkbells/Numerical-Computing-CS2008', 'size': '1444'}