|
-
Apr 13th, 2005, 07:46 PM
#1
Thread Starter
Junior Member
[RESOLVED]Quadratic Formula
Could anyone help me in representing the Quadratic Formula in VB6.0 code? I'm programming an app that requires plotting points along a parabola, and I need to convert the quadratic formula to code for easy use, maybe as a function.
For those of you that don't know, or don't remember from that boring algebra II class, the quadratic formula is:
-- Image removed by admin (linked site changed image to ad) --
Thanks in advance for any help.
Last edited by VipeR801; Apr 14th, 2005 at 10:26 AM.
Never Pet a Burning Dog.

-
Apr 14th, 2005, 02:48 AM
#2
New Member
Re: Quadratic Formula
The quadratic formula doesn't help you plot points- it's for finding the roots of the equation, ie the x values where y=0. (OK, so in that sense it gives you 2 points to plot; (x1,0) and (x2,0).) You just need to assign a,b & c their values and then calc the roots:
Code:
x1= (-b + ((b^2) - (4*a*c))^0.5 )/ (2*a)
'then put some code to plot (x1,0)
x2= (-b - ((b^2) - (4*a*c)) ^0.5)/ (2*a)
'then put some code to plot (x2,0)
To plot the points on the parabola, you just need to throw a whole bunch of different x values into the quadratic's equation (the equation itself, not the so-called Formula for finding the roots) and calculating the resulting y values.
Probably you would want to find the axis of symmetry first, then use (say) 5 x values either side. If my memory serves, the AoS is x=-b/2a but don't quote me.
Then just use a for..next loop starting to the left of AoS and passing to the right, each time re-calculating y= ax^2 + bx + c, giving a bunch of (x,y) pairs to plot.
Code:
aos= -b/(2*a) 'check this is right first!
start= ' some value to the left of aos
finish=' some value to the right of aos
for x= start to finish
y= (a*x^2) + (b*x) + c
'put some code to plot (x,y)
next x
-
Apr 14th, 2005, 08:15 AM
#3
Thread Starter
Junior Member
Re: Quadratic Formula
Alright, I got it to work, thanks for the help
Never Pet a Burning Dog.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|