Numbers as multiply of pi?
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi, does anyone know how to tell Matlab it should show a number as a multiply of pi?
Example: atan(sqrt(3)/1) = 1.0472 but I want to see it as pi/3
Thx for the help guys.
댓글 수: 0
채택된 답변
Stephen23
2021년 3월 11일
atan(sqrt(sym(3))/1)
댓글 수: 3
Steven Lord
2021년 3월 11일
The order in which you call sym and other operations doesn't always matter, but it can.
Do you want to perform the calculations numerically then convert the result to a symbolic answer? Or do you want to perform the calculations symbolically from the beginning?
x = sym(2)^2000
y = sym(2^2000)
Calculating y computed 2^2000 in double precision first (which overflows to Inf) and then converts that infinity into a symbolic result. Calculating x "computes" 2 in double precision (which doesn't overflow), converts that 2 to a symbolic result that I'll call two, then computes two^2000 symbolically. Symbolic Math Toolbox can handle that large number.
If you have something where doing the work in double precision will lose desired precision, overflow, or underflow you probably want to go symbolic first. On the other hand, performing calculations symbolically has a bit more overhead.
Walter Roberson
2021년 3월 11일
sym(atan(sqrt(3)/1))
That happened to work. The symbolic toolbox can deal with pi divided by 1 to 9999 if I recall correctly
sym(pi/5987)
But beyond some simple ratios, it loses track
sym((pi-1)/3)
(sym(pi)-1)/3
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numbers and Precision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!