Simbolic Math Toolbox: How to convert d-form sym to r-form? And a bug?
4 次查看(过去 30 天)
显示 更早的评论
Two new questions --
Q5 How to easy convert symbolic d-form into r-form?
>> a=vpa(log(2),5)
a =
0.69315
This is d-form.
>> b=sym(rats(0.69))
b =
69/100
This is r-form.
That is -- what is symbolic analog command RATS?
Q6: new bug?
>> digits(32) >> vpa(pi,100)
ans =
3.141592653589793115997963468544185161590576171875
>> vpa pi 100
ans =
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803
It seems results must be equal...
0 个评论
采纳的回答
Walter Roberson
2011-2-10
vpa(pi,100)
evalutes pi at the Matlab level, to a double precision number, and passes that to vpa.
vpa pi 100
is equivalent, because of command / function duality, to
vpa('pi','100')
which would evaluate pi at the symbolic level according to the given number of digits.
Likewise, when you evaluate
vpa(log(2),5)
you are evaluating log(2) at the Matlab level, to a double precision number. You don't want to do that if you care about precision.
vpa(log(sym(2)),5)
I do not see at the moment a command to convert a decimal symbolic number to a fraction. Possibly
sym(vpa(log(2),5))
but I do not have the toolbox to test this with.
(I know the command in Maple, but it does not appear to exist in MuPad.)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Values 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!