On Nov 15, 2007 2:49 AM, William Stein <[EMAIL PROTECTED]> wrote: > > On Nov 15, 2007 1:45 AM, Dan Drake <[EMAIL PROTECTED]> wrote: > > > > I discovered Sage recently and am very excited about it. In grad school, > > I came to be very good with Mathematica, and am now doing a postdoc > > where I only have access to (an old copy of) Maple. I like the idea of > > having my mathematical software being only a 'wget' away, and even more > > I like the idea of being able to see how it works and change it as I see > > fit. > > > > But I'm having difficulty even defining a relatively simple function and > > finding a floating-point approximation. I want to do > > > > f := x -> integrate(exp(t^2), t=0..x); (Maple) > > evalf(f(2)); > > > > f[x_] := Integrate[Exp[t^2], {t, 0, x}] (Mathematica) > > N[f[2]] > > > > in Sage. I know Python, and Sage is built with Python, so I tried > > > > sage: def f(x): integrate(exp(t^2), t, 0, x) > > > > which complains that "global name 't' is not defined" when I try to > > evaluate it. I don't want a global variable, just a local one to do the > > integration! > > You can define that function and compute the integral in Sage as > follows: > > sage: assume(x > 0) > sage: f(x,t) = integrate(exp(t^2), t, 0, x) > sage: f > (x, t) |--> -sqrt(pi)*I*erf(I*x)/2 > sage: a = f(x,0) > sage: a > -sqrt(pi)*I*erf(I*x)/2 > > The assume is needed above because of how Maxima works (you'll be > non-interactively > asked for it if you don't give it). > > Unfortunately, Sage does not have an implementation of computing > a numerical approximation of erf(a) when a is not real, as PARI only
In that case, what is going on here? sage: w = var("w") sage: f = lambda w: exp((w+sqrt(-1))^2) sage: f(w) e^(w + I)^2 sage: f(w).nintegral(w,0,2)[0] -4.4746871004750179 sage: f = lambda w: real(exp((w+sqrt(-1))^2)) sage: f(w).nintegral(w,0,2)[0] -4.4746871004750179 sage: f = lambda w: imag(exp((w+sqrt(-1))^2)) sage: f(w).nintegral(w,0,2)[0] -1.2224121101763701 > provides this function in case a is real, and maxima also seems to > only provide it in that case. Thus you can't actually numerically evaluate > the result at some point. > > You are the second person to request numerical evaluation of erf... at a > complex argument this week (Paul Zimmerman requested the same > thing a few days ago). So I hope one of the Sage developers looks into > this. I've made it: > > http://trac.sagemath.org/sage_trac/ticket/1173 > > I also made > > http://trac.sagemath.org/sage_trac/ticket/1174 > > which is related. > > > What's the right way to go about all this? Like I said, I'm very excited > > about Sage, but this is not such an auspicious start. > > Calculus is actually not at all the main focus of Sage or Sage development > yet, unfortunately, though the calculus package is very powerful. It's > something we introduced pretty recently into Sage, but it will still take > some time to get every reasonable thing implemented, which very much > is our goal. We need more people-power though, at least for the calculus > part of Sage (where there are currently very few developers compared > to other parts of Sage). > > -- 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://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---