Ticket #10682: trac10682_1.patch

File trac10682_1.patch, 13.6 KB (added by dimpase, 10 years ago)

Sage library patch to go with the new spkg

  • sage/calculus/calculus.py

    # HG changeset patch
    # User Dmitrii Pasechnik <dimpase@gmail.com>
    # Date 1330565705 -46800
    # Node ID c68df2759a67a7b13af54e2ab432103ac6a1a404
    # Parent  122b7b1ed524dbf93f6006833d25e78aec2cf0aa
    Sage lib upgrade for Maxima 5.26; adding a test for the sum in #10682; adding calls to 'domain' in desolve()
    
    diff --git a/sage/calculus/calculus.py b/sage/calculus/calculus.py
    a b  
    632632      - ``5`` - integral is probably divergent or slowly
    633633        convergent
    634634
    635       - ``6`` - the input is invalid
     635      - ``6`` - the input is invalid; this includes the case of desired_relative_error
     636        being too small to be achieved
    636637
    637638    ALIAS: nintegrate is the same as nintegral
    638639
     
    641642    integration using the GSL C library. It is potentially much faster
    642643    and applies to arbitrary user defined functions.
    643644
    644     Also, there are limits to the precision to which Maxima can compute
    645     the integral to due to limitations in quadpack.
    646 
    647645    ::
    648646
    649647        sage: f = x
    650         sage: f = f.nintegral(x,0,1,1e-14)
    651         Traceback (most recent call last):
    652         ...
    653         ValueError: Maxima (via quadpack) cannot compute the integral
    654         to that precision
     648        sage: f.nintegral(x,0,1,1e-14)
     649        (0.0, 0.0, 0, 6)
    655650
    656651    EXAMPLES::
    657652
     
    717712                                    limit=maximum_num_subintervals)
    718713    except TypeError, err:
    719714        if "ERROR" in str(err):
    720             raise ValueError, "Maxima (via quadpack) cannot compute the integral to that precision"
     715            raise ValueError, "Maxima (via quadpack) cannot compute the integral"
    721716        else:
    722717            raise TypeError, err
    723718
    724719    #This is just a work around until there is a response to
    725720    #http://www.math.utexas.edu/pipermail/maxima/2008/012975.html
    726721    if 'quad_qags' in str(v):
    727         raise ValueError, "Maxima (via quadpack) cannot compute the integral to that precision"
     722        raise ValueError, "Maxima (via quadpack) cannot compute the integral"
    728723
    729724    return float(v[0]), float(v[1]), Integer(v[2]), Integer(v[3])
    730725
     
    12231218        sage: (z + exp(x)).laplace(x, s)
    12241219        z/s + 1/(s - 1)
    12251220        sage: log(t/t0).laplace(t, s)
    1226         -(euler_gamma + log(s) - log(1/t0))/s
     1221        -(euler_gamma + log(s) + log(t0))/s
    12271222
    12281223    We do a formal calculation::
    12291224
     
    14231418    EXAMPLES::
    14241419
    14251420        sage: a = lim(exp(x^2)*(1-erf(x)), x=infinity); a
    1426         limit(-e^(x^2)*erf(x) + e^(x^2), x, +Infinity)
     1421        -limit((erf(x) - 1)*e^(x^2), x, +Infinity)
    14271422        sage: a = sage.calculus.calculus.dummy_limit(sin(x)/x, x, 0);a
    14281423        limit(sin(x)/x, x, 0)
    14291424    """
  • sage/calculus/desolvers.py

    diff --git a/sage/calculus/desolvers.py b/sage/calculus/desolvers.py
    a b  
    110110      can be used only if the result is one SymbolicEquation (does not
    111111      contain singular solution, for example)
    112112
    113 
    114113    OUTPUT:
    115114   
    116115    In most cases returns SymbolicEquation which defines the solution
     
    355354    Trac #9961 fixed (allow assumptions on the dependent variable in desolve)::
    356355   
    357356        sage: y=function('y',x); assume(x>0); assume(y>0)
     357        sage: sage.calculus.calculus.maxima('domain:real')  # needed since Maxima 5.26.0 to get the answer as below
     358        real
    358359        sage: desolve(x*diff(y,x)-x*sqrt(y^2+x^2)-y == 0, y, contrib_ode=True)
    359360        [x - arcsinh(y(x)/x) == c]
    360    
     361
     362    Trac #10682 updated Maxima to 5.26, and it started to show a different solution in the complex domain for the ODE above::
     363
     364        sage: sage.calculus.calculus.maxima('domain:complex')  # back to the dafault, complex, domain
     365        complex
     366        sage: desolve(x*diff(y,x)-x*sqrt(y^2+x^2)-y == 0, y, contrib_ode=True)
     367        [1/2*(2*x^2*sqrt(x^(-2)) - 2*x*sqrt(x^(-2))*arcsinh(y(x)/sqrt(x^2))
     368        - 2*x*sqrt(x^(-2))*arcsinh(y(x)^2/(sqrt(y(x)^2)*x))
     369        + log(4*(2*x^2*sqrt((x^2*y(x)^2 + y(x)^4)/x^2)*sqrt(x^(-2)) + x^2 + 2*y(x)^2)/x^2))/(x*sqrt(x^(-2))) == c]
     370
    361371    Trac #6479 fixed::
    362372
    363373        sage: x = var('x')
  • sage/calculus/functional.py

    diff --git a/sage/calculus/functional.py b/sage/calculus/functional.py
    a b  
    328328    it unevaluated::
    329329   
    330330        sage: lim(exp(x^2)*(1-erf(x)), x=infinity)
    331         limit(-e^(x^2)*erf(x) + e^(x^2), x, +Infinity)
     331        -limit((erf(x) - 1)*e^(x^2), x, +Infinity)
    332332    """
    333333    if not isinstance(f, Expression):
    334334        f = SR(f)
  • sage/calculus/wester.py

    diff --git a/sage/calculus/wester.py b/sage/calculus/wester.py
    a b  
    383383::
    384384
    385385    sage: # (YES) Assuming Re(x)>0, Re(y)>0, deduce x^(1/n)*y^(1/n)-(x*y)^(1/n)=0.
    386     sage: assume(real(x) > 0, real(y) > 0)
    387     sage: n = var('n')
     386    sage: # Maxima 5.26 does not do "just" simpify() here. Thus simplify_exp() used.
     387    sage: # assume(real(x) > 0, real(y) > 0) # (not needed for simplify_exp())
     388    sage: n = var('n');
    388389    sage: f = x^(1/n)*y^(1/n)-(x*y)^(1/n)
    389     sage: f.simplify()
     390    sage: f.simplify_exp()
    390391    0
    391392    sage: forget()
    392393
  • sage/functions/special.py

    diff --git a/sage/functions/special.py b/sage/functions/special.py
    a b  
    13431343   
    13441344        sage: x,y = var('x,y')
    13451345        sage: spherical_harmonic(3,2,x,y)
    1346         1/8*sqrt(7)*sqrt(30)*e^(2*I*y)*sin(x)^2*cos(x)/sqrt(pi)
     1346        15/4*sqrt(7/30)*e^(2*I*y)*sin(x)^2*cos(x)/sqrt(pi)
    13471347        sage: spherical_harmonic(3,2,1,2)
    1348         1/8*sqrt(7)*sqrt(30)*e^(4*I)*sin(1)^2*cos(1)/sqrt(pi)
     1348        15/4*sqrt(7/30)*e^(4*I)*sin(1)^2*cos(1)/sqrt(pi)
    13491349    """
    13501350    _init()
    13511351    return meval("spherical_harmonic(%s,%s,%s,%s)"%(ZZ(m),ZZ(n),x,y))
     
    14611461    EXAMPLES::
    14621462
    14631463        sage: z = var("z")
     1464        sage: # this is still wrong: must be abs(sin(z)) + 2*round(z/pi)
    14641465        sage: elliptic_e(z, 1)
    1465         sin(z)
     1466        sin(z) + 2*round(z/pi)
    14661467        sage: elliptic_e(z, 0)
    14671468        z
    14681469        sage: elliptic_e(0.5, 0.1)
  • sage/interfaces/maxima.py

    diff --git a/sage/interfaces/maxima.py b/sage/interfaces/maxima.py
    a b  
    122122    sage: a = maxima('(1 + sqrt(2))^5'); a
    123123    (sqrt(2)+1)^5
    124124    sage: a.expand()
    125     3*2^(7/2)+5*sqrt(2)+41
     125    29*sqrt(2)+41
    126126
    127127::
    128128
  • sage/interfaces/maxima_abstract.py

    diff --git a/sage/interfaces/maxima_abstract.py b/sage/interfaces/maxima_abstract.py
    a b  
    420420        EXAMPLES::
    421421       
    422422            sage: maxima.version()
    423             '5.24.0'
     423            '5.26.0'
    424424        """
    425425        return maxima_version()
    426426
     
    23552355   
    23562356        sage: from sage.interfaces.maxima_abstract import maxima_version
    23572357        sage: maxima_version()
    2358         '5.24.0'
     2358        '5.26.0'
    23592359    """
    23602360    return os.popen('maxima --version').read().split()[-1]
    23612361
     
    23672367   
    23682368        sage: from sage.interfaces.maxima_abstract import maxima_console
    23692369        sage: maxima_console()                    # not tested
    2370         Maxima 5.24.0 http://maxima.sourceforge.net
     2370        Maxima 5.26.0 http://maxima.sourceforge.net
    23712371        ...
    23722372    """
    23732373    os.system('maxima')
  • sage/matrix/matrix2.pyx

    diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
    a b  
    1037510375
    1037610376            sage: a=matrix(RR,[[1,pi.n()],[1e2,1e-2]])
    1037710377            sage: a.exp()
    10378             [ 1/416296432702*((297*sqrt(382784569869489) + 208148216351)*e^(1/551700*sqrt(382784569869489)) - 297*sqrt(382784569869489) + 208148216351)*e^(-1/1103400*sqrt(382784569869489) + 101/200)                                5199650/1148353709608467*(sqrt(382784569869489)*e^(1/551700*sqrt(382784569869489)) - sqrt(382784569869489))*e^(-1/1103400*sqrt(382784569869489) + 101/200)]
    10379             [                                     30000/208148216351*(sqrt(382784569869489)*e^(1/551700*sqrt(382784569869489)) - sqrt(382784569869489))*e^(-1/1103400*sqrt(382784569869489) + 101/200) -1/416296432702*((297*sqrt(382784569869489) - 208148216351)*e^(1/551700*sqrt(382784569869489)) - 297*sqrt(382784569869489) - 208148216351)*e^(-1/1103400*sqrt(382784569869489) + 101/200)]
     10378            [ 1/11882424341266*((11*sqrt(227345670387496707609) + 5941212170633)*e^(3/1275529100*sqrt(227345670387496707609)) - 11*sqrt(227345670387496707609) + 5941212170633)*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)                            445243650/75781890129165569203*(sqrt(227345670387496707609)*e^(3/1275529100*sqrt(227345670387496707609)) - sqrt(227345670387496707609))*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)]
     10379            [                                     10000/53470909535697*(sqrt(227345670387496707609)*e^(3/1275529100*sqrt(227345670387496707609)) - sqrt(227345670387496707609))*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200) -1/11882424341266*((11*sqrt(227345670387496707609) - 5941212170633)*e^(3/1275529100*sqrt(227345670387496707609)) - 11*sqrt(227345670387496707609) - 5941212170633)*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)]
    1038010380            sage: a.change_ring(RDF).exp()
    1038110381            [42748127.3153 7368259.24416]
    1038210382            [234538976.138 40426191.4516]
  • sage/rings/number_field/number_field_element.pyx

    diff --git a/sage/rings/number_field/number_field_element.pyx b/sage/rings/number_field/number_field_element.pyx
    a b  
    20712071       
    20722072            sage: K.<a> = NumberField(x^6-x^3-1, embedding=1)
    20732073            sage: SR(a)
    2074             1/2*(sqrt(5) + 1)^(1/3)*2^(2/3)
     2074            (1/2*sqrt(5) + 1/2)^(1/3)
    20752075        """
    20762076        if self.__symbolic is None:
    20772077       
  • sage/symbolic/expression.pyx

    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    27142714            sage: g = derivative(f, x); g # this is a complex expression
    27152715            1/2*(x/(x^2 - 1) - (x^2 + 1)*x/(x^2 - 1)^2)/((x^2 + 1)/(x^2 - 1))^(3/4)
    27162716            sage: g.factor()
    2717             -x/((x^2 - 1)^(5/4)*(x^2 + 1)^(3/4))
    2718 
     2717            -x/((x - 1)^2*(x + 1)^2*((x^2 + 1)/(x^2 - 1))^(3/4))
     2718 
    27192719        ::
    2720 
     2720       
    27212721            sage: y = var('y')
    27222722            sage: f = y^(sin(x))
    27232723            sage: derivative(f, x)
     
    31903190            sage: sin(x/2).expand_trig(half_angles=False)
    31913191            sin(1/2*x)
    31923192            sage: sin(x/2).expand_trig(half_angles=True)
    3193             1/2*sqrt(-cos(x) + 1)*sqrt(2)*(-1)^floor(1/2*x/pi)
     3193            sqrt(-1/2*cos(x) + 1/2)*(-1)^floor(1/2*x/pi)
    31943194
    31953195        ALIASES:
    31963196
     
    78207820            (f6, f5, f4, x)
    78217821            sage: e=15*f6*x^2 + 5*f5*x + f4
    78227822            sage: res = e.roots(x); res
    7823             [(-1/30*(sqrt(-12*f4*f6 + 5*f5^2)*sqrt(5) + 5*f5)/f6, 1), (1/30*(sqrt(-12*f4*f6 + 5*f5^2)*sqrt(5) - 5*f5)/f6, 1)]
     7823            [(-1/30*(5*f5 + sqrt(-60*f4*f6 + 25*f5^2))/f6, 1), (-1/30*(5*f5 - sqrt(-60*f4*f6 + 25*f5^2))/f6, 1)]
    78247824            sage: e.subs(x=res[0][0]).is_zero()
    78257825            True
    78267826        """
     
    86918691            sage: (binomial(n,k)*x^k).sum(k, 0, n, algorithm = 'maple')      # optional  -- requires maple
    86928692            (x + 1)^n
    86938693
     8694        Check that the sum in #10682 is done right::
     8695
     8696            sage: sum(binomial(n,k)*k^2, k, 2, n)
     8697            1/4*(n^2 + n)*2^n - n
     8698 
    86948699        .. note::
    86958700
    86968701           #. Sage can currently only understand a subset of the output of Maxima, Maple and
  • sage/symbolic/integration/integral.py

    diff --git a/sage/symbolic/integration/integral.py b/sage/symbolic/integration/integral.py
    a b  
    489489        sage: res = integral(f,x,0.0001414, 1.); res
    490490        Traceback (most recent call last):
    491491        ...
    492         ValueError: Computation failed since Maxima requested additional
    493         constraints; using the 'assume' command before integral evaluation
    494         *may* help (example of legal syntax is 'assume((y-1)*(y+1)>0)',
    495         see `assume?` for more details)
    496         Is  (y-1)*(y+1)  positive, negative, or zero?
     492        ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before integral evaluation *may* help (example of legal syntax is 'assume(50015104*y^2-50015103>0)', see `assume?` for more details)
     493        Is  50015104*y^2-50015103  positive, negative, or zero?
    497494        sage: assume(y>1)
    498495        sage: res = integral(f,x,0.0001414, 1.); res
    499496        2*y*arctan(1/y) - 2*y*arctan(0.0001414/y) - 0.0001414*log(y^2 + 1.999396e-08) + log(y^2 + 1.0) - 1.9997172
  • sage/symbolic/relation.py

    diff --git a/sage/symbolic/relation.py b/sage/symbolic/relation.py
    a b  
    486486        sage: solve([x+y==6, x-y==4], x, y)
    487487        [[x == 5, y == 1]]
    488488        sage: solve([x^2+y^2 == 1, y^2 == x^3 + x + 1], x, y)
    489         [[x == -1/2*I*sqrt(3) - 1/2, y == -1/2*sqrt(-I*sqrt(3) + 3)*sqrt(2)],
    490          [x == -1/2*I*sqrt(3) - 1/2, y == 1/2*sqrt(-I*sqrt(3) + 3)*sqrt(2)],
    491          [x == 1/2*I*sqrt(3) - 1/2, y == -1/2*sqrt(I*sqrt(3) + 3)*sqrt(2)],
    492          [x == 1/2*I*sqrt(3) - 1/2, y == 1/2*sqrt(I*sqrt(3) + 3)*sqrt(2)],
    493          [x == 0, y == -1],
     489        [[x == -1/2*I*sqrt(3) - 1/2, y == -sqrt(-1/2*I*sqrt(3) + 3/2)],
     490         [x == -1/2*I*sqrt(3) - 1/2, y == sqrt(-1/2*I*sqrt(3) + 3/2)],
     491         [x == 1/2*I*sqrt(3) - 1/2, y == -sqrt(1/2*I*sqrt(3) + 3/2)],
     492         [x == 1/2*I*sqrt(3) - 1/2, y == sqrt(1/2*I*sqrt(3) + 3/2)],
     493         [x == 0, y == -1], 
    494494         [x == 0, y == 1]]
    495495        sage: solve([sqrt(x) + sqrt(y) == 5, x + y == 10], x, y)
    496496        [[x == -5/2*I*sqrt(5) + 5, y == 5/2*I*sqrt(5) + 5], [x == 5/2*I*sqrt(5) + 5, y == -5/2*I*sqrt(5) + 5]]