Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifying a mathematical function

Status
Not open for further replies.

Bussotao

Programmer
Mar 26, 2002
11
0
0
BR
Hi:
I want to build a project in which there is a field where the user put an mathematical expression. Then I want to use this expression to make some calculations.
As an example the user would type the expression
cos(x*x)
and the code would draw the graph of the function typed.
Tks a lot.

 
That thing is not an easy task.
First you need to code a function evaluator.
Then using the Function Evaluator you need assign some values to the independient variable betwen an interval and draw the resulting value.

You can use many tool that Borland C++ has, like stacks and Charts.

--- LastCyborg ---
 
Howdy,

I built a graphing calculator a while back, and faced the ugly task of parsing the expression string. All I can say is get ready; this is very complicated. The graphing is rather simple. I used a TImage object to draw on. The problem was too big for me to tackle then, and is probably too big for me to tackle now. The fact is, that there are SO many contingencies you must plan for from the start. The problem I couldnt get around was how to create a sequence to convert the expression into a series of appropriate function calls that can be repeated to attain the ordered pairs needed to graph.

So have fun and post your progress. It would be very interesting to brainstorm this one again.

onrdbandit
 
What you need to do is dig around for the "Reverse Polish Notation". This is a binary-tree representation of a mathematical function and this is what you need to use to compute values for your expressions.

Once you built that tree, it's relatively easy to compute the value of a function and then plot it on the screen.

Good luck.

~~Razvan

[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top