On Tue, Aug 18, 2009 at 11:00 PM, Ondrej Certik<ond...@certik.cz> wrote:
>
> On Tue, Aug 18, 2009 at 5:27 PM, William Stein<wst...@gmail.com> wrote:
>>
>> On Tue, Aug 18, 2009 at 3:51 AM, Golam Mortuza
>> Hossain<gmhoss...@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> While testing new integral SFunction class for Sage,
>>> I encountered this weird bug.
>>>
>>> ----------
>>> sage: f(x) = function('f',x)
>>>
>>> sage: f(x).integral(x)
>>> integrate(f(x), x)
>>>
>>> sage: f(x).integral(x^2)
>>> x^2*f(x)
>>> -----------
>>
>> Indeed, what does that mean?  If forced to, I would interpret this as
>>
>>   int f(x) d(x^2)  = int f(x) 2 x dx
>>                         = 2x integrate(f(x),x)
>>
>> So I think the Sage/Maxima answer of x^2*f(x) is bizarre.
>
> well, I would interpret it differently:
>
> int f(x) d(x^2)  = int f(x) 2 x dx
>                     = 2 integrate(x*f(x),x)

That's exactly what I meant.  I was just being very sloppy because I
was in a hurry.  The point is that "int f(x) d(x^2)  = int f(x) 2 x
dx" seems very reasonable.    We could easily make Sage use this
interpretation even though Maxima doesn't.  It woud be an additional
2-3 lines of code in calculus.py.

I am equally for either:

(1) raising an error like Mathematica does
and
(2) Use the interpretation that Ondrej and I agree upon above.

I favor (1) a little bit more than (2), because it's clear that there
is some confusion over this issue, and (1) will definitively reduce
confusion, at the expense of making some user code slightly longer
(but probably easier to understand!).

William

> in sympy we just raise an exception:
>
> In [1]: integrate(sin(x), x)
> Out[1]: -cos(x)
>
> In [2]: integrate(sin(x), x**2)
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
>
> /home/ondrej/repos/sympy/<ipython console> in <module>()
>
> /home/ondrej/repos/sympy/sympy/utilities/decorator.pyc in
> threaded_decorator(expr, *args, **kwargs)
>     54                     return Add(*[ func(f, *args, **kwargs) for
> f in expr.args ])
>     55                 else:
> ---> 56                     return func(expr, *args, **kwargs)
>     57
>     58         threaded_decorator.__doc__  = func.__doc__
>
> /home/ondrej/repos/sympy/sympy/integrals/integrals.pyc in
> integrate(*args, **kwargs)
>    480     """
>    481     new_args = [sympify(arg) for arg in args]
> --> 482     integral = Integral(*new_args, **kwargs)
>    483
>    484     if isinstance(integral, Integral):
>
> /home/ondrej/repos/sympy/sympy/integrals/integrals.pyc in __new__(cls,
> function, *symbols, **assumptions)
>     46                             continue
>     47
> ---> 48                 raise ValueError("Invalid integration variable
> or limits: %s" % str(symbols))
>     49         else:
>     50             # no symbols provided -- let's compute full antiderivative
>
>
> ValueError: Invalid integration variable or limits: (x**2,)
>
>
>
> Ondrej
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to