Re: Integral?
- To: mathgroup at smc.vnet.net
- Subject: [mg14180] Re: Integral?
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Wed, 30 Sep 1998 19:42:15 -0400
- Organization: University of Western Australia
- References: <6ud2f0$17f@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Torben Mikael Hansen wrote:
> How do I make Mathematica perform the double integral
>
> Integrate[Integrate[Exp[x]*Exp[y]*p[x,y],{x,-Infinity,Infinity}],
> {y,-Infinity,Infinity}]
>
> where
>
> p[x_,y_]:=1/(2 Pi s^2 Sqrt[1-r^2])*Exp[-(x^2-2 r s x y +y^2)/
> (2 s^2 (1-r^2))]
For your p[x,y] (Daniel entered this incorrectly),
In[1]:=
2 2
x + y - 2 r s x y
Exp[-(-------------------)]
2
1 - r
p[x_, y_] := ---------------------------
2 2
2 Pi s Sqrt[1 - r ]
we suppress the integrate conditions,
In[2]:= SetOptions[Integrate, GenerateConditions -> False];
and compute the integral over x:
In[3]:= Integrate[Exp[x] Exp[y] p[x, y], {x, -Infinity, Infinity}]
Out[3]=
2 2 2
y (r - 2 s y r - 1)
Exp[------ + y - -------------------]
2 2
r - 1 4 (r - 1)
-------------------------------------
2
2 Sqrt[Pi] s
To simplify this result we "complete the square" as follows:
In[4]:= % /. Exp[a_] :> Exp[Collect[a, y, Simplify]] Out[4]=
2 2 2
(1 - r s ) y 1 2 Exp[-------------- + (r s +
1) y + - (1 - r )]
2 4
r - 1
----------------------------------------------
2
2 Sqrt[Pi] s
In[5]:=
2 b 2 b 2 %
/. (a_) y + (b_) y + (c_) :> a (y + ---) + Simplify[c - a (---) ]
2 a 2 a
Out[5]=
2
2 2 (r - 1) (r s + 1) 2
(1 - r s ) (------------------ + y)
2 2 2
2 (1 - r s ) r - 1
Exp[------------------------------------- + ---------]
2 2 r s - 2
r - 1
------------------------------------------------------
2
2 Sqrt[Pi] s
Since we are integrating with respect to y over -Infinity to Infinity we
do a simple change of variables:
In[6]:=
2
(r - 1) (r s + 1)
% /. y -> y - ------------------
2 2
2 (1 - r s )
Out[6]=
2 2 2 2
(1 - r s ) y r - 1
Exp[-------------- + ---------]
2 2 r s - 2
r - 1
-------------------------------
2
2 Sqrt[Pi] s
and then do the integration:
In[7]:= Integrate[%, {y, -Infinity, Infinity}] Out[7]=
2
r - 1
Exp[---------]
2 r s - 2
--------------------
2 2
2 r s - 1
2 s Sqrt[---------]
2
r - 1
As a numerical check,
In[8]:= % /. {r -> 0.2, s -> 1.2}
Out[8]= 0.659048
which agrees with the direct numerical integration:
In[9]:= NIntegrate[Evaluate[Exp[x] Exp[y] p[x, y] /.
{r -> 0.2, s -> 1.2}], {x, -Infinity, Infinity},
{y, -Infinity, Infinity}, AccuracyGoal -> 4] Out[9]= 0.65907
Cheers,
Paul
____________________________________________________________________
Paul Abbott Phone: +61-8-9380-2734
Department of Physics Fax: +61-8-9380-1014
The University of Western Australia Nedlands WA 6907
mailto:paul at physics.uwa.edu.au AUSTRALIA
http://www.physics.uwa.edu.au/~paul
God IS a weakly left-handed dice player
____________________________________________________________________