Python Forum

Full Version: Polynomial value between a interval
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
n1 = eval(input())
n2 = eval(input())

(M, m) = (n1, n2) if n1 > n2 else (n2, n1)


i = m
while i < M:
    i += 0.5
    print(3* i**3 -5*i + 0.8)

if M == m:
    print(3*m**3 -5*m + 0.8)
I'm getting wrong values, almost every one wright, i don't get the first one e i get one after the inteval finish
Please provide an example (n1, n2, results)
Without knowing what your expected/actual output is, all we can do is guess what the problem is.  That said, your equation looks fairly complicated, and there could easily be an order of operations issue here.  Maybe add some parentheses to make it very obvious what should be happening?

...that said, you're modifying i, but the final equation doesn't even use it, it goes solely off of m, which is never modified.