MATLAB: Is there a way to define a tolerance for an equation that I want to solve numerically

efficiencyMATLABvpasolve

I am trying to solve an equation that is accepted to describe a nomogram. Due to the number of times the equation has to be called, I would prefer to solve it numerically. A precise answer is not, required, however. I am currently using vpasolve, and have the initial guess defined as well.
I have used Profiler to determine that currently about 90-95% of the time spent running my code is on the calculation of this equation. If I could define a tolerance such that the equation would be solved in a shorter amount of time, I believe it would be greatly helpful.
Any help would be appreciated! Thanks!

Best Answer

Why are you using symbolic tools? I see too many people using syms for simple problems that have no need at all for anything symbolic. The result is they get slow running code for no good reason.
Instead, just work with regular variables, in double precision. If I had to guess, I would imagine that because someone does not know the value of some number, then it MUST be represented as a symbolic parameter, using the symbolic toolbox. In fact, that is wrong, but it seems to be a common misperception held by many students and new users of MATLAB.
Yes, there are some cases where what is really needed is a knowledge of numerical analysis. Lacking that, some people just resort to using symbolic tools to avoid any worries about precision.
And of course, there are some rare cases where symbolic tools are used for good reason. But if you are starting with real numbers, known to a very short number of digits? Then all of those carefully crafted symbolic computations with all those extra digits are just wasting CPU time computing essentially random digits beyond where you have any significance.
Anyway, some of this aggregate of individuals eventually realize their code runs as slowly as a horse with two legs, because they have used symbolic tools for no good reason.
Of course, I cannot know why you have done what you did, because I cannot see into your mind, or even your computer. But what you have described is a perfect example of a case where a computation is being done using a symbolic tool, where in the end, the result is needed not in symbolic form, but as a number with far fewer digits, with far less precision.
So use tools like fzero, fminbnd, or optimization toolbox tools like fsolve. If necessary, learn some techniques of numerical analysis. You will surely find that valuable for long term use of MATLAB.