Numbers as multiply of pi?
23 views (last 30 days)
Show older comments
Fabian Glutz
on 11 Mar 2021
Commented: Walter Roberson
on 11 Mar 2021
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 Comments
Accepted Answer
Stephen23
on 11 Mar 2021
atan(sqrt(sym(3))/1)
3 Comments
Steven Lord
on 11 Mar 2021
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
on 11 Mar 2021
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
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!