Potting functions in VB NET (please help...)

geonaf

Freshman
Joined
Jan 28, 2003
Messages
29
Hi guys!
How can I plot functions in vb net?
The user enters a math expression for f(x) and the program plots this.,eg: f(x)=x^2+Sin(x)
Is that possible with vb net??
Thanks
 
I figure that you can numerically solve the equation for a small step of x variables and fill an arrary with the soluvtions for both x and f(x), I just don't know how to graph my array.
 
That's what I did.
You can just put a function...
Visual Basic:
Private Function F(ByVal X As Currency) As Currency
F = X*X
End Function
Then you can graph it like this:
Visual Basic:
For X = -20 To 20
  Y = F(X)
  'You can draw Y here with whatever graphics you need
  'Preferably a DrawPixel of some sort at (X, Y), however
  'it will be upside down, so you'd have to take your Y
  'value and negate it.
  Y = -Y
  'Then you need to move it on the visible area of the form.
  Y += Width
  'Where Width is the width of the area that you want to
  'see the drawing at.
Next
 
Script

I have heard that I could use a Script with my application in order to do that.Does anyone know details???
 
Is there a command which can convert string variables to arithmetical values, eg:
user types "x^2+5*x" as string and the machine regocnise it as an operation.???????
 
There may be some addin of some sort (like a MS Scripting addin) that will do this for you, but I doubt if .NET comes with a way to do this, mainly because there are so many ways to parse an arithmetic function.
You would have to either hardcode all the functions or use the polynomial approach, in which you specify the coefficients for each exponent... i.e. for x^3 + 3x^2 + 12, you would have 1, 3, 0, and 12. :)
 
Back
Top