integrals and algorithms

64 views
Skip to first unread message

Enrique Artal

unread,
Nov 12, 2017, 5:30:51 AM11/12/17
to sage-support
I was prepairing some exercises and I got some errors using differente algorithms for integral, using version 8.0. Integrating with mathematica_free, I got this error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_4.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aW50ZWdyYWwoeCx4LGFsZ29yaXRobT0nbWF0aGVtYXRpY2FfZnJlZScp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpfvk1XJ/___code___.py", line 2, in <module>
    exec compile(u"integral(x,x,algorithm='mathematica_free')" + '\n', '', 'single')
  File "", line 1, in <module>
    
  File "/usr/local/sage-8.0/local/lib/python2.7/site-packages/sage/misc/functional.py", line 721, in integral
    return x.integral(*args, **kwds)
  File "sage/symbolic/expression.pyx", line 12275, in sage.symbolic.expression.Expression.integral (/usr/local/sage-8.0/src/build/cythonized/sage/symbolic/expression.cpp:69945)
  File "/usr/local/sage-8.0/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 795, in integrate
    return integrator(expression, v, a, b)
  File "/usr/local/sage-8.0/local/lib/python2.7/site-packages/sage/symbolic/integration/external.py", line 97, in mma_free_integrator
    page = page[page.index('"inputForm"'):page.index('"outputForm"')]
ValueError: substring not found
  

If I try  integral(sin(x^2),x,algorithm='sympy') I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_20.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aD1pbnRlZ3JhbChzaW4oeF4yKSx4LGFsZ29yaXRobT0nc3ltcHknKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpK8eQi1/___code___.py", line 3, in <module>
    exec compile(u"h=integral(sin(x**_sage_const_2 ),x,algorithm='sympy')" + '\n', '', 'single')
  File "", line 1, in <module>
    
  File "/usr/local/sage-8.0/local/lib/python2.7/site-packages/sage/misc/functional.py", line 721, in integral
    return x.integral(*args, **kwds)
  File "sage/symbolic/expression.pyx", line 12275, in sage.symbolic.expression.Expression.integral (/usr/local/sage-8.0/src/build/cythonized/sage/symbolic/expression.cpp:69945)
  File "/usr/local/sage-8.0/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 795, in integrate
    return integrator(expression, v, a, b)
  File "/usr/local/sage-8.0/local/lib/python2.7/site-packages/sage/symbolic/integration/external.py", line 56, in sympy_integrator
    return result._sage_()
  File "/usr/local/sage-8.0/local/lib/python2.7/site-packages/sympy/core/mul.py", line 1572, in _sage_
    s *= x._sage_()
  File "/usr/local/sage-8.0/local/lib/python2.7/site-packages/sympy/core/function.py", line 707, in _sage_
    func = getattr(sage, fname)
AttributeError: 'module' object has no attribute 'fresnels'

It seems that fresnels is defined in sympy but not in sagemath, Is it possible to correct these errors? Thanks, Enrique.

Vincent Delecroix

unread,
Nov 12, 2017, 5:57:06 AM11/12/17
to sage-s...@googlegroups.com
You should give the command that leads you to the error.

Concerning sympy, note that you can use it directly within Sage

sage: import sympy
sage: x = sympy.Symbol('x')
sage: sympy.integrate(sympy.sin(x^2), x)
3*sqrt(2)*sqrt(pi)*fresnels(sqrt(2)*x/sqrt(pi))*gamma(3/4)/(8*gamma(7/4))

Enrique Artal

unread,
Nov 12, 2017, 9:35:33 AM11/12/17
to sage-support
Sorry. 
For the first one

integral(x,x,algorithm='mathematica_free')

You can replace the first x by any function; a previous problem was solved in #22641 but now I does not work. For the the second one the problem is with

integral(sin(x^2),x,algorithm='mathematica_free')

and I presume it is due to the non-existence of Fresnel integrals in sage. It works for other integrals, and it works also importing sympy as you did.

Enrique Artal

unread,
Nov 12, 2017, 9:35:53 AM11/12/17
to sage-support
Sorry. 
For the first one

integral(x,x,algorithm='mathematica_free')

You can replace the first x by any function; a previous problem was solved in #22641 but now I does not work. For the the second one the problem is with

integral(sin(x^2),x,algorithm='mathematica_free')

and I presume it is due to the non-existence of Fresnel integrals in sage. It works for other integrals, and it works also importing sympy as you did.

El domingo, 12 de noviembre de 2017, 11:57:06 (UTC+1), vdelecroix escribió:

Ralf Stephan

unread,
Nov 13, 2017, 9:06:13 AM11/13/17
to sage-support
On Sunday, November 12, 2017 at 11:30:51 AM UTC+1, Enrique Artal wrote:
It seems that fresnels is defined in sympy but not in sagemath, Is it possible to correct these errors? Thanks, Enrique.



Thanks for the report,

Enrique Artal

unread,
Nov 13, 2017, 4:12:36 PM11/13/17
to sage-support
Thanks to you for your work!

kcrisman

unread,
Nov 13, 2017, 9:31:49 PM11/13/17
to sage-support


On Monday, November 13, 2017 at 4:12:36 PM UTC-5, Enrique Artal wrote:
Thanks to you for your work!

Yes, indeed! 
Reply all
Reply to author
Forward
0 new messages