Python Forum
Polynomial value between a interval
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Polynomial value between a interval
#1
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
Reply
#2
Please provide an example (n1, n2, results)
Reply
#3
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.
Reply
#4
See https://python-forum.io/Thread-Polynomia...4#pid30634
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  integer +-* interval mcgrim 2 2,163 May-08-2019, 11:53 AM
Last Post: mcgrim
  draw sample from distribution in interval SchroedingersLion 2 2,484 Oct-28-2018, 10:23 PM
Last Post: SchroedingersLion
  sklearn Polynomial Features Graphing pegn305 0 2,327 Mar-02-2018, 10:22 PM
Last Post: pegn305
  matplotlib legend and x axis interval metalray 5 25,715 Apr-14-2017, 12:07 PM
Last Post: metalray

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020