By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,382 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

defining math function at run time

P: n/a
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 -))
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"philippe mordellet" <an*******@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
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).
thanks for your kind help,

philippe mordellet -))

Nov 15 '05 #2

P: n/a

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:Ox****************@TK2MSFTNGP09.phx.gbl...

"philippe mordellet" <an*******@discussions.microsoft.com> wrote in message news:8A**********************************@microsof t.com...
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).

SHould have done this initally, but there is a sample parser at
http://www.gotdotnet.com/Community/U...7-b996ed419284
It may hold the technique you need, appears to be in vb.net though. thanks for your kind help,

philippe mordellet -))


Nov 15 '05 #3

P: n/a
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 er****@microsoft.com, 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.
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:Ox****************@TK2MSFTNGP09.phx.gbl...

"philippe mordellet" <an*******@discussions.microsoft.com> wrote in message news:8A**********************************@microsof t.com...
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).
thanks for your kind help,

philippe mordellet -))


Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.