Ticket #7377: trac_7377-assumptions-p3.patch
File trac_7377-assumptions-p3.patch, 25.8 KB (added by , 11 years ago) |
---|
-
sage/calculus/calculus.py
# HG changeset patch # User Karl-Dieter Crisman <kcrisman@gmail.com> # Date 1299792266 18000 # Node ID c86e54a6bef8e0625f47bac2ec1128c30d0f235a # Parent 8e1dc3ae4ccc1b0ab2a5da96e0f484e56265138f Trac 7377 - provisional patch fixing error messages for assumptions Also fixes various other things, including extra documentation in a number of places and additional examples of assumptions in summation, integration, and limits. diff -r 8e1dc3ae4ccc -r c86e54a6bef8 sage/calculus/calculus.py
a b 483 483 sage: symbolic_sum(a*q^k, k, 0, n) 484 484 (a*q^(n + 1) - a)/(q - 1) 485 485 486 The geometric series:: 486 For the geometric series, we will have to assume 487 the right values for the sum to converge:: 487 488 488 489 sage: assume(abs(q) < 1) 489 490 sage: symbolic_sum(a*q^k, k, 0, oo) … … 498 499 Traceback (most recent call last): 499 500 ... 500 501 ValueError: Sum is divergent. 502 sage: forget() 503 sage: assumptions() # check the assumptions were really forgotten 504 [] 501 505 502 506 This summation only Mathematica can perform:: 503 507 … … 533 537 raise ValueError, "summation limits must not depend on the summation variable" 534 538 535 539 if algorithm == 'maxima': 536 try: 537 return maxima.sr_sum(expression,v,a,b) 538 except TypeError, error: 539 s = str(error) 540 if "divergent" in s or 'Pole encountered' in s: 541 raise ValueError, "Sum is divergent." 542 else: 543 raise 540 return maxima.sr_sum(expression,v,a,b) 544 541 545 542 elif algorithm == 'mathematica': 546 543 try: … … 990 987 sage: CDF(f.limit(x = I)) 991 988 2.06287223508 + 0.74500706218*I 992 989 990 Notice that Maxima may ask for more information:: 991 992 sage: var('a') 993 a 994 sage: limit(x^a,x=0) 995 Traceback (most recent call last): 996 ... 997 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see `assume?` for more details) 998 Is a positive, negative, or zero? 999 1000 With this example, Maxima is looking for a LOT of information:: 1001 1002 sage: assume(a>0) 1003 sage: limit(x^a,x=0) 1004 Traceback (most recent call last): 1005 ... 1006 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see `assume?` for more details) 1007 Is a an integer? 1008 sage: assume(a,'integer') 1009 sage: limit(x^a,x=0) 1010 Traceback (most recent call last): 1011 ... 1012 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see `assume?` for more details) 1013 Is a an even number? 1014 sage: assume(a,'even') 1015 sage: limit(x^a,x=0) 1016 0 1017 sage: forget() 1018 993 1019 More examples:: 994 1020 995 1021 sage: limit(x*log(x), x = 0, dir='+') -
sage/calculus/functional.py
diff -r 8e1dc3ae4ccc -r c86e54a6bef8 sage/calculus/functional.py
a b 242 242 sage: integral(abs(x)*x, x, 0, a) 243 243 Traceback (most recent call last): 244 244 ... 245 TypeError: Computation failed since Maxima requested additional 246 constraints (try the command 'assume(a>0)' before integral or limit 247 evaluation, for example): 245 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before integral evaluation *may* help (example of legal syntax is 'assume(a>0)', see `assume?` for more details) 248 246 Is a positive, negative, or zero? 249 247 sage: assume(a>0) 250 248 sage: integral(abs(x)*x, x, 0, a) -
sage/interfaces/maxima.py
diff -r 8e1dc3ae4ccc -r c86e54a6bef8 sage/interfaces/maxima.py
a b 580 580 581 581 def _expect_expr(self, expr=None, timeout=None): 582 582 """ 583 EXAMPLES: 584 sage: a,b=var('a,b') 585 sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x) 583 Wait for a given expression expr (which could be a regular 584 expression or list of regular expressions) to appear in the output 585 for at most timeout seconds. 586 587 See `sage.interfaces.expect.Expect._expect_expr` for full details 588 on its use and functionality. 589 590 TESTS: 591 592 These tests indirectly show that the interface is working 593 and catching certain errors:: 594 595 sage: maxima('2+2') 596 4 597 sage: maxima('integrate(1/(x^3*(a+b*x)^(1/3)),x)') 586 598 Traceback (most recent call last): 587 599 ... 588 TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(a>0)'before integral or limit evaluation, for example):600 TypeError: Computation failed since Maxima requested additional constraints (try the command "maxima.assume('a>0')" before integral or limit evaluation, for example): 589 601 Is a positive or negative? 590 sage: assume(a>0) 591 sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x) 592 2/9*sqrt(3)*b^2*arctan(1/3*(2*(b*x + a)^(1/3) + a^(1/3))*sqrt(3)/a^(1/3))/a^(7/3) + 2/9*b^2*log((b*x + a)^(1/3) - a^(1/3))/a^(7/3) - 1/9*b^2*log((b*x + a)^(2/3) + (b*x + a)^(1/3)*a^(1/3) + a^(2/3))/a^(7/3) + 1/6*(4*(b*x + a)^(5/3)*b^2 - 7*(b*x + a)^(2/3)*a*b^2)/((b*x + a)^2*a^2 - 2*(b*x + a)*a^3 + a^4) 593 sage: var('x, n') 594 (x, n) 595 sage: integral(x^n,x) 602 sage: maxima.assume('a>0') 603 [a>0] 604 sage: maxima('integrate(1/(x^3*(a+b*x)^(1/3)),x)') 605 -b^2*log((b*x+a)^(2/3)+a^(1/3)*(b*x+a)^(1/3)+a^(2/3))/(9*a^(7/3))+2*b^2*atan((2*(b*x+a)^(1/3)+a^(1/3))/(sqrt(3)*a^(1/3)))/(3^(3/2)*a^(7/3))+2*b^2*log((b*x+a)^(1/3)-a^(1/3))/(9*a^(7/3))+(4*b^2*(b*x+a)^(5/3)-7*a*b^2*(b*x+a)^(2/3))/(6*a^2*(b*x+a)^2-12*a^3*(b*x+a)+6*a^4) 606 sage: maxima('integrate(x^n,x)') 596 607 Traceback (most recent call last): 597 608 ... 598 TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(n+1>0)'before integral or limit evaluation, for example):609 TypeError: Computation failed since Maxima requested additional constraints (try the command "maxima.assume('n+1>0')" before integral or limit evaluation, for example): 599 610 Is n+1 zero or nonzero? 600 sage: assume(n+1>0) 601 sage: integral(x^n,x) 602 x^(n + 1)/(n + 1) 603 sage: forget() 611 sage: maxima.assume('n+1>0') 612 [n>-1] 613 sage: maxima('integrate(x^n,x)') 614 x^(n+1)/(n+1) 615 sage: maxima.forget([fact for fact in maxima.facts()]) 616 [[a>0,n>-1]] 617 sage: maxima.facts() 618 [] 619 sage: var('a') 620 a 621 sage: maxima('limit(x^a,x,0)') 622 Traceback (most recent call last): 623 ... 624 TypeError: Computation failed since Maxima requested additional constraints (try the command "maxima.assume('a>0')" before integral or limit evaluation, for example): 625 Is a positive, negative, or zero? 604 626 """ 605 627 if expr is None: 606 628 expr = self._prompt_wait … … 623 645 j = v.find('Is ') 624 646 v = v[j:] 625 647 k = v.find(' ',4) 626 msg = " Computation failed since Maxima requested additional constraints (try the command 'assume(" + v[4:k] +">0)' before integral or limit evaluation, for example):\n" + v + self._ask[i-1]648 msg = """Computation failed since Maxima requested additional constraints (try the command "maxima.assume('""" + v[4:k] +""">0')" before integral or limit evaluation, for example):\n""" + v + self._ask[i-1] 627 649 self._sendline(";") 628 650 self._expect_expr() 629 651 raise ValueError, msg … … 949 971 """ 950 972 return MaximaElementFunction 951 973 952 ##some helper functions to wrap thacalculus use of the maxima interface.974 ##some old helper functions to wrap the calculus use of the maxima interface. 953 975 ##these routines expect arguments living in the symbolic ring and return something 954 976 ##that is hopefully coercible into the symbolic ring again. 955 956 def sr_integral(self,*args):957 return args[0]._maxima_().integrate(*args[1:])958 959 def sr_sum(self,expression,v,a,b):960 sum = "'sum(%s, %s, %s, %s)" % tuple([repr(expr._maxima_()) for expr in (expression, v, a, b)])961 result = self.simplify_sum(sum)962 result = result.ratsimp()963 return expression.parent()(result)964 965 def sr_limit(self,ex,*args):966 return ex._maxima_().limit(*args)967 968 def sr_tlimit(self,ex,*args):969 return ex._maxima_().tlimit(*args)970 977 ## 978 ## def sr_integral(self,*args): 979 ## return args[0]._maxima_().integrate(*args[1:]) 980 ## 981 ## def sr_sum(self,expression,v,a,b): 982 ## sum = "'sum(%s, %s, %s, %s)" % tuple([repr(expr._maxima_()) for expr in (expression, v, a, b)]) 983 ## result = self.simplify_sum(sum) 984 ## result = result.ratsimp() 985 ## return expression.parent()(result) 986 ## 987 ## def sr_limit(self,ex,*args): 988 ## return ex._maxima_().limit(*args) 989 ## 990 ## def sr_tlimit(self,ex,*args): 991 ## return ex._maxima_().tlimit(*args) 992 ## 971 993 972 994 def is_MaximaElement(x): 973 995 """ -
sage/interfaces/maxima_lib.py
diff -r 8e1dc3ae4ccc -r c86e54a6bef8 sage/interfaces/maxima_lib.py
a b 405 405 ##that is hopefully coercible into the symbolic ring again. 406 406 407 407 def sr_integral(self,*args): 408 """ 409 Helper function to wrap calculus use of Maxima's integration. 410 411 TESTS:: 412 413 sage: a,b=var('a,b') 414 sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x) 415 Traceback (most recent call last): 416 ... 417 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before integral evaluation *may* help (example of legal syntax is 'assume(a>0)', see `assume?` for more details) 418 Is a positive or negative? 419 sage: assume(a>0) 420 sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x) 421 2/9*sqrt(3)*b^2*arctan(1/3*(2*(b*x + a)^(1/3) + a^(1/3))*sqrt(3)/a^(1/3))/a^(7/3) + 2/9*b^2*log((b*x + a)^(1/3) - a^(1/3))/a^(7/3) - 1/9*b^2*log((b*x + a)^(2/3) + (b*x + a)^(1/3)*a^(1/3) + a^(2/3))/a^(7/3) + 1/6*(4*(b*x + a)^(5/3)*b^2 - 7*(b*x + a)^(2/3)*a*b^2)/((b*x + a)^2*a^2 - 2*(b*x + a)*a^3 + a^4) 422 sage: var('x, n') 423 (x, n) 424 sage: integral(x^n,x) 425 Traceback (most recent call last): 426 ... 427 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before integral evaluation *may* help (example of legal syntax is 'assume(n+1>0)', see `assume?` for more details) 428 Is n+1 zero or nonzero? 429 sage: assume(n+1>0) 430 sage: integral(x^n,x) 431 x^(n + 1)/(n + 1) 432 sage: forget() 433 sage: assumptions() # Check the assumptions really were forgotten 434 [] 435 """ 408 436 try: 409 437 return max_to_sr(maxima_eval(([max_integrate],[sr_to_max(SR(a)) for a in args]))) 410 438 except RuntimeError, error: 411 439 s = str(error) 412 440 if "Divergent" in s or "divergent" in s: 441 # in pexpect interface, one looks for this - e.g. integrate(1/x^3,x,-1,3) gives a principal value 442 # if "divergent" in s or 'Principal Value' in s: 413 443 raise ValueError, "Integral is divergent." 444 elif "Is" in s: # Maxima asked for a condition 445 j = s.find('Is ') 446 s = s[j:] 447 k = s.find(' ',4) 448 raise ValueError, "Computation failed since Maxima requested additional constraints; using the 'assume' command before integral evaluation *may* help (example of legal syntax is 'assume(" + s[4:k] +">0)', see `assume?` for more details)\n" + s 414 449 else: 415 450 raise error 416 451 417 452 def sr_sum(self,*args): 453 """ 454 Helper function to wrap calculus use of Maxima's summation. 455 456 TESTS:: 457 458 sage: x, y, k, n = var('x, y, k, n') 459 sage: sum(binomial(n,k) * x^k * y^(n-k), k, 0, n) 460 (x + y)^n 461 sage: q, a = var('q, a') 462 sage: sum(a*q^k, k, 0, oo) 463 Traceback (most recent call last): 464 ... 465 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before summation *may* help (example of legal syntax is 'assume(abs(q)-1>0)', see `assume?` for more details) 466 Is abs(q)-1 positive, negative, or zero? 467 sage: assume(q > 1) 468 sage: sum(a*q^k, k, 0, oo) 469 Traceback (most recent call last): 470 ... 471 ValueError: Sum is divergent. 472 sage: forget() 473 sage: assume(abs(q) < 1) 474 sage: sum(a*q^k, k, 0, oo) 475 -a/(q - 1) 476 sage: forget() 477 sage: assumptions() # check the assumptions were really forgotten 478 [] 479 """ 418 480 try: 419 481 return max_to_sr(maxima_eval([[max_ratsimp],[[max_simplify_sum],([max_sum],[sr_to_max(SR(a)) for a in args])]])); 420 482 except RuntimeError, error: 421 483 s = str(error) 422 484 if "divergent" in s: 485 # in pexpect interface, one looks for this - could not find an example where 'Pole encountered' occurred, though 486 # if "divergent" in s or 'Pole encountered' in s: 423 487 raise ValueError, "Sum is divergent." 488 elif "Is" in s: # Maxima asked for a condition 489 j = s.find('Is ') 490 s = s[j:] 491 k = s.find(' ',4) 492 raise ValueError, "Computation failed since Maxima requested additional constraints; using the 'assume' command before summation *may* help (example of legal syntax is 'assume(" + s[4:k] +">0)', see `assume?` for more details)\n" + s 424 493 else: 425 494 raise error 426 495 427 496 def sr_limit(self,expr,v,a,dir=None): 428 L=[sr_to_max(SR(a)) for a in [expr,v,a]] 429 if dir == "plus": 430 L.append(max_plus) 431 elif dir == "minus": 432 L.append(max_minus) 433 return max_to_sr(maxima_eval(([max_limit],L))) 497 """ 498 Helper function to wrap calculus use of Maxima's limits. 499 500 TESTS:: 501 502 sage: f = (1+1/x)^x 503 sage: limit(f,x = oo) 504 e 505 sage: limit(f,x = 5) 506 7776/3125 507 sage: limit(f,x = 1.2) 508 2.06961575467... 509 sage: var('a') 510 a 511 sage: limit(x^a,x=0) 512 Traceback (most recent call last): 513 ... 514 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see `assume?` for more details) 515 Is a positive, negative, or zero? 516 sage: assume(a>0) 517 sage: limit(x^a,x=0) 518 Traceback (most recent call last): 519 ... 520 ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see `assume?` for more details) 521 Is a an integer? 522 sage: assume(a,'integer') 523 sage: assume(a,'even') # Yes, Maxima will ask this too 524 sage: limit(x^a,x=0) 525 0 526 sage: forget() 527 sage: assumptions() # check the assumptions were really forgotten 528 [] 529 """ 530 try: 531 L=[sr_to_max(SR(a)) for a in [expr,v,a]] 532 if dir == "plus": 533 L.append(max_plus) 534 elif dir == "minus": 535 L.append(max_minus) 536 return max_to_sr(maxima_eval(([max_limit],L))) 537 except RuntimeError, error: 538 s = str(error) 539 if "Is" in s: # Maxima asked for a condition 540 j = s.find('Is ') 541 s = s[j:] 542 raise ValueError, "Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see `assume?` for more details)\n" + s 543 else: 544 raise error 434 545 435 546 def sr_tlimit(self,expr,v,a,dir=None): 547 """ 548 Helper function to wrap calculus use of Maxima's Taylor series limits. 549 550 TESTS:: 551 552 sage: f = (1+1/x)^x 553 sage: limit(f, x = I, taylor=True) 554 (-I + 1)^I 555 """ 436 556 L=[sr_to_max(SR(a)) for a in [expr,v,a]] 437 557 if dir == "plus": 438 558 L.append(max_plus) -
sage/symbolic/assumptions.py
diff -r 8e1dc3ae4ccc -r c86e54a6bef8 sage/symbolic/assumptions.py
a b 94 94 """ 95 95 from sage.calculus.calculus import maxima 96 96 if self._context is None: 97 # We get the list here because features may be added with time. 97 # We get the list here because features may be added with time. 98 98 valid_features = list(maxima("features")) 99 99 if self._assumption not in [repr(x).strip() for x in list(valid_features)]: 100 100 raise ValueError, "%s not a valid assumption, must be one of %s" % (self._assumption, valid_features) … … 102 102 self._context = maxima.newcontext('context' + maxima._next_var_name()) 103 103 try: 104 104 maxima.eval("declare(%s, %s)" % (repr(self._var), self._assumption)) 105 except TypeError, mess: 105 # except TypeError, mess: 106 # if 'inconsistent' in str(mess): # note Maxima doesn't tell you if declarations are redundant 107 # raise ValueError, "Assumption is inconsistent" 108 except RuntimeError, mess: 106 109 if 'inconsistent' in str(mess): # note Maxima doesn't tell you if declarations are redundant 107 110 raise ValueError, "Assumption is inconsistent" 108 111 else: … … 138 141 else: # trying to forget a declaration explicitly rather than implicitly 139 142 for x in _assumptions: 140 143 if repr(self) == repr(x): # so by implication x is also a GenericDeclaration 141 x.forget() 144 x.forget() 142 145 break 143 146 return 144 147 145 148 def contradicts(self, soln): 146 149 """ 147 Returns ``True`` if this assumption is violated by the given variable assignment(s). 150 Returns ``True`` if this assumption is violated by the given 151 variable assignment(s). 148 152 149 153 INPUT: 150 154 … … 259 263 260 264 - ``*args`` - assumptions 261 265 262 EXAMPLES:: 266 EXAMPLES: 267 268 Assumptions are typically used to ensure certain relations are 269 evaluated as true that are not true in general. 263 270 271 Here, we verify that for `x>0`, `\sqrt(x^2)=x`:: 272 264 273 sage: assume(x > 0) 265 274 sage: bool(sqrt(x^2) == x) 266 275 True 276 277 This will be assumed in the current Sage session until forgotten:: 278 267 279 sage: forget() 268 280 sage: bool(sqrt(x^2) == x) 269 281 False 270 282 283 284 Another major use case is in taking certain integrals and limits 285 where the answers may depend on some sign condition:: 286 287 sage: var('x, n') 288 (x, n) 289 sage: assume(n+1>0) 290 sage: integral(x^n,x) 291 x^(n + 1)/(n + 1) 292 sage: forget() 293 294 :: 295 296 sage: var('q, a, k') 297 (q, a, k) 298 sage: assume(q > 1) 299 sage: sum(a*q^k, k, 0, oo) 300 Traceback (most recent call last): 301 ... 302 ValueError: Sum is divergent. 303 sage: forget() 304 sage: assume(abs(q) < 1) 305 sage: sum(a*q^k, k, 0, oo) 306 -a/(q - 1) 307 sage: forget() 308 271 309 An integer constraint:: 272 310 273 311 sage: var('n, P, r, r2') … … 278 316 sage: solve(c==d,r2) 279 317 [r2 == e^r - 1] 280 318 281 ::319 Simplifying certain well-known identities works as well:: 282 320 283 321 sage: sin(n*pi) 284 322 sin(pi*n) -
sage/symbolic/integration/external.py
diff -r 8e1dc3ae4ccc -r c86e54a6bef8 sage/symbolic/integration/external.py
a b 18 18 if a is None: 19 19 result = maxima.sr_integral(expression,v) 20 20 else: 21 try: 22 result = maxima.sr_integral(expression, v, a, b) 23 except TypeError, error: 24 s = str(error) 25 if "divergent" in s or 'Principal Value' in s: 26 raise ValueError, "Integral is divergent." 27 else: 28 raise 21 result = maxima.sr_integral(expression, v, a, b) 29 22 return result._sage_() 30 23 31 24 def sympy_integrator(expression, v, a=None, b=None): -
sage/symbolic/integration/integral.py
diff -r 8e1dc3ae4ccc -r c86e54a6bef8 sage/symbolic/integration/integral.py
a b 55 55 """ 56 56 # The automatic evaluation routine will try these integrators 57 57 # in the given order. This is an attribute of the class instead of 58 # a global variable in this module to enable customization by 58 # a global variable in this module to enable customization by 59 59 # creating a subclasses which define a different set of integrators 60 60 self.integrators = [external.maxima_integrator] 61 61 … … 141 141 """ 142 142 # The automatic evaluation routine will try these integrators 143 143 # in the given order. This is an attribute of the class instead of 144 # a global variable in this module to enable customization by 144 # a global variable in this module to enable customization by 145 145 # creating a subclasses which define a different set of integrators 146 146 self.integrators = [external.maxima_integrator] 147 147 … … 332 332 sage: integral(x^n,x) 333 333 Traceback (most recent call last): 334 334 ... 335 TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(n+1>0)' before integral or limit evaluation, for example): 335 ValueError: Computation failed since Maxima requested additional 336 constraints; using the 'assume' command before integral evaluation 337 *may* help (example of legal syntax is 'assume(n+1>0)', see `assume?` 338 for more details) 336 339 Is n+1 zero or nonzero? 337 340 sage: assume(n > 0) 338 341 sage: integral(x^n,x) … … 348 351 Note that an exception is raised when a definite integral is 349 352 divergent:: 350 353 351 sage: forget() 352 354 sage: forget() # always remember to forget assumptions you no longer need 353 355 sage: integrate(1/x^3,(x,0,1)) 354 356 Traceback (most recent call last): 355 357 ... 356 358 ValueError: Integral is divergent. 357 sage: integrate(1/x^3,x,-1,3) 359 sage: integrate(1/x^3,x,-1,3) 358 360 Traceback (most recent call last): 359 361 ... 360 362 ValueError: Integral is divergent. … … 362 364 But Sage can calculate the convergent improper integral of 363 365 this function:: 364 366 365 sage: integrate(1/x^3,x,1,infinity) 367 sage: integrate(1/x^3,x,1,infinity) 366 368 1/2 367 369 368 370 The examples in the Maxima documentation:: … … 411 413 -y*z + x^y/log(x) 412 414 sage: (x^y-z).integrate(y,algorithm="sympy") 413 415 -y*z + x^y/log(x) 414 416 415 417 416 418 We integrate the above function in maple now:: 417 419 … … 434 436 435 437 :: 436 438 437 sage: integral(e^(-x^2),(x, 0, 0.1)) 439 sage: integral(e^(-x^2),(x, 0, 0.1)) 438 440 0.0562314580091*sqrt(pi) 439 441 440 442 ALIASES: integral() and integrate() are the same. 441 443 442 EXAMPLES: Here is example where we have to use assume:: 444 EXAMPLES: 445 446 Here is an example where we have to use assume:: 443 447 444 448 sage: a,b = var('a,b') 445 449 sage: integrate(1/(x^3 *(a+b*x)^(1/3)), x) 446 450 Traceback (most recent call last): 447 451 ... 448 TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(a>0)' before integral or limit evaluation, for example): 452 ValueError: Computation failed since Maxima requested additional 453 constraints; using the 'assume' command before integral evaluation 454 *may* help (example of legal syntax is 'assume(a>0)', see `assume?` 455 for more details) 449 456 Is a positive or negative? 450 457 451 458 So we just assume that `a>0` and the integral works:: … … 483 490 sage: res = integral(f,x,0.0001414, 1.); res 484 491 Traceback (most recent call last): 485 492 ... 486 TypeError: Computation failed since Maxima requested additional 487 constraints (try the command 'assume((y-1)*(y+1)>0)' before integral 488 or limit evaluation, for example): 493 ValueError: Computation failed since Maxima requested additional 494 constraints; using the 'assume' command before integral evaluation 495 *may* help (example of legal syntax is 'assume((y-1)*(y+1)>0)', 496 see `assume?` for more details) 489 497 Is (y-1)*(y+1) positive, negative, or zero? 490 498 sage: assume(y>1) 491 499 sage: res = integral(f,x,0.0001414, 1.); res … … 560 568 2*pi 561 569 sage: a.simplify_full().simplify_trig() 562 570 1 563 """ 571 """ 564 572 if isinstance(v, (list, tuple)) and a is None and b is None: 565 573 if len(v)==1: # bare variable in a tuple 566 574 v=v[0]