I did something like this for EBay. I defined a hierarchy of Equation classes, including linear, nth order polynomials, power law. The base Equation class provided common functionality such as data initialization and solving for the unknown gien a variable. Applications could then be written that called the library function in real time, so a mouse could be tracked while live X and Y intercepts were displayed, etc. Sorry I can't offer the source code. Hopefully this gives you an idea of how you might proceed.
Mike