MATLAB: Speed differences in sym and vpa

symvpa

I am working on an optimization problem that involves calling the Symbolic Math toolbox. The sym function makes optimization very slow, so I tried vpa and it made it a lot faster. I am wondering where the speed difference comes from? Is it the fact that sym converts everything to rational form while vpa doesn't? If so, should sym(x,'d') do the same thing as vpa(x) because now they're in the same form?
Thanks!

Best Answer

vpa() switches to arithmetic calculations with the default number of digits (unless you asked for different). That can be a lot faster than trying to find symbolic equivalences and symbolic special cases -- and is likely to require far fewer terms.