# Problem to calculate arcsin(5/24*cos(45)) to a real number

When I enter the expression arcsin(5/24*cos(45)) in a Jupyter Notebook running the Sage kernel, I "only" receive arcsin(5/24*cos(45)).

I want to have the expression as a real number, but I don't know how to tell Sage that I want this expression to be calculated.

edit retag close merge delete

You can use real numbers in the calculation to get a real number result, namely arcsin(5/24*cos(45.0))

( 2022-11-24 10:37:09 +0100 )edit

Welcome to Ask Sage! Thank you for your question.

( 2022-11-24 15:00:28 +0100 )edit

Sort by » oldest newest most voted

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

more

I want to have the expression as a real number

arcsin(5/24*cos(45)) is a Sage object representing the quantity you want to manipulate; its value is a real number+. What you are seeking is a numerical approximation of this quantity expressed as a decimal representation. Which can be obtained by :

sage: numerical_approx(arcsin(5/24*cos(45)))
0.109661742042478


or

sage: arcsin(5/24*cos(45)).n()
0.109661742042478


Try numerical_approx?...

• Note that there are an infinity of complex values whose $\sin$ is 5/24*cos(45) ; the mathematical function $\arcsin$ is multivalued. The Sage function arcsin implement aparticular choice of this branch cut, returning a value in the interval $[-\frac\pi2\ \frac\pi2]$.
more