On Fri, Apr 17, 2009 at 4:02 PM, Minjae wrote:
>
> Hello,
>
> I am very new to Sympy, and I was attempting to use it in place of
> Mathematica. It seems that when I try to integrate
>
> integrate(exp(-x)*x**n,(x,0,10)).evalf()
is "n" a number? If so, it works for me:
In [5]: integrate(exp(-x)*
Hello,
n is a symbol, so I was expecting a function of n as the result.
(By the way, changing '10' to 'oo' would have been more relevant: a mistake
on my part)
integrate(exp(-x)*x**n, (x,0,oo))
Which still fails.
Thanks for your point about evalf().
Best,
Minjae
On Fri, Apr 17, 2009 at 8:07 PM
You could try doing this :
>>> x,k=symbols('xk')
>>> f= lambda n : Integral(x**k*exp(-x),(x,0,oo)).subs(k,n)
>>> f(2)
Integral(x**2*exp(-x), (x, 0, oo))
>>> f(2).doit()
2
This works only for integers, for real n, try making use of quad in
scipy - and libmpf (?).
On Apr 18, 5:53 am, Minjae Kim w
On 18 Apr., 02:07, Ondrej Certik wrote:
> On Fri, Apr 17, 2009 at 4:02 PM, Minjae wrote:
>
> > Hello,
>
> > I am very new to Sympy, and I was attempting to use it in place of
> > Mathematica. It seems that when I try to integrate
>
> > integrate(exp(-x)*x**n,(x,0,10)).evalf()
>
> is "n" a numbe