# absolute value for the ln function

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 close merge delete

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)

( 2019-07-08 17:19:02 +0200 )edit

Sort by » oldest newest most voted

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.
more

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

( 2019-07-08 17:01:07 +0200 )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.

( 2019-07-08 19:57:37 +0200 )edit