3

I'm teaching a course in Multivariate Calculus and decided to convert my notes from Sage to Jupyter using SymPy. I have rewritten nearly all my notes as Jupyter Notebooks and am very impressed how I can use multiple cells like Mathematica and I can use MarkDown cells with LaTeX as well as all the great features of matplotlib, NumPy and SymPy.

I'm nearly done converting my sagelets to Python scripts on Colab and found a discrepancy.

This Sage code resolves as pi:

integral(integral(integral(1, z, x^2+y^2, 2-x^2-y^2),
                  y, -sqrt(1-x^2), sqrt(1-x^2)),
         x, -1, 1)

but this this SymPy code resolves as -pi/2:

Integral(1,
         (z, x**2+y**2, 2-x**2-y**2),
         (y, -sqrt(1-x**2), sqrt(1-x**2)),
         (x, -1, 1)
        ).doit()

See #3 in this Jupyter Notebook:

https://colab.research.google.com/drive/1OlT9nfPG8TzoR_WpDavx-SAa07HLg3hV?usp=sharing

Shouldn't these be equal? What am I missing? Any help would be greatly appreciated as I've done A LOT of work on this course using SymPy and would like to use it in class this summer session!

Please help,

A. Jorge Garcia

Applied Math & CS

Nassau Community College

http://shadowfaxrant.blogspot.com

PS: Here's the SageCell version,

https://sagecell.sagemath.org/?z=eJzFk8FuwjAMhu9IvIMFB9qRTk1A07TrtE07cNuuSBkEGlGS4qRA-_RLQ1uQuDCGtlMsx_ns_5fTn-AbsJg-3scPoxg-J89sDB8os1TAu7JiiTw13U6fhvCy5WnOrQCu5v4OMxT2CWRdFpwHlJQkJiwkhTtGIdm7Yxx2OybRu6B3U2jPYbccg0FBykHT4seUdrYK52SzX0xIo-KArZvQo_DbYnsXyz1_e5A5unqe_ZQNiykjLHJR5KIKHJkN2oBWqZCcxFXviJ4a8deNL7XqOvrBzHEIr9JpsYmANTcG9MLHuZIWZvmXcNJ8YiHRWNAzy5WFXSIUYKJBGshQZxqt1IqnYLUvNpuco2hYc2ncq5ljoF77jEa5lKo19j-HaL_i6pKPuLoLareHZWWs39NmPf2yOmO_Adu6eJ4=&lang=sage

  • 2
    This is probably a bug and you may want to file a report [here](https://github.com/sympy/sympy/issues?q=is%3Aissue+is%3Aopen). I get `pi` in Mathematica. Also, if you compute the innermost two integrals, call `simplify` and then integrate over `x` the result is also `pi`. – hilberts_drinking_problem Jun 26 '21 at 06:01
  • 1
    Numerically evaluating the integral also gives `pi`. Please report this as a bug. It seems that sympy can correctly evaluate the two inner integrals. The outer integral fails: `Integral(-4*(1 - x**2)**(S(3)/2)/3 + 2*sqrt(1 - x**2)*(2 - 2*x**2), (x, -1, 1))`. – Oscar Benjamin Jun 26 '21 at 11:03
  • 1
    I've opened an issue: https://github.com/sympy/sympy/issues/21665 – Oscar Benjamin Jun 26 '21 at 11:55
  • Thanx for the input, guys! Very interesting. So this behavior is inconsistent. What can be done to remedy this? Here's another triple integral that should give 4pi as the result but comes out to -2pi??? ```display(Integral(-4*(2 - x**2)**(3/2)/3 + 2*sqrt(2 - x**2)*(4 - 2*x**2),(x,-sqrt(2),sqrt(2))).doit().n())``` TIA, A. Jorge Garcia – Jorge Garcia Jun 27 '21 at 20:04

0 Answers0