defining math function at run time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello everybody

is it possible to ask the user to write a math function (ie : y = ax + b) in a textbox, and use this function to plot the curve in a window (how do Mathematica guys manage this, since its possible in their program ???

thanks for your kind help

philippe mordellet -))
 
philippe mordellet said:
hello everybody,

is it possible to ask the user to write a math function (ie : y = ax + b)
in a textbox, and use this function to plot the curve in a window (how do
Mathematica guys manage this, since its possible in their program ???)
You'll have to write a function parser, basically, which is most certainly
waht mathematica does. I am no master at it, but you should be able to find
some information on google. Look up something like "parsing math equations"
or the like. It shouldn't be terribly complex(assuming you are just doing
basic algebraic equations).
 
Daniel O'Connell said:
b)
in a textbox, and use this function to plot the curve in a window (how do
Mathematica guys manage this, since its possible in their program ???)
You'll have to write a function parser, basically, which is most certainly
waht mathematica does. I am no master at it, but you should be able to find
some information on google. Look up something like "parsing math equations"
or the like. It shouldn't be terribly complex(assuming you are just doing
basic algebraic equations).
SHould have done this initally, but there is a sample parser at
http://www.gotdotnet.com/Community/...mpleGuid=a756b0d7-9ab1-4ae3-8c87-b996ed419284
It may hold the technique you need, appears to be in vb.net though.
 
Daniel's approach will work.

You might also consider embedding the expression in a C# class and compiling
it using the C# compiler, and loading it in. Somewhere I have an example
that shows both techniques (though not for an arbitrary expression). I don't
think I have it accessible online - email me at (e-mail address removed), and
I'll send it to you.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://weblogs.asp.net/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top