On Wed, Nov 19, 2008 at 5:36 PM, Robert Bradshaw
<[EMAIL PROTECTED]> wrote:
>
> On Nov 19, 2008, at 2:19 PM, Jason Grout wrote:
>
>>
>> Jason Grout wrote:
>>> Scott Walck wrote:
>>>> The sage command
>>>>
>>>> plot(2*cos)
>>>>
>>>> produces a plot of 2*sin(x).  This seems like a bug.  This occurs in
>>>> sage 3.1.4 and on the web version.
>>>>
>>>> Note that
>>>>
>>>> plot(2*cos(x))
>>>>
>>>> works properly.  Also,
>>>>
>>>> plot(2*sin)
>>>>
>>>> appears to give the correct plot.
>>>
>>
>>
>> Line 6860 of calculus.py defines the fast_float function for cos(x) to
>> be math.sin.  That's the problem.  I'm posting a patch right now.
>
> Why are we using math.sin/math.cos at all? Really, it should use the
> native C sin and cos.
>
> - Robert

You're right Robert, and that definition of _fast_float_ for sin and cos
is totally the wrong approach.  E.g., observe that your _fast_float_ sin
is twice as fast as math.sin:

sage: a = sin._fast_float_()
sage: timeit('a(3.4r)')
625 loops, best of 3: 469 ns per loop
sage: a = sin(x)._fast_float_()
sage: timeit('a(3.4r)')
625 loops, best of 3: 254 ns per loop

Note that the code in calculus.py is *not* just returning math.sin,
actually, but constructing a fast_float object, which is actually
way *WORSE* than math.sin, even:

sage: a = sin._fast_float_()
sage: timeit('a(3.4r)')
625 loops, best of 3: 809 ns per loop
sage: type(a)
<type 'sage.ext.fast_eval.FastDoubleFunc'>

I've opened a ticket about fixing this here:
   http://trac.sagemath.org/sage_trac/ticket/4561

I think #4557 should go in as/is into sage-3.2, but this
should be fixed better (efficiency-wise) for sage-3.2.1.

William

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

Reply via email to