Ticket #6189: trac_6189-num-approx-integral.patch

File trac_6189-num-approx-integral.patch, 1.3 KB (added by Karl-Dieter Crisman, 13 years ago)

Based on 4.1.2.alpha2

  • sage/calculus/calculus.py

    # HG changeset patch
    # User Karl-Dieter Crisman <kcrisman@gmail.com>
    # Date 1254232002 14400
    # Node ID 7d6c4a5e23a638661101833a89fdb02f334e3251
    # Parent  3429495f2a434e75015ad53111da60404ac23b9f
    Verify that numerical approximation bug in integration in Trac 6189 is fixed.
    
    diff -r 3429495f2a43 -r 7d6c4a5e23a6 sage/calculus/calculus.py
    a b  
    562562        (-0.66951170887280698, 7.7686781108547113e-15)
    563563        sage: res.subs(y=.5).n()
    564564        -0.669511708873
     565
     566    Check if #6189 is fixed (which, by the way, also
     567    demonstrates it's not always good to expand)::
     568
     569        sage: n = N; n
     570        <function numerical_approx at ...>
     571        sage: F(x) = 1/sqrt(2*pi*1^2)*exp(-1/(2*1^2)*(x-0)^2)
     572        sage: G(x) = 1/sqrt(2*pi*n(1)^2)*exp(-1/(2*n(1)^2)*(x-n(0))^2)
     573        sage: integrate( (F(x)-F(x))^2, x, -infinity, infinity).n()
     574        0.000000000000000
     575        sage: integrate( ((F(x)-G(x))^2).expand(), x, -infinity, infinity).n()
     576        -6.26376265908397e-17
     577        sage: integrate( (F(x)-G(x))^2, x, -infinity, infinity).n()
     578        0
    565579    """           
    566580    if b is None and a is not None:
    567581        # two arguments, must be endpoints