Question
PYTHON CODE: Consider the equation X 4 = X 3 +10. [a,b]= [2,3] Write a PYTHON code to find the number of steps of Bisection
PYTHON CODE: Consider the equation X4= X3+10.
[a,b]= [2,3]
Write a PYTHON code to find the number of steps of Bisection method are required to calculate the solution within 10-10. Use a for loop.
CODE SO FAR: (not right):
#!/usr/bin/python import math
#Interval is [2,3] # tolerance is 10^-10 = 0.0000000001 # f(x) is x^4-x^3 - 10
a=2.0 b=3.0 y = 0.0 c = 0.0 count = 1 for i in range(10000000): count = count+1 c = (a+b)/2.0 y = (math.pow(a,4)-math.pow(a,3) - 10) * (math.pow(c,4)-math.pow(c,3) - 10) print(y) if abs(y) < 0.0000000001: break if y > 0: a = c if y < 0: b = c
print(count)
(answer should be 33 or 34)
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