# 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/...

>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.....
File "sage/misc/persist.pyx", line 136, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2440)
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

edit retag close merge delete

1

Hey! 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!

( 2018-08-02 01:58:28 -0500 )edit

If you could try the fresnel_sin() command, tell me if it works. I’m still using Sagemath 7.5 :/

( 2018-08-02 02:05:16 -0500 )edit

I confirm that 8.3.rc3 has fresne_sin and fresnel_cos.

( 2018-08-02 12:56:26 -0500 )edit

Sort by » oldest newest most voted

Time 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's (a. k. a. Abramowitz & Stegun) definitions rather that the simpler ones quoted by (the start of the) Wikipedia article. 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 ?).

more

In 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'

more