How I can obtain the numerical values of a symbolic results?

조회 수: 94 (최근 30일)
Pilar Jiménez
Pilar Jiménez 2017년 1월 23일
댓글: John D'Errico 2017년 1월 23일
For example, I have this expression -(5^(1/2)*i - (1 - 3*5^(1/4))^(1/2) + 5*i)/(8*pi), how I can obtain the numerical result?
  댓글 수: 2
John Chilleri
John Chilleri 2017년 1월 23일
편집: John Chilleri 2017년 1월 23일
If I type,
a = -(5^(1/2)*i - (1 - 3*5^(1/4))^(1/2) + 5*i)/(8*pi)
a =
0.0000 - 0.2136i
Does this not work for you?
When I did work with huge numbers (100s of digits), Matlab would leave it as symbols like you have when, I assume, it could not do the computation. I ended up using Maxima for these symbolic computations then going back to Matlab with the result. I don't imagine Matlab can't compute it unless it's obscenely large or contains portions that don't convert to mathematics.
Pilar Jiménez
Pilar Jiménez 2017년 1월 23일
Yes, I try to avoid a result like this 2745406554013086831442544068479080209^(1/2)*4355616553956842689236828859350347876557^(1/2)*108890357414700308308279874378165827665920^(1/2))/829748217121411424736445675629054455395170669059925077917696

댓글을 달려면 로그인하십시오.

답변 (1개)

Niels
Niels 2017년 1월 23일
of you have a symbolic expression use double (a is of class sym)
a=double(a)
  댓글 수: 3
Niels
Niels 2017년 1월 23일
is i said, if u got something like
result=solve(...)
result is a variable of class sym
try
result=double(result)
and your problem is solved
John D'Errico
John D'Errico 2017년 1월 23일
Double will produce a double precision result. If you want a symbolic result that has still many digits, use vpa.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by