Accepted Answer

Symbolic equation solving is a complex problem and there is no closed solution for many equations. Writing your own Computer Algebra System is none trivial, but you may be able to write a program for simple equation.

You will have to build a expression tree of the input string and define transformation rules for manipulating the expression tree. To solve for a variable you might then perform a search (guided by good heuristics to keep the runtime acceptable) on the space of expression tree that can be derived from the orginal tree by multiple aplications of
transformation rules.

Popular Answer

This is a non-trivial problem you're trying to solve... I don't think you'll have much luck trying to solve it on your own. Better to find some kind of third-party app or library that does it. There are a number of programs that can do the operation you're talking about, such as Matlab and Maple. Also, a TI-89 graphing calculator can do it. You may be able to get the algorithms you need from Octave, which is essentially an open-source implementation of Matlab.