Math expression calulation

Hi, everyone:
My program need a class of function to calulate expressions user input, like this: user input “sin(sqrt(x^2+y^2))” and system will calculate this expression from x=1 to 20 and y=1 to 20.
I’ve wrote a class use stack to solve this problem but it runs really really slow (My computer’s CPU is Pentium M 1.5G), so, I want to find a better way to calculate expressions like that, please help me or tell me how to do it, thanks a lot!

The standard hint is:

“Use a stack of opcodes to convert the expression into postfix notation, then use a stack of operands to compute the result.”

If you have done this and it runs too slowly, the problem is somewhere in your code. Post the code and perhaps someone can help further.