Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168703
Image: ubuntu2004

Let's see how sage handles pi.

pi
pi
sin(pi)
0

In Matlab, sin(pi) returns 1.2246e-16. But Sage handles pi correctly. It will also handle e (in addition, exp(1) returns e), golden_ratio (the golden ratio), euler_gamma, and a number of other constants. In order to approximate pi with a decimal we must first define a function that converts a numerical type into a decimal with a bit precision we specify. This is done with RealField(precision). Try changing the number inside the parentheses below and reevaluating.

R=RealField(200) R(pi)
3.1415926535897932384626433832795028841971693993751058209749