Answer to Question #157620 in Algebra for Sajal Abbasi

Question #157620

x^3+8x^2+18x+7=0

Solve for x


1
Expert's answer
2021-02-04T07:58:01-0500


#Let's implement sentences numerical method in python

a0 = int(input('Enter the left spacing value: '))


a1 = int(input('Enter the right span value: '))


solve = [a0,a1]


i = True


while i:


x = (solve[0] + solve[1]) / 2


f = x**3 + 8*x**2 + 18*x + 7


if f > 0:


solve[1] = x


print(solve)


if f < 0:


solve[0] = x


print(solve)


if f == 0:


print(x)


i = False


if abs(solve[0] - solve[1]) <= 0.001:


i = False


print(f'{solve}')


#Output:


#Enter the left spacing value: -1000


#Enter the right span value: 1000


#[-1000, 0.0]


#[-500.0, 0.0]


#[-250.0, 0.0]


#[-125.0, 0.0]


#[-62.5, 0.0]


#[-31.25, 0.0]


#[-15.625, 0.0]


#[-7.8125, 0.0]


#[-3.90625, 0.0]


#[-1.953125, 0.0]


#[-0.9765625, 0.0]


#[-0.9765625, -0.48828125]


#[-0.732421875, -0.48828125]


#[-0.6103515625, -0.48828125]


#[-0.54931640625, -0.48828125]


#[-0.518798828125, -0.48828125]


#[-0.5035400390625, -0.48828125]


#[-0.49591064453125, -0.48828125]


#[-0.492095947265625, -0.48828125]


#[-0.4901885986328125, -0.48828125]


#[-0.48923492431640625, -0.48828125]


#[-0.48923492431640625, -0.48828125]


#Answer: take half of our segment -0.488−0.488


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS