Untitled
unknown
plain_text
3 years ago
644 B
33
Indexable
def cube(x):
return x ** 3
x_0 = -1
x_1 = 1
def sign(x, y):
if cube(x) * cube(y) > 0:
return 1
return -1
def difference(x, y):
return x - y
def is_this_a_zero(x, y):
if cube(x) == 0:
print(x)
elif cube(y) == 0:
print(y)
else:
if sign(x, y) == -1:
x_2 = (x + y) / 2
if sign(x_2, x) == -1:
y = x_2
pass
x = x_2
else:
print("The numbers are not compatible")
while difference(x_1, x_0) > 0.1:
is_this_a_zero(x_0, x_1)
print("Your zero is between ")
Editor is loading...