ans =
The question is not clear enough to be answered. "Make code that can solve math problems" sound like some genious work. "Math problems" is an extremely wide field and e.g. "adding and subtracting" is not enough for the tensor arithmetics of the 4 dimensional space time used in Einstein's theory of General Relativity.
"Finding variables" can mean a variety of things.
Please explain your problem with more details: Which kind of problems do you want to solve? What should be computed automatically and which part is done by Matlab? Post some examples.