Speed differences in sym and vpa

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!

 採用された回答

Walter Roberson
Walter Roberson 2013 年 10 月 11 日

0 投票

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.

1 件のコメント

Pat
Pat 2013 年 10 月 11 日
編集済み: Pat 2013 年 10 月 11 日
Thanks for your answer. Does this mean that sym(x,'d') is the same as vpa(x)?

サインインしてコメントする。

その他の回答 (1 件)

Alan Weiss
Alan Weiss 2013 年 10 月 11 日

0 投票

I recommend using matlabFunction for optimizing symbolic variables and functions. There is an extensive example here, and another example here.
Alan Weiss
MATLAB mathematical toolbox documentation

タグ

質問済み:

Pat
2013 年 10 月 10 日

回答済み:

2013 年 10 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by