Ask Your Question
0

absolute value for the ln function

asked 2019-07-08 09:43:12 +0100

Sha gravatar image

updated 2019-07-08 09:58:04 +0100

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.

edit retag flag offensive close merge delete

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 ( 2019-07-08 17:19:02 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-07-08 11:37:14 +0100

tmonteil gravatar image

updated 2019-07-08 11:39:59 +0100

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.
edit flag offensive delete link more

Comments

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

Sha gravatar imageSha ( 2019-07-08 17:01:07 +0100 )edit

@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 ( 2019-07-08 19:57:37 +0100 )edit

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: 2019-07-08 09:43:12 +0100

Seen: 1,112 times

Last updated: Jul 08 '19