Hi,

I was wondering how to write code that allowed a user to input a mathematical expression for evaluation. For example, I've written a simple method that calculates Riemann sums.

```
def riemann(hgLoc, a, b, intervals):
sums = 0.0
size = float(b - a) / intervals
for i in range(0, intervals):
sums = sums + ((i+ hgLoc) * size + a) ** 2 #It's hard coded to f(x) = x ^ 2 right now...
sums *= size
return sums
```

Is there any way for it to do the following?

```
def riemann(hgLoc, a, b, intervals, USERINPUTEXPRESSION):
sums = 0.0
size = float(b - a) / intervals
for i in range(0, intervals):
sums = sums + USERINPUTEXPRESSION((i+ hgLoc) * size + a)
sums *= size
return sums
```

(Also is it possible to do this in Java?)

Thanks for any responses.