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

조회 수: 2 (최근 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...

채택된 답변

Walter Roberson
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개)

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by