#2697: [with patch, needs review] allow integration without explicit variable
declaration
-------------------------+--------------------------------------------------
 Reporter:  was          |        Owner:  kcrisman  
     Type:  enhancement  |       Status:  new       
 Priority:  major        |    Milestone:  sage-3.2.1
Component:  calculus     |   Resolution:            
 Keywords:               |  
-------------------------+--------------------------------------------------
Changes (by kcrisman):

  * owner:  was => kcrisman
  * summary:  [with patch, negative review] allow integration without
              explicit variable declaration => [with patch,
              needs review] allow integration without
              explicit variable declaration

Comment:

 Replying to [comment:3 robertwb]:

 Posting (final? I hope) version of patch, based on 3.2.alpha0.  Passed
 doctests for calculus.py once, all other times it timed out for me, but I
 do not believe it changes pre-existing correct behavior.

 > I'm getting
 >
 > {{{
 > sage: integrate(sin(x), pi, 2*pi)
 > ------------------------------------------------------------
 > Traceback (most recent call last):
 >   File "<ipython console>", line 1, in <module>
 >   File "/Users/robert/sage/sage-3.1.3/local/lib/python2.5/site-
 packages/sage/calculus/functional.py", line 254, in integral
 >     return f.integral(*args, **kwds)
 >   File "/Users/robert/sage/current/local/lib/python2.5/site-
 packages/sage/calculus/calculus.py", line 2586, in integral
 >     raise TypeError, 'only one endpoint given'
 > TypeError: only one endpoint given
 > }}}
 >

 Turns out that this actually comes from the original code, where the
 second item was turned into a variable in case someone used some already-
 in-use identifier for the variable; the problem was that it turned things
 like e and pi into variables.

 > Rather than catching the error that, say, 0 is not a valid variable
 name, perhaps one should look at the number of variables passed to
 determine how to integrate. E.g.
 >
 > {{{
 > sage: integrate(sin(x))               # 0 args, implicit indefinite
 > cos(x)
 > sage: integrate(sin(x), y)            # 1 arg, explicit indefinite
 > sin(x)*y
 > sage: integrate(sin(x), pi, 2*pi)     # 2 args, implicit definite
 > -2
 > sage: integrate(sin(x), y, pi, 2*pi)  # 3 args, explicit definite
 > pi*sin(x)
 > }}}

 Good idea!  In the end, though, it was easier for me to just jury-rig the
 code as is.  When I make my own functions I try to do that sort of
 planning, but I don't feel confident enough (or have enough time) to
 completely change the way this type of code works.  Hopefully my final
 solution is still pretty good, though; it does all of the above, except
 you will have to declare y beforehand (I couldn't find a way around that),
 and the first integral is -cos(x) :)

 As a bonus, I was finally able to figure out how to do this, which now
 works:
 {{{
 sage: integrate(sin,0,pi)
 2
 }}}
 That alone is worth it for me.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/2697#comment:4>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to