Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this sypder task, you need to complete the two missing lines to solve the problem: finding the corresponding value of x which can lead
In this sypder task, you need to complete the two missing lines to solve the problem: finding the corresponding value of x which can lead to x ** x = 20 import numpy as np import matplotlib.pyplot as plt def func(x): return x**x def solve_bisection(function, lower, upper, value): if function((lower + upper) / 2) < value: # please complete the following line else: # please complete the following line lower, upper, value = 1, 3, 20 boundary_list = [(lower,upper),] while abs(func(sum(boundary_list[-1]) / 2) - value) > 1e-6: boundary_list.append(solve_bisection(func, boundary_list[-1][0], boundary_list[-1][1], value)) res = sum(boundary_list[-1]) / 2 length = len(boundary_list) plt.plot(np.linspace(0.1, 3.5), func(np.linspace(0.1, 3.5)), linewidth = 2) for boundary, i in zip(boundary_list, np.linspace(80, 30, length)): plt.plot(boundary, [i]*2, 'D-', linewidth = 2) plt.axvline(x = res, linestyle = '--', color = 'gray') plt.plot(res, func(res), 'x', markersize = 15, markeredgewidth = 3, color = 'red') plt.xlabel('x') plt.ylabel('y')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started