macchianera

48 Reputation

2 Badges

15 years, 211 days

MaplePrimes Activity


These are answers submitted by macchianera

Thank you,

So I write:

_EnvAllSolutions := true;

assume(1 > q, q > 0, 1 > p, p >0, q > p);

lambda21 := int(int(int(((xs-xr)^2+(ys-p)^2)*xr/(xs-xr),xr=0..(2-p)*xs/(2-ys)),xs=0..q),ys=0..p);

So the result in Maple 9.5 is:

lambda21 := int(int(PIECEWISE([PIECEWISE([undefined, And(0 < Re(xs), Re(xs) < (-2+p)*xs/(-2+ys))],

[-(PIECEWISE([signum(xs*ys^2-2*xs*ys*p+xs*p^2)*infinity, 0 = xs], [-xs*ln(-xs)*(ys^2-2*ys*p+p^2),

otherwise]))+(PIECEWISE([signum(xs*ys^2-2*xs*ys*p+xs*p^2)*infinity, (-2+p)*xs/(-2+ys) = xs],

[1/6*xs*(48*ys^2+3*xs^2*p^2*ys-12*xs^2*p*ys+36*ln(-xs*(ys-p)/(-2+ys))*p^2*ys^2-

96*ln(-xs*(ys-p)/(-2+ys))*ys*p+144*ln(-xs*(ys-p)/(-2+ys))*ys^2*p+12*ln(-xs*(ys-p)/(-2+ys))*ys^4*p-

72*ln(-xs*(ys-p)/(-2+ys))*p^2*ys-6*ln(-xs*(ys-p)/(-2+ys))*p^2*ys^3-72*ln(-xs*(ys-p)/(-2+ys))*ys^3*p-8*xs^2+12*ys^4-48*ys^3+

12*xs^2*ys+48*p^2-96*ys*p-2*xs^2*p^3+48*ln(-xs*(ys-p)/(-2+ys))*p^2-6*ln(-xs*(ys-p)/(-2+ys))*ys^5+

36*ln(-xs*(ys-p)/(-2+ys))*ys^4-72*ln(-xs*(ys-p)/(-2+ys))*ys^3+48*ln(-xs*(ys-p)/(-2+ys))*ys^2+

6*xs^2*p^2+12*ys^3*p^2-36*p^2*ys^2+24*p^3*ys-6*p^3*ys^2-6*ys^4*p-24*p^3+72*p*ys^2)/(-8+12*ys-6*ys^2+ys^3), otherwise])),

otherwise]), 0 < -xs/(-2+ys)], [0, -xs/(-2+ys) = 0], [undefined, -xs/(-2+ys) < 0]), xs = 0 .. q), ys = 0 .. p)

What can I do?

Thanks

Best regards

Sorry,

There is a mistake.

The result of the integral:

assume(1 > q, q > 0, 1 > p, p >0, q > p);
lambda21 := int(int(int(((xs-xr)^2+(ys-p)^2)*xr/(xs-xr),xr=0..(2-p)*xs/(2-ys)),xs=0..q),ys=0..p);

in Maple 8 is:

lambda21 :=         -1/96*q^2*(-48*p^3+160*p^2+q^2*p^3-4*q^2*p-256*ln(2-p)+256*ln(2)-
                                                      48*p^3*ln(2)+32*p^3*ln(2-p)+16*p^3*ln(p)+192*p^2*ln(2)-
                                                      192*p^2*ln(2-p)-384*p*ln(2)+384*p*ln(2-p)-128*p).

Thanks

Best regards.

 

 

The computation of function Z written as

Z:=(i, pa, pb)->if i=1 then (1-pa)*(1-pb)  else (((1-pa)*(1-pb))^((pa/(1-pa)+pb/(1-pb))^i))* product('1-Z(k, pa, pb)',k=1..i-1) end if;

requires 2^n iteration when i=n.

The serie is f(n)=f(n-1)+f(n-2)+f(n-3)+...+f(1) but f(n-1)=f(n-2)+f(n-3)+...f(1) . So f(n)=2*f(n-1). Where f(n) is the cost of the computation when i=n.

So after 20 iterations performance heavly decreases.

Now I write:

A:=Vector(100);

pa:=0.2; pb:=0.35;

for i from 1 to 100 do if i=1 then A[i]:=(1-pa)*(1-pb) else A[i]:=(((1-pa)*(1-pb))^((pa/(1-pa)+pb/(1-pb))^i)); for j from 1 to i-1 do A[i]:=A[i]*(1-A[j]) end do; end if; end do;

mean:=0;

for i from 1 to 100 do mean:=mean+i*A[i]; end do;

Now It works!

Thanks

Best Regards

Well, the variable x is an integer random variable, while a and b are parameters.

x=1,2,3,... and 0<a<1 and 0<b<1.

Actually, I'm writing the following instructions to compute the mean

Z:=(i, pa, pb)->if i=1 then (1-pa)*(1-pb) else (((1-pa)*(1-pb))^((pa/(1-pa)+pb/(1-pb))^i))* product('1-Z(k, pa, pb)',k=1..i-1) end if;

mysum:=0;

for i from 1 to 100 do mysum:=mysum+i*evalf(Z(i, 0.22, 0.35)) end do;

where a=0.22 and b=0.35. So mysum is the mean, also for me. Note that now the mean is not an integer.

Clearly I need to try not with 100 but with infinite iterations, but I'm happy also with only 100 iterations (after the contributions tend to 0).

These instructions are very difficult, and after 20 iterations performances decreases heavly and I don't see the end of the computation.

So, now I'm rewriting the function Z, memorizing partial result in vectors.

Let's hope.

Thank you very much

Thank you,

you are right, in this case this is not the way to calculate the main.

How can I calculate the mean of this function with i integer in Maple?

Thank you very much.

Best Regards

 

Hello,

Thank you very much.

But now I have another question and the same error.

I want to compute the mean of this function, a numerical approximation. So I write in Maple:

evalf(int(i*Z(i, 0.37, 0.35), i=0..infinity));

But the result is:

Error, (in product) too many levels of recursion.

What can I do?

Thanks

Best Regards

Page 1 of 1