title: Efficiency of stack-based expression evaluation for math parsing
body: <p>I have to write, for academic purposes, an application that plots user-input expressions like: f(x) = 1 - exp(3^(5*ln(cosx)) + x)</p>
  
  <p>The approach I've chosen to write the parser is to convert the expression in RPN with the Shunting-Yard algorithm, treating primitive functions like "cos" as unary operators. This means the function written above would be converted in a series of tokens like:</p>
  
  <pre><code>1, x, cos, ln, 5, *,3, ^, exp, -
  </code></pre>
  
  <p>The problem is that to plot the function I have to evaluate it LOTS of times, so applying the stack evaluation algorithm for each input value would be very inefficient.
  How can I solve this? Do I have to forget the RPN idea?</p>