On Thu, Oct 23, 2008 at 7:56 AM, John H Palmieri <[EMAIL PROTECTED]> wrote:
>
> The setup:
>
> sage: var('x y')
> sage: F = sin(x^2 + y^2) * cos(y) * exp(-0.5*(x^2+y^2))
> sage: G=F.derivative(x,x); G
> -3.00000000000000*x^2*e^(-(0.500000000000000*(y^2 +
> x^2)))*cos(y)*sin(y^2 + x^2) -
> 1.00000000000000*e^(-(0.500000000000000*(y^2 + x^2)))*cos(y)*sin(y^2 +
> x^2) - 4.00000000000000*x^2*e^(-(0.500000000000000*(y^2 +
> x^2)))*cos(y)*cos(y^2 + x^2) + 2*e^(-(0.500000000000000*(y^2 +
> x^2)))*cos(y)*cos(y^2 + x^2)
>
> Then the following takes a long time, between 5 and 10 seconds on my
> 2.4 GHz Intel iMac.
>
> sage: G(1.2, 1.2)
> 0.193703001636676
>
> (I tried using 'timeit(G(1.2, 1.2))' but got: AttributeError:
> 'SymbolicArithmetic' object has no attribute 'find'.)

Quick note: You should have done
   timeit("G(1.2,1.2)")
since timeit takes a string as input.

> My impression is that Ginac is in 3.2-alpha0, which I just installed.
> Can I use it to do these computations? If so, how?

Here's me doing this in sage-3.2.alpha0.  Note that not all the same
commands and conventions as with Sage's usual symbolic variables
are yet supported.  However, the good thing is that the final substitution
takes 1.81 ms on sage.math instead of 10 seconds.

[EMAIL PROTECTED]:~/build/sage-3.2.alpha0$ ./sage
----------------------------------------------------------------------
| SAGE Version 3.2.alpha0, Release Date: 2008-10-20                  |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------

sage: var('x,y',ns=1)    #note the ns=1, which will go away in the future...
(x, y)
sage: F = sin(x^2 + y^2) * cos(y) * exp(-0.5*(x^2+y^2))
sage: G=F.diff(x,1).diff(x,1); G
-exp(-(0.500000000000000)*x^2 - (0.500000000000000)*y^2)*sin(x^2 +
y^2)*cos(y) + 2*exp(-(0.500000000000000)*x^2 -
(0.500000000000000)*y^2)*cos(x^2 + y^2)*cos(y) -
(3.00000000000000)*exp(-(0.500000000000000)*x^2 -
(0.500000000000000)*y^2)*sin(x^2 + y^2)*cos(y)*x^2 -
(4.00000000000000)*exp(-(0.500000000000000)*x^2 -
(0.500000000000000)*y^2)*cos(x^2 + y^2)*cos(y)*x^2
sage: G.subs(x=1.2).subs(y=1.2)
0.193703001636676
sage: timeit('G.subs(x=1.2).subs(y=1.2)')
125 loops, best of 3: 1.81 ms per loop

William

--~--~---------~--~----~------------~-------~--~----~
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-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to