PDA

View Full Version : Software designers Qbasic + mathemeticians polynomial graphs



blackmage_nuke
09-19-2007, 12:58 PM
So im writing this program for class that draws polynomial graphs using q basic. And i cant find the whats wrong with my program.
It works with Parabolas and Cubics curves, but for some reason when it gets to polynomials of degree 4, it draws the graph but there are these weird lines that appear on the sides.

This is the code


CLS
SCREEN 1
SCREEN 0

INPUT "What is the highest power of x?", power
FOR z% = 0 TO (power)
PRINT "what is the pronumeral of x^"; z%
INPUT pronum(z%)
NEXT

SCREEN 1
LINE (160, 0)-(160, 200)
LINE (0, 100)-(320, 100)
FOR i% = -30 TO 30
y = 0
y2 = 0
FOR z% = 0 TO (power)
y = (pronum(z%) * (i%) ^ (z%)) + y
y2 = (pronum(z%) * (i% + 1) ^ (z%)) + y2
NEXT
y = -y
y2 = -y2
posx = (i% * 6) + 160
posy = y + 100
posx2 = ((i% + 1) * 6) + 160
posy2 = y2 + 100
LINE ((posx), (posy))-((posx2), (posy2))
NEXT

Can anyone tell me how to get rid of those lines or atleast whats causing them?

I could be wrong but I think it might be that the values get too high or something and the program cant handle it and just goes to a really high value or something, if thats the case can someone tell me the maximum value?

Otherwise it could be some crazy maths concept ive never heard about

edit: I just realised pronumeral should be co-eficcient so dont point that out to me