ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 06 Aug 2018 00:36:21 +0200does sagemath support fresnels function?https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/ I am trying to run integration on file that contains problems using fresnels functions.
I am not even able to load the file, since sagemath complains that it does not know fresnels.
This function is there in sympy
http://docs.sympy.org/latest/modules/functions/special.html?highlight=fresnel#sympy.functions.special.error_functions.fresnels
>python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
>>> from sympy import *
>>> fresnels(x)
fresnels(x)
But in Sagemath
sage: var('x')
x
sage: fresnels(x)
NameError Traceback (most recent call last)
<ipython-input-10-08120c00ce46> in <module>()
----> 1 fresnels(x)
NameError: name 'fresnels' is not defined
It is no problem for this to fail, as I can capture the exception. But the problem is that I can't even load the file itself to begin with. The sage script I have starts by reading a plain text file, which contains a list of the problems. Like this
var('a b c d e m n x ')
lst=[[x^7*fresnels(b*x),x,6,],
[x^6*fresnels(b*x),x,6,],
[x^5*fresnels(b*x),x,5,],
[x^4*fresnels(b*x),x,5,]]
The sage script does this
load(currentTestFile)
Where the `currentTestFile` is as shown above.
And once loaded, it iterates over each integral in the list and run it. But it seems sage parses the file during loading:
>./build_giac.sage
Test starting.....
load(currentTestName) #read the problems. This also contains the var('') statement.
File "sage/misc/persist.pyx", line 136, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2440)
File "/usr/lib/python2.7/site-packages/sage/repl/load.py", line 263, in load
exec(preparse_file(f.read()) + "\n", globals)
File "<string>", line 3, in <module>
NameError: name 'fresnels' is not defined
So I am not able to even load the file. If I can even load the file, then if the integral fails afterwords, it is OK, since I can trap the exception, mark it as failed, and go to the next integral.
First question is: Does Sagemath have no support for fresnels?
And in this case, how could one bypass this error during reading of the input file to give me a change to run the integrals?
Using SageMath version 8.3.rc2, Release Date: 2018-07-22
Thank you
--Nasser
Thu, 02 Aug 2018 03:50:46 +0200https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/Comment by joaoff for <p>I am trying to run integration on file that contains problems using fresnels functions.
I am not even able to load the file, since sagemath complains that it does not know fresnels.</p>
<p>This function is there in sympy
<a href="http://docs.sympy.org/latest/modules/functions/special.html?highlight=fresnel#sympy.functions.special.error_functions.fresnels">http://docs.sympy.org/latest/modules/...</a></p>
<pre><code>>python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
>>> from sympy import *
>>> fresnels(x)
fresnels(x)
</code></pre>
<p>But in Sagemath</p>
<pre><code>sage: var('x')
x
sage: fresnels(x)
NameError Traceback (most recent call last)
<ipython-input-10-08120c00ce46> in <module>()
----> 1 fresnels(x)
NameError: name 'fresnels' is not defined
</code></pre>
<p>It is no problem for this to fail, as I can capture the exception. But the problem is that I can't even load the file itself to begin with. The sage script I have starts by reading a plain text file, which contains a list of the problems. Like this</p>
<pre><code> var('a b c d e m n x ')
lst=[[x^7*fresnels(b*x),x,6,],
[x^6*fresnels(b*x),x,6,],
[x^5*fresnels(b*x),x,5,],
[x^4*fresnels(b*x),x,5,]]
</code></pre>
<p>The sage script does this</p>
<pre><code> load(currentTestFile)
</code></pre>
<p>Where the <code>currentTestFile</code> is as shown above.</p>
<p>And once loaded, it iterates over each integral in the list and run it. But it seems sage parses the file during loading:</p>
<pre><code>>./build_giac.sage
Test starting.....
load(currentTestName) #read the problems. This also contains the var('') statement.
File "sage/misc/persist.pyx", line 136, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2440)
File "/usr/lib/python2.7/site-packages/sage/repl/load.py", line 263, in load
exec(preparse_file(f.read()) + "\n", globals)
File "<string>", line 3, in <module>
NameError: name 'fresnels' is not defined
</code></pre>
<p>So I am not able to even load the file. If I can even load the file, then if the integral fails afterwords, it is OK, since I can trap the exception, mark it as failed, and go to the next integral.</p>
<p>First question is: Does Sagemath have no support for fresnels?
And in this case, how could one bypass this error during reading of the input file to give me a change to run the integrals?</p>
<p>Using SageMath version 8.3.rc2, Release Date: 2018-07-22 </p>
<p>Thank you</p>
<p>--Nasser</p>
https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?comment=43238#post-id-43238Hey! It seems that the support to Fresnel integrals starts with Sagemath 8.3 beta4.
https://trac.sagemath.org/ticket/24212
I didn’t read all the ticket, but if it is correct, it is very nice!Thu, 02 Aug 2018 08:58:28 +0200https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?comment=43238#post-id-43238Comment by joaoff for <p>I am trying to run integration on file that contains problems using fresnels functions.
I am not even able to load the file, since sagemath complains that it does not know fresnels.</p>
<p>This function is there in sympy
<a href="http://docs.sympy.org/latest/modules/functions/special.html?highlight=fresnel#sympy.functions.special.error_functions.fresnels">http://docs.sympy.org/latest/modules/...</a></p>
<pre><code>>python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
>>> from sympy import *
>>> fresnels(x)
fresnels(x)
</code></pre>
<p>But in Sagemath</p>
<pre><code>sage: var('x')
x
sage: fresnels(x)
NameError Traceback (most recent call last)
<ipython-input-10-08120c00ce46> in <module>()
----> 1 fresnels(x)
NameError: name 'fresnels' is not defined
</code></pre>
<p>It is no problem for this to fail, as I can capture the exception. But the problem is that I can't even load the file itself to begin with. The sage script I have starts by reading a plain text file, which contains a list of the problems. Like this</p>
<pre><code> var('a b c d e m n x ')
lst=[[x^7*fresnels(b*x),x,6,],
[x^6*fresnels(b*x),x,6,],
[x^5*fresnels(b*x),x,5,],
[x^4*fresnels(b*x),x,5,]]
</code></pre>
<p>The sage script does this</p>
<pre><code> load(currentTestFile)
</code></pre>
<p>Where the <code>currentTestFile</code> is as shown above.</p>
<p>And once loaded, it iterates over each integral in the list and run it. But it seems sage parses the file during loading:</p>
<pre><code>>./build_giac.sage
Test starting.....
load(currentTestName) #read the problems. This also contains the var('') statement.
File "sage/misc/persist.pyx", line 136, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2440)
File "/usr/lib/python2.7/site-packages/sage/repl/load.py", line 263, in load
exec(preparse_file(f.read()) + "\n", globals)
File "<string>", line 3, in <module>
NameError: name 'fresnels' is not defined
</code></pre>
<p>So I am not able to even load the file. If I can even load the file, then if the integral fails afterwords, it is OK, since I can trap the exception, mark it as failed, and go to the next integral.</p>
<p>First question is: Does Sagemath have no support for fresnels?
And in this case, how could one bypass this error during reading of the input file to give me a change to run the integrals?</p>
<p>Using SageMath version 8.3.rc2, Release Date: 2018-07-22 </p>
<p>Thank you</p>
<p>--Nasser</p>
https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?comment=43239#post-id-43239If you could try the fresnel_sin() command, tell me if it works. I’m still using Sagemath 7.5 :/Thu, 02 Aug 2018 09:05:16 +0200https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?comment=43239#post-id-43239Comment by Emmanuel Charpentier for <p>I am trying to run integration on file that contains problems using fresnels functions.
I am not even able to load the file, since sagemath complains that it does not know fresnels.</p>
<p>This function is there in sympy
<a href="http://docs.sympy.org/latest/modules/functions/special.html?highlight=fresnel#sympy.functions.special.error_functions.fresnels">http://docs.sympy.org/latest/modules/...</a></p>
<pre><code>>python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
>>> from sympy import *
>>> fresnels(x)
fresnels(x)
</code></pre>
<p>But in Sagemath</p>
<pre><code>sage: var('x')
x
sage: fresnels(x)
NameError Traceback (most recent call last)
<ipython-input-10-08120c00ce46> in <module>()
----> 1 fresnels(x)
NameError: name 'fresnels' is not defined
</code></pre>
<p>It is no problem for this to fail, as I can capture the exception. But the problem is that I can't even load the file itself to begin with. The sage script I have starts by reading a plain text file, which contains a list of the problems. Like this</p>
<pre><code> var('a b c d e m n x ')
lst=[[x^7*fresnels(b*x),x,6,],
[x^6*fresnels(b*x),x,6,],
[x^5*fresnels(b*x),x,5,],
[x^4*fresnels(b*x),x,5,]]
</code></pre>
<p>The sage script does this</p>
<pre><code> load(currentTestFile)
</code></pre>
<p>Where the <code>currentTestFile</code> is as shown above.</p>
<p>And once loaded, it iterates over each integral in the list and run it. But it seems sage parses the file during loading:</p>
<pre><code>>./build_giac.sage
Test starting.....
load(currentTestName) #read the problems. This also contains the var('') statement.
File "sage/misc/persist.pyx", line 136, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2440)
File "/usr/lib/python2.7/site-packages/sage/repl/load.py", line 263, in load
exec(preparse_file(f.read()) + "\n", globals)
File "<string>", line 3, in <module>
NameError: name 'fresnels' is not defined
</code></pre>
<p>So I am not able to even load the file. If I can even load the file, then if the integral fails afterwords, it is OK, since I can trap the exception, mark it as failed, and go to the next integral.</p>
<p>First question is: Does Sagemath have no support for fresnels?
And in this case, how could one bypass this error during reading of the input file to give me a change to run the integrals?</p>
<p>Using SageMath version 8.3.rc2, Release Date: 2018-07-22 </p>
<p>Thank you</p>
<p>--Nasser</p>
https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?comment=43243#post-id-43243I confirm that 8.3.rc3 has `fresne_sin` and `fresnel_cos`.Thu, 02 Aug 2018 19:56:26 +0200https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?comment=43243#post-id-43243Answer by Emmanuel Charpentier for <p>I am trying to run integration on file that contains problems using fresnels functions.
I am not even able to load the file, since sagemath complains that it does not know fresnels.</p>
<p>This function is there in sympy
<a href="http://docs.sympy.org/latest/modules/functions/special.html?highlight=fresnel#sympy.functions.special.error_functions.fresnels">http://docs.sympy.org/latest/modules/...</a></p>
<pre><code>>python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
>>> from sympy import *
>>> fresnels(x)
fresnels(x)
</code></pre>
<p>But in Sagemath</p>
<pre><code>sage: var('x')
x
sage: fresnels(x)
NameError Traceback (most recent call last)
<ipython-input-10-08120c00ce46> in <module>()
----> 1 fresnels(x)
NameError: name 'fresnels' is not defined
</code></pre>
<p>It is no problem for this to fail, as I can capture the exception. But the problem is that I can't even load the file itself to begin with. The sage script I have starts by reading a plain text file, which contains a list of the problems. Like this</p>
<pre><code> var('a b c d e m n x ')
lst=[[x^7*fresnels(b*x),x,6,],
[x^6*fresnels(b*x),x,6,],
[x^5*fresnels(b*x),x,5,],
[x^4*fresnels(b*x),x,5,]]
</code></pre>
<p>The sage script does this</p>
<pre><code> load(currentTestFile)
</code></pre>
<p>Where the <code>currentTestFile</code> is as shown above.</p>
<p>And once loaded, it iterates over each integral in the list and run it. But it seems sage parses the file during loading:</p>
<pre><code>>./build_giac.sage
Test starting.....
load(currentTestName) #read the problems. This also contains the var('') statement.
File "sage/misc/persist.pyx", line 136, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2440)
File "/usr/lib/python2.7/site-packages/sage/repl/load.py", line 263, in load
exec(preparse_file(f.read()) + "\n", globals)
File "<string>", line 3, in <module>
NameError: name 'fresnels' is not defined
</code></pre>
<p>So I am not able to even load the file. If I can even load the file, then if the integral fails afterwords, it is OK, since I can trap the exception, mark it as failed, and go to the next integral.</p>
<p>First question is: Does Sagemath have no support for fresnels?
And in this case, how could one bypass this error during reading of the input file to give me a change to run the integrals?</p>
<p>Using SageMath version 8.3.rc2, Release Date: 2018-07-22 </p>
<p>Thank you</p>
<p>--Nasser</p>
https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?answer=43257#post-id-43257Time to make it a "real" answer :
As of Sage 8.3 (released Aug, 3, 2018), Sage implements :
* `fresnel_sin` (i. e. $\displaystyle\int_0^x \sin\frac{\pi t^2}{2} dt$), and
* `fresnel_cos` (i. e. $\displaystyle\int_0^x \cos\frac{\pi t^2}{2} dt$).
Note that Sage follows [DLMF](https://dlmf.nist.gov/)'s (a. k. a. Abramowitz & Stegun) [definitions](https://dlmf.nist.gov/7.2#E6) rather that the simpler ones quoted by (the start of the) Wikipedia [article](https://en.wikipedia.org/wiki/Fresnel_integral). Note also that this does not implement Fresnel's $\cal{F}(z)=\displaystyle\int_z^\infty \textrm{e}^{\frac{1}{2}\pi i t^2} \textrm{d}t $ (left as an exercise to the reader ?).Sun, 05 Aug 2018 09:40:04 +0200https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?answer=43257#post-id-43257Answer by slelievre for <p>I am trying to run integration on file that contains problems using fresnels functions.
I am not even able to load the file, since sagemath complains that it does not know fresnels.</p>
<p>This function is there in sympy
<a href="http://docs.sympy.org/latest/modules/functions/special.html?highlight=fresnel#sympy.functions.special.error_functions.fresnels">http://docs.sympy.org/latest/modules/...</a></p>
<pre><code>>python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
>>> from sympy import *
>>> fresnels(x)
fresnels(x)
</code></pre>
<p>But in Sagemath</p>
<pre><code>sage: var('x')
x
sage: fresnels(x)
NameError Traceback (most recent call last)
<ipython-input-10-08120c00ce46> in <module>()
----> 1 fresnels(x)
NameError: name 'fresnels' is not defined
</code></pre>
<p>It is no problem for this to fail, as I can capture the exception. But the problem is that I can't even load the file itself to begin with. The sage script I have starts by reading a plain text file, which contains a list of the problems. Like this</p>
<pre><code> var('a b c d e m n x ')
lst=[[x^7*fresnels(b*x),x,6,],
[x^6*fresnels(b*x),x,6,],
[x^5*fresnels(b*x),x,5,],
[x^4*fresnels(b*x),x,5,]]
</code></pre>
<p>The sage script does this</p>
<pre><code> load(currentTestFile)
</code></pre>
<p>Where the <code>currentTestFile</code> is as shown above.</p>
<p>And once loaded, it iterates over each integral in the list and run it. But it seems sage parses the file during loading:</p>
<pre><code>>./build_giac.sage
Test starting.....
load(currentTestName) #read the problems. This also contains the var('') statement.
File "sage/misc/persist.pyx", line 136, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2440)
File "/usr/lib/python2.7/site-packages/sage/repl/load.py", line 263, in load
exec(preparse_file(f.read()) + "\n", globals)
File "<string>", line 3, in <module>
NameError: name 'fresnels' is not defined
</code></pre>
<p>So I am not able to even load the file. If I can even load the file, then if the integral fails afterwords, it is OK, since I can trap the exception, mark it as failed, and go to the next integral.</p>
<p>First question is: Does Sagemath have no support for fresnels?
And in this case, how could one bypass this error during reading of the input file to give me a change to run the integrals?</p>
<p>Using SageMath version 8.3.rc2, Release Date: 2018-07-22 </p>
<p>Thank you</p>
<p>--Nasser</p>
https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?answer=43260#post-id-43260In order to use SymPy's `fresnelc` and `fresnels` functions in Sage, one should import them.
This is done as follows.
sage: from sympy import fresnelc, fresnels
Then one can do for instance
sage: fresnels(x)
fresnels(x)
sage: integrate(fresnels(x), (x, 0, 1))
-1/pi + fresnel_sin(1)
The above is run using Sage 8.3.rc3.
sage: version()
'SageMath version 8.3.rc3, Release Date: 2018-07-28'
Mon, 06 Aug 2018 00:36:21 +0200https://ask.sagemath.org/question/43237/does-sagemath-support-fresnels-function/?answer=43260#post-id-43260