I'm trying to build a program in Pascal to differentiate mathematical functions. It's working very well (calculate min/max, symmetry, drawing the graph, etc.) but I have to put the functions (i.e. x^3+3x+2) into the source code like this:
function f(x : real): real;
begin
f := x * x * x + 3 * x + 2;
end;
Though, I want the user to define the function to differentiate. Obviosly the readln function does not help. Somebody told me the only solution would be a specific parser. But it's very difficult, and I don't know how to do it. My idea would be to extract the function into a *.txt file for example so that it could be changed easily. Is that possible? Can somebody show me a parser which could solve this problem or have anybody some other great solution? I would really appreciate your help! Thanks in advance ;)