ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 08 Jul 2019 12:57:37 -0500absolute value for the ln functionhttp://ask.sagemath.org/question/47095/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`.Mon, 08 Jul 2019 02:43:12 -0500http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/Comment by Emmanuel Charpentier for <p>I tried to execute this but could not figure out the absolute value sign correctly</p>
<pre><code>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
</code></pre>
<p>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 <code>for</code>. Example <code>for c=0.999, 0.901, -0.999</code>, then yield the value of <code>N</code>.</p>
http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/?comment=47101#post-id-47101Well...
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)Mon, 08 Jul 2019 10:19:02 -0500http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/?comment=47101#post-id-47101Answer by tmonteil for <p>I tried to execute this but could not figure out the absolute value sign correctly</p>
<pre><code>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
</code></pre>
<p>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 <code>for</code>. Example <code>for c=0.999, 0.901, -0.999</code>, then yield the value of <code>N</code>.</p>
http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/?answer=47098#post-id-47098For 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.Mon, 08 Jul 2019 04:37:14 -0500http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/?answer=47098#post-id-47098Comment by slelievre for <p>For the absolute value, you should not use <code>|</code>, but the <code>abs()</code> function. By the way:</p>
<ul>
<li>you should only use parentheses, not brackets that have a different meaning in Python</li>
<li><code>Pi</code> is not defined in Sage. Do not use <code>pi</code> which is an (exact) symbolic constant, instead, use <code>RR.pi()</code> that is of the same kind as <code>c</code>, a floating-point number (or <code>pi.n()</code> to tell that you want a numerical approximation of <code>pi</code>). Alternatively, define <code>Pi = RR.pi()</code> before your computation.</li>
</ul>
http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/?comment=47102#post-id-47102@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.Mon, 08 Jul 2019 12:57:37 -0500http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/?comment=47102#post-id-47102Comment by Sha for <p>For the absolute value, you should not use <code>|</code>, but the <code>abs()</code> function. By the way:</p>
<ul>
<li>you should only use parentheses, not brackets that have a different meaning in Python</li>
<li><code>Pi</code> is not defined in Sage. Do not use <code>pi</code> which is an (exact) symbolic constant, instead, use <code>RR.pi()</code> that is of the same kind as <code>c</code>, a floating-point number (or <code>pi.n()</code> to tell that you want a numerical approximation of <code>pi</code>). Alternatively, define <code>Pi = RR.pi()</code> before your computation.</li>
</ul>
http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/?comment=47100#post-id-47100Thank you for the feedback. I have corrected it and now it works fine. Thanks!Mon, 08 Jul 2019 10:01:07 -0500http://ask.sagemath.org/question/47095/absolute-value-for-the-ln-function/?comment=47100#post-id-47100