Processing math: 100%
Ask Your Question
1

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

asked 2 years ago

pfeifhns gravatar image

updated 2 years ago

slelievre gravatar image

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.

Preview: (hide)

Comments

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

tolga gravatar imagetolga ( 2 years ago )

Welcome to Ask Sage! Thank you for your question.

slelievre gravatar imageslelievre ( 2 years ago )

Thank you very much for your answer, it was very helpful.

pfeifhns gravatar imagepfeifhns ( 2 years ago )

You can click the check mark next to an answer to mark it as the accepted answer.

Ideally, if you have comments on an answer, post them as comments rather than as a new answer.

slelievre gravatar imageslelievre ( 2 years ago )

2 Answers

Sort by » oldest newest most voted
2

answered 2 years ago

slelievre gravatar image

updated 2 years ago

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.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: b = asin(5/24*cos(pi.n()/4))
    sage: b
    0.147852003702638
Preview: (hide)
link
0

answered 2 years ago

Emmanuel Charpentier gravatar image

updated 2 years ago

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 [π2 π2].
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2 years ago

Seen: 322 times

Last updated: Nov 26 '22