Opened 9 years ago

Closed 8 years ago

#6465 closed defect (fixed)

Derivative D acts wrongly on symbolic integration

Reported by: gmhossain Owned by:
Priority: critical Milestone: sage-4.3.3
Component: symbolics Keywords:
Cc: Merged in: sage-4.3.3.alpha1
Authors: Burcin Erocal, Golam Mortuza Hossain Reviewers: Tim Dumol, Karl-Dieter Crisman, Ross Kyprianou, Minh Van Nguyen
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by gmhossain)

In new symbolics, derivative operator does not know how to act on symbolic integration.

sage: f(x) = function('f',x)
sage: g = integrate(f(x),x)
sage: g.diff(x)
D[0](integrate)(f(x), x)*D[0](f)(x) + D[1](integrate)(f(x), x)

Patches:

  • Both patches should be applied in order (spkg is already included in sage-4.1.1).

Apart from solving this bug it introduces couple of new features (by moving it into new symbolics' SFunction sub-class)

(1) Stricter syntax:

http://groups.google.com/group/sage-devel/browse_thread/thread/3e98841311653d7a

(2) Numerical approximation using .n() method

(3) Updated "integrate?" docstring

(4) Graceful handling of situations where integration is specified w.r.t. an expression

http://groups.google.com/group/sage-devel/browse_thread/thread/cd9f91338635ada9

(4) Behind the scene it provides a framework to hook up easily new integration algorithm written within sage.

Attachments (9)

trac_6465-chain_rule.patch (7.1 KB) - added by burcin 9 years ago.
support disabling chain rule for symbolic functions
trac_6465-moves-integration-into-sfunction-subclass.patch (23.0 KB) - added by gmhossain 9 years ago.
Should be applied after the chain-rule patch
trac_6465-chain_rule.take2.patch (30.0 KB) - added by burcin 9 years ago.
rebased to 4.3.rc0
trac_6465-moves-integration-into-sfunction-subclass.take2.patch (17.5 KB) - added by burcin 9 years ago.
rebased to 4.3.1.rc0
trac_6465-integral.patch (50.2 KB) - added by burcin 9 years ago.
referee patch
trac_6465-integral.take2.patch (50.0 KB) - added by burcin 8 years ago.
new version
trac_6465-integral.take3.patch (52.9 KB) - added by burcin 8 years ago.
fix numerical problems in doctests
trac_6465-integral.take4.patch (53.2 KB) - added by burcin 8 years ago.
rebased to 4.3.2
trac_6465-moves-integration-into-sfunction-subclass.take3.patch (17.2 KB) - added by burcin 8 years ago.
rebased to 4.3.2

Download all attachments as: .zip

Change History (31)

Changed 9 years ago by burcin

support disabling chain rule for symbolic functions

comment:1 Changed 9 years ago by burcin

attachment:trac_6465-chain_rule.patch adds support for disabling chain rule for symbolic functions. It depends on the new pynac package here:

http://sage.math.washington.edu/home/burcin/pynac/pynac-0.1.8.p2.spkg

comment:2 Changed 9 years ago by gmhossain

  • Authors set to Burcin Erocal, Golam Mortuza Hossain
  • Description modified (diff)
  • Summary changed from Derivative D acts wrongly on symbolic integration to [with patch, needs review] Derivative D acts wrongly on symbolic integration

Changed 9 years ago by gmhossain

Should be applied after the chain-rule patch

comment:3 Changed 9 years ago by kcrisman

There need to be deprecation warnings for things like

sage: integral(sin(x), pi, 2*pi)
sage: integral(sin(x)^3

comment:4 Changed 9 years ago by timdumol

  • Reviewers set to Tim Dumol
  • Summary changed from [with patch, needs review] Derivative D acts wrongly on symbolic integration to [with patch, needs work] Derivative D acts wrongly on symbolic integration

The sudden API change probably merits a deprecation warning, as kcrisman said. Also:

Doctest failure:

sage -t -long devel/sage/sage/libs/ginac/decl.pxi         
         [0.1 s]                                          
sage -t -long devel/sage/sage/misc/functional.py          
**********************************************************************
File "/opt/sage-bin/devel/sage-deriv/sage/misc/functional.py", line 412:
    sage: integral(exp(-x), (x, 1, oo))                                 
Expected:                                                               
    e^(-1)                                                              
Got:                                                                    
    gamma_incomplete(1, 1)                                              
**********************************************************************  
1 items had failures:                                                   
   1 of  15 in __main__.example_25                                      
***Test Failed*** 1 failures.                                           
For whitespace errors, see the file /opt/sage-bin/tmp/.doctest_functional.py
         [9.3 s]

comment:5 Changed 9 years ago by kcrisman

That may be due to the Maxima upgrade - has it been patched elsewhere? Just FYI, I'm not certain on this.

comment:6 Changed 9 years ago by timdumol

  • Report Upstream set to N/A

This patch needs to be rebased on #6816. The doctest failure persists, but gamma_incomplete(1, 1) is equivalent to e(-1) anyways.

comment:7 follow-up: Changed 9 years ago by burcin

  • Milestone set to sage-4.3.1
  • Summary changed from [with patch, needs work] Derivative D acts wrongly on symbolic integration to Derivative D acts wrongly on symbolic integration

Both patches need major rebase after #7490. I'll take a look at this when I find some time.

The problem with gamma_incomplete might be related to/fixed by #7748.

comment:8 in reply to: ↑ 7 Changed 9 years ago by kcrisman

The problem with gamma_incomplete might be related to/fixed by #7748.

Yes, I think so, as Maxima 5.20.1 now returns this for both integrate(exp(-x),x,1,inf) and integrate(1/%ex,x,1,inf). Note that

sage: gamma_inc(1,1)
0.367...

rather than 1/e at this point, so it really is the symbolic piece, not just having translation from Maxima, that would be important.

Changed 9 years ago by burcin

rebased to 4.3.rc0

Changed 9 years ago by burcin

rebased to 4.3.1.rc0

Changed 9 years ago by burcin

referee patch

comment:9 Changed 9 years ago by burcin

I uploaded new versions of the two old patches, rebased to 4.3.1.rc0, and a referee patch. I consider this ready now, though someone needs to review my changes.

Unfortunately attachment:trac_6465-chain_rule.take2.patch depends on the next version of pynac. I will release that real soon now. :)

The patches should be applied in this order:

They probably depend on other tickets. ATM, my queue contains: #7822, #6961, #7876, #7363, #7955, #7957, #7916 related to symbolics.

comment:10 Changed 9 years ago by burcin

  • Status changed from needs_work to needs_review

comment:11 Changed 9 years ago by jason

There is a reject on sage/symbolic/random_tests.py with the last patch.

comment:12 Changed 9 years ago by jason

See #6559 for the correct order of patches to avoid the reject.

comment:13 Changed 9 years ago by kcrisman

I've applied every one of Burcin's patches I could find, and get only one type of doctest failure with all of them (when applied in the right order). So so far so good! Unfortunately, I can't review any of them for two reasons - my understanding of C++/Pynac is not reliable enough to do a good job, and there are so many failures until one applies all the patches that it's hard to separate out what's what.

The reason I say that here is that I do get a significant failure, in a few different files, for the _tderivative_ method, though the actual failure occurs as a RuntimeError? in line 216 of sage/misc/derivative.pyx (with no error message, more's the pity). For instance, in line 99 of sage/symbolic/integration/integral.py,

sage: f = function('f'); a,b = var('a,b')
sage: h = indefinite_integral(f(x), x)
sage: h.diff(x)
RuntimeError

I hope this helps track it down.

comment:14 follow-up: Changed 9 years ago by burcin

Can you download the package file again and install it?

I forgot to include a patch when I first put the release together. I fixed the spkg file once I realized the problem, assuming no one looked at it yet. You must have downloaded in that period.

Sorry for the inconvenience and many thanks for trying these patches out.

comment:15 in reply to: ↑ 14 Changed 8 years ago by kcrisman

  • Reviewers changed from Tim Dumol to Tim Dumol, Karl-Dieter Crisman
  • Status changed from needs_review to needs_work

Replying to burcin:

Can you download the package file again and install it?

I forgot to include a patch when I first put the release together. I fixed the spkg file once I realized the problem, assuming no one looked at it yet. You must have downloaded in that period.

I now get

sage: h.diff(x)
f(x)

However, I now get some errors after applying all patches up to and including this set. Some should also be marked # optional - requires Internet (the mathematica_free ones). They all seem to be related to some extra keyword being passed to the DeprecatedSFunction constructor.

sage -t  "devel/sage/sage/symbolic/integration/integration.py"
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 29:
    sage: from sage.symbolic.integration.integration import _maxima_integrator
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_1[2]>", line 1, in <module>
        from sage.symbolic.integration.integration import _maxima_integrator###line 29:
    sage: from sage.symbolic.integration.integration import _maxima_integrator
      File "/Users/.../sage-4.3.1/local/lib/python/site-packages/sage/symbolic/integration/integration.py", line 316, in <module>
        integral = SymbolicIntegration()
      File "/Users/.../sage-4.3.1/local/lib/python/site-packages/sage/symbolic/integration/integration.py", line 152, in __init__
        SFunction.__init__(self, "integrate", *args, **kwds)
      File "function.pyx", line 1059, in sage.symbolic.function.DeprecatedSFunction.__init__ (sage/symbolic/function.cpp:8588)
    TypeError: __init__() got an unexpected keyword argument 'built_in_function'
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 30:
    sage: _maxima_integrator(sin(x), x)
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_1[3]>", line 1, in <module>
        _maxima_integrator(sin(x), x)###line 30:
    sage: _maxima_integrator(sin(x), x)
    NameError: name '_maxima_integrator' is not defined
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 33:
    sage: _maxima_integrator(f(x), x)
Expected:
    Traceback (most recent call last):
    ...
    NotImplementedError: Maxima failed to integrate
Got:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_1[5]>", line 1, in <module>
        _maxima_integrator(f(x), x)###line 33:
    sage: _maxima_integrator(f(x), x)
    NameError: name '_maxima_integrator' is not defined
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 293:
    sage: from sage.symbolic.integration.integration import integral
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_10[2]>", line 1, in <module>
        from sage.symbolic.integration.integration import integral###line 293:
    sage: from sage.symbolic.integration.integration import integral
      File "/Users/.../sage-4.3.1/local/lib/python/site-packages/sage/symbolic/integration/integration.py", line 316, in <module>
        integral = SymbolicIntegration()
      File "/Users/.../sage-4.3.1/local/lib/python/site-packages/sage/symbolic/integration/integration.py", line 152, in __init__
        SFunction.__init__(self, "integrate", *args, **kwds)
      File "function.pyx", line 1059, in sage.symbolic.function.DeprecatedSFunction.__init__ (sage/symbolic/function.cpp:8588)
    TypeError: __init__() got an unexpected keyword argument 'built_in_function'
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 294:
    sage: _ilatex = integral._print_latex_
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_10[3]>", line 1, in <module>
        _ilatex = integral._print_latex_###line 294:
    sage: _ilatex = integral._print_latex_
    AttributeError: 'function' object has no attribute '_print_latex_'
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 298:
    sage: _ilatex(f(x),x)
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_10[6]>", line 1, in <module>
        _ilatex(f(x),x)###line 298:
    sage: _ilatex(f(x),x)
    NameError: name '_ilatex' is not defined
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 300:
    sage: _ilatex(f(x),x,a,b)
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_10[7]>", line 1, in <module>
        _ilatex(f(x),x,a,b)###line 300:
    sage: _ilatex(f(x),x,a,b)
    NameError: name '_ilatex' is not defined
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 51:
    sage: from sage.symbolic.integration.integration import _sympy_integrator
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_2[2]>", line 1, in <module>
        from sage.symbolic.integration.integration import _sympy_integrator###line 51:
    sage: from sage.symbolic.integration.integration import _sympy_integrator
      File "/Users/.../sage-4.3.1/local/lib/python/site-packages/sage/symbolic/integration/integration.py", line 316, in <module>
        integral = SymbolicIntegration()
      File "/Users/.../sage-4.3.1/local/lib/python/site-packages/sage/symbolic/integration/integration.py", line 152, in __init__
        SFunction.__init__(self, "integrate", *args, **kwds)
      File "function.pyx", line 1059, in sage.symbolic.function.DeprecatedSFunction.__init__ (sage/symbolic/function.cpp:8588)
    TypeError: __init__() got an unexpected keyword argument 'built_in_function'
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 52:
    sage: _sympy_integrator(sin(x), x)
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_2[3]>", line 1, in <module>
        _sympy_integrator(sin(x), x)###line 52:
    sage: _sympy_integrator(sin(x), x)
    NameError: name '_sympy_integrator' is not defined
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 55:
    sage: _sympy_integrator(f(x), x)
Expected:
    Traceback (most recent call last):
    ...
    NotImplementedError: Sympy failed to integrate
Got:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_2[5]>", line 1, in <module>
        _sympy_integrator(f(x), x)###line 55:
    sage: _sympy_integrator(f(x), x)
    NameError: name '_sympy_integrator' is not defined
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 76:
    sage: from sage.symbolic.integration.integration import _mathematica_free_integrator
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_3[2]>", line 1, in <module>
        from sage.symbolic.integration.integration import _mathematica_free_integrator###line 76:
    sage: from sage.symbolic.integration.integration import _mathematica_free_integrator
      File "/Users/.../sage-4.3.1/local/lib/python/site-packages/sage/symbolic/integration/integration.py", line 316, in <module>
        integral = SymbolicIntegration()
      File "/Users/.../sage-4.3.1/local/lib/python/site-packages/sage/symbolic/integration/integration.py", line 152, in __init__
        SFunction.__init__(self, "integrate", *args, **kwds)
      File "function.pyx", line 1059, in sage.symbolic.function.DeprecatedSFunction.__init__ (sage/symbolic/function.cpp:8588)
    TypeError: __init__() got an unexpected keyword argument 'built_in_function'
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 77:
    sage: _mathematica_free_integrator(sin(x), x)
Exception raised:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_3[3]>", line 1, in <module>
        _mathematica_free_integrator(sin(x), x)###line 77:
    sage: _mathematica_free_integrator(sin(x), x)
    NameError: name '_mathematica_free_integrator' is not defined
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 80:
    sage: _mathematica_free_integrator(f(x), x)
Expected:
    Traceback (most recent call last):
    ...
    NotImplementedError: mathematica_free failed to integrate
Got:
    Traceback (most recent call last):
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/.../sage-4.3.1/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_3[5]>", line 1, in <module>
        _mathematica_free_integrator(f(x), x)###line 80:
    sage: _mathematica_free_integrator(f(x), x)
    NameError: name '_mathematica_free_integrator' is not defined
**********************************************************************
File "/Users/.../sage-4.3.1/devel/sage/sage/symbolic/integration/integration.py", line 241:
    sage: h.n()
Expected:
    0.472399177268953
Got:
    0.47239917726895253
**********************************************************************
5 items had failures:
   3 of   6 in __main__.example_1
   4 of   9 in __main__.example_10
   3 of   6 in __main__.example_2
   3 of   6 in __main__.example_3
   1 of   4 in __main__.example_8
***Test Failed*** 14 failures.
	 [6.5 s]

Sorry for the inconvenience and many thanks for trying these patches out.

No problem. Although I strongly disagree with the removal of indefinite integration longterm without explicit variable, overall this set of changes will be a big improvement. I am sorry again I cannot review much of the C++ related stuff, or the Pynac changes, though I am glad they are now up on [|pynac.sagemath.org] !

Changed 8 years ago by burcin

new version

comment:16 Changed 8 years ago by burcin

  • Status changed from needs_work to needs_review

attachment:trac_6465-integral.patch renames the file sage/symbolic/integration/integration.py to sage/symbolic/integration/integral.py. Are you sure you applied the patches correctly? Since these are git style diffs using hg import or hg qimport is recommended.

I applied the whole batch of symbolics patches associated to pynac-0.11 to 4.3.2.alpha0, and tested the sage/{symbolic,calculus,functions} directories. The only doctest failure I got was in sage/symbolic/integration/external.py. attachment:trac_6465-integral.take2.patch removes this dubious test.

The patches that need to be applied from this ticket are now:

Changed 8 years ago by burcin

fix numerical problems in doctests

comment:17 Changed 8 years ago by burcin

After testing on a 32-bit Debian box, I uploaded attachment:trac_6465-integral.take3.patch to replace attachment:trac_6465-integral.take2.patch. The only difference is the ... used for the trailing digits of the numerical integral on line 188 of sage/symbolic/integration/integral.py.

The patches that need to be applied are:

comment:18 Changed 8 years ago by burcin

Oops, the last patch to be applied is attachment:trac_6465-integral.take3.patch! That was a typo in the list above.

Changed 8 years ago by burcin

rebased to 4.3.2

Changed 8 years ago by burcin

rebased to 4.3.2

comment:20 Changed 8 years ago by rossk

  • Reviewers changed from Tim Dumol, Karl-Dieter Crisman to Tim Dumol, Karl-Dieter Crisman, Ross Kyprianou

The patch solves the stated problem without loss of functionality (at least in the tests below). +1 for positive review.

sage: f(x) = function('f',x)
sage: g = integrate(f(x),x)
sage: g.diff(x)
f(x)
sage: integrate(f(x),x).diff(x)
f(x)

sage: h(x,y) = function('h',x,y)
sage: kx = integrate(h(x,y),x)
sage: kx
integrate(h(x, y), x)
sage: kx.diff(x)
h(x, y)

sage: kxy = integrate( integrate(h(x,y),x), y)
sage: kxy
integrate(integrate(h(x, y), x), y)
sage: kxy.diff(y).diff(x)
h(x, y)
sage: kxy.diff(x).diff(y)
h(x, y)
sage: kxy.diff(x)
integrate(h(x, y), y)

sage: integrate(1/(2*x+1)^2, x, 0, 1)
1/3

sage: loads(dumps(integrate(1/(2*x+1)^2, x, 0, 1))) == 1/3
True

sage: integrate(1/(2*x+1)^2, x, 0.0, 1.0)
0.333333333333

sage: integrate(1/(2*x+1)^2, x, 0, 1.0)
0.333333333333

sage: integrate(1/(2*x+1)^2, x, CC(0), 1.0)
0.333333333333

sage: integrate(x/(1+x^2),x)
1/2*log(x^2 + 1)

sage: integrate(tan(x),x)
log(sec(x))

There is one issue (that is not necessarily a part of this ticket). I may be wrong but I'm reasonably sure that in general that integrate( integrate(h(x,y),x), y).diff(y).diff(x) <> integrate( integrate(h(x,y),x), y).diff(x).diff(y) But the following seems to imply it is (both are equal to h(x, y) )

sage: kxy = integrate( integrate(h(x,y),x), y)
sage: kxy
integrate(integrate(h(x, y), x), y)
sage: kxy.diff(y).diff(x)
h(x, y)
sage: kxy.diff(x).diff(y)
h(x, y)

comment:21 Changed 8 years ago by mvngu

  • Reviewers changed from Tim Dumol, Karl-Dieter Crisman, Ross Kyprianou to Tim Dumol, Karl-Dieter Crisman, Ross Kyprianou, Minh Van Nguyen
  • Status changed from needs_review to positive_review

The rebase looks good. See #6961 for the order in which to apply patches.

comment:22 Changed 8 years ago by mvngu

  • Merged in set to sage-4.3.3.alpha1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.