Ask Your Question

Revision history [back]

In Sage as in most math software, angles are measured in radians, not degrees.

So if by cos(45) you mean the cosine of 45 degrees, use cos(pi/4) instead.

The next thing is that Sage aims to give exact results for exact input.

To get a floating-point approximation for your computation, two choices.

First, you can compute exactly and then take a numerical approximation.

For this, use the numerical_approx method or its shortcut n.

sage: a = arcsin(5/24*cos(pi/4))
sage: a
arcsin(5/48*sqrt(2))

sage: a.numerical_approx()
0.147852003702638

sage: a.n()
0.147852003702638

Second, you can compute in floating-point all the way.

For this, start by using a floating point approximation of pi.

sage: a = asin(5/24*cos(pi.n()/4))
sage: a
0.147852003702638

In Sage as in most math software, angles are measured in radians, not degrees.

So if by cos(45) you mean the cosine of 45 degrees, use cos(pi/4) instead.

The next thing is that Sage aims to give exact results for exact input.

sage: a = arcsin(5/24*cos(pi/4))
sage: a
arcsin(5/48*sqrt(2))

To get a floating-point approximation for your computation, two choices.

  • First, you can compute exactly and then take a numerical approximation.

    For this, use the numerical_approx method or its shortcut n.

    sage: a = arcsin(5/24*cos(pi/4))
    sage: a
    arcsin(5/48*sqrt(2))
    
    sage: a.numerical_approx()
    0.147852003702638
    
    sage: a.n()
    0.147852003702638
    
  • Second, you can compute in floating-point all the way.

    For this, start by using a floating point approximation of pi.

    sage: a b = asin(5/24*cos(pi.n()/4))
    sage: a
    b
    0.147852003702638