Here is some of my work on Matlab and an actuarial exam P study manual
What is the expectance of E(X+Y+Z)^2 if mean is 3 for x,y,z exponentional variables
syms x y z
fx(x)=(1/3)*exp(-x/3)
fy(y)=(1/3)*exp(-y/3)
fz(z)=(1/3)*exp(-z/3)
expand((x+y+z)^2)
Ex1=int(x*fx(x),0,inf)
Ex2=int(x^2*fx(x),0,inf)
E2xy=int(int(2*x*fx(x),0,inf) * y * fy(y),0,inf)
E2xz=int(int(2*x*fx(x),0,inf) * z * fz(z),0,inf)
Ey2=int(y^2*fy(y),0,inf)
E2yz=int(int(2*y*fy(y),0,inf) * z * fz(z),0,inf)
Ez2=int(z^2*fz(z),0,inf)
Etrinomialnis2=Ex2+E2xy+E2xz+Ey2+E2yz+Ez2
What is the P(Y>1/2) given 0 < x < y < z < 1 ?
syms x y z
fz(z)=z
fx(x)=x
fy(y)=y
int1=int(48*fz(z),y,1)
int2=int(int1*fx(x),0,y)
int3=int(int2*fy(y),1/2,1)
double(int3)
(My favorite) What is the expectance of X and Y=5, given Y=5?
X is distributed as the first time a 6 appears on a fair die
Y is distributed as the first even number appearing on another fair die
syms x y
fx(x)=(5/6)^(x-1)*(1/6)
fy(y)=(1/2)^(y-1)*(1/2)
den=double(int(y * fy(y),0,5))
num=int(x * den * fx(x),0,inf)
ans=round(num/den)