# Simbolic Math Toolbox: How to convert d-form sym to r-form? And a bug?

2 views (last 30 days)
Igor on 10 Feb 2011
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...

Walter Roberson on 10 Feb 2011
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.)