First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 12 years ago

kayhan gravatar image

newbie question about symbolic integration in sage

Hi,

I am new to sage and my question can be naive, I apologize in advance. I would like to use sage for some symbolic integration operations to avoid human mistake. Here is my first test (which is going to important for my application).

Integration of Normal distribution from -infinity to +infinity. Obviously the result should be one and I am wondering why I don't get it:

--

x, sigma, mu = var('x','sigma','mu')

q = 1/((2pi)^(1/2)sigma)exp(-(x - mu)^2/(2sigma^2))

show(q)

import sympy

show((sympy.integrate(q, (x,-sympy.oo, sympy.oo))).simplify())

--

Here is the result:

Integral(2(1/2)exp(-mu2/(2sigma2))exp(-x2/(2sigma2))exp(mux/sigma2)/(2pi(1/2)sigma),(x,-oo,oo))

I am wondering why I don't get 1? Am I missing anything?

Thanks

click to hide/show revision 2
No.2 Revision

updated 12 years ago

kcrisman gravatar image

newbie question about symbolic integration in sage

Hi,

I am new to sage and my question can be naive, I apologize in advance. I would like to use sage for some symbolic integration operations to avoid human mistake. Here is my first test (which is going to important for my application).

Integration of Normal distribution from -infinity to +infinity. Obviously the result should be one and I am wondering why I don't get it:

--

x, sigma, mu = var('x','sigma','mu')

var('x','sigma','mu')

q = 1/((2pi)^(1/2)sigma)exp(-(x 1/((2*pi)^(1/2)*sigma)*exp(-(x - mu)^2/(2sigma^2))

mu)^2/(2*sigma^2)) show(q)

show(q)

import sympy

import sympy

show((sympy.integrate(q, (x,-sympy.oo, sympy.oo))).simplify())

sympy.oo))).simplify())

--

Here is the result:

Integral(2(1/2)exp(-mu2/(2sigma2))exp(-x2/(2sigma2))exp(mux/sigma2)/(2pi(1/2)sigma),(x,-oo,oo))

Integral(2**(1/2)*exp(-mu**2/(2*sigma**2))*exp(-x**2/(2*sigma**2))*exp(mu*x/sigma**2)/(2*pi**(1/2)*sigma),(x,-oo,oo))

--

I am wondering why I don't get 1? Am I missing anything?

Thanks