Actually computing the function value from the input expression would fall in the ambit of symbolic mathematics, which, I believe is strongly connected to string parsing in a more beginning state.
So, I think that your problem can be reduced to a “simple” string processing problem.
You should keep a table of symbols which stand for the common operations, like +,/,x,^, etc and then you must try and play with it a bit…
Like, if you find a ^ you must convert the base and exp to numbers to display the result, you should keep constants unchanged, if you find a parenthesis, then you know you have a function. Then you:
a) Either reduce the argument if its an expression f(x^2 + 6) reduces to f(result);
b) Leave it as it is replacing x by the value given;
I know this sounds easier said than done, but, while the code might be hard to get working properly, I believe this is the whole idea