Ask Your Question
0

absolute value for the ln function

asked 5 years ago

Sha gravatar image

updated 5 years ago

I tried to execute this but could not figure out the absolute value sign correctly

c = var('c')

c=-0.999

N=(sqrt(1-c^2)/Pi)*[2.239539+(c/sqrt(1-c^2))*ln|(0.9*sqrt(1-c^2)-c*0.435889)/(0.9*sqrt(1-c^2)+c*0.435889)|+(1.8*sqrt(0.19)/(0.81-c^2)];N

I need help on the correct symbol for the absolute value for the ln function. Also, how am I to vary the value of c. I know is should use the command for. Example for c=0.999, 0.901, -0.999, then yield the value of N.

Preview: (hide)

Comments

1

Well...

sage: r.library('fortunes')
sage: r.fortune("'TFM'")

This is all documented in TFM. Those who WTFM don't want to have to WTFM again
on the mailing list. RTFM.
   -- Barry Rowlingson
      R-help (October 2003)
Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 5 years ago

tmonteil gravatar image

updated 5 years ago

For the absolute value, you should not use |, but the abs() function. By the way:

  • you should only use parentheses, not brackets that have a different meaning in Python
  • Pi is not defined in Sage. Do not use pi which is an (exact) symbolic constant, instead, use RR.pi() that is of the same kind as c, a floating-point number (or pi.n() to tell that you want a numerical approximation of pi). Alternatively, define Pi = RR.pi() before your computation.
Preview: (hide)
link

Comments

Thank you for the feedback. I have corrected it and now it works fine. Thanks!

Sha gravatar imageSha ( 5 years ago )

@Sha -- since this answers your question, please accept the answer (by clicking on the button with a tick mark); this will mark the question as answered in the main list of question on the Ask Sage homepage.

slelievre gravatar imageslelievre ( 5 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 1,132 times

Last updated: Jul 08 '19