Basically I'm doing a small project for a math course that does root finding of functions, both polynomial and standard functions (using at most cos, sin, x, etc). Now I have a library with a class that acts as standard integer polynomial which takes in an array of coefficients and spreads it across an nth degree polynomial. It also calculates the polynomial at a given value (also integer). For the polynomial root finding algorithm it's pretty straightforward since the most I'm given is an array or vector of numbers.
On the other hand I am to create a library for other functions such as cos(x) + x-2 - x^2, and the like.
The problem is with the input. I can make the library take as parameters function objects as callbacks and just have the main program(mer) modify the source files. The only thing is I'm giving this as a program to the teacher, I don't want him to have to test if it works with different functions and modify and recompile everything himself (considering it's spread across three seperate projects).
What I imagine is one of two things.
1) design a "function" class that like the polynomial class represents an arbitrary function that's not a polynomial, and can evaluate it at x
2) take a file that has functions typed in it and my program parses it for what it is and can evaluate it.
I personally don't know what to choose as I don't know how I can represent an arbitrary function as completely as I can a polynomial outside of a string.
Anyone have an idea if I can have input as a script, and it could just use basic <cmath> library functions, or do I need to parse everything myself?