MaPal93

175 Reputation

6 Badges

2 years, 330 days

MaplePrimes Activity


These are questions asked by MaPal93

How to interpret the output to limit()?

restart;
local gamma;

gamma

(1)

A := -sigma__v^2*(((-2*gamma^2*sigma__d^4*sigma__e^4 - 16)*sigma__v^6 + (-6*gamma^2*sigma__d^4*sigma__e^6 - 4*gamma^2*sigma__d^2*sigma__e^4 - 48*sigma__e^2)*sigma__v^4 - sigma__e^4*(gamma^4*sigma__d^6*sigma__e^6 + 4*gamma^2*sigma__d^4*sigma__e^4 + 8*gamma^2*sigma__d^2*sigma__e^2 + 48)*sigma__v^2 - 4*gamma^2*sigma__d^2*sigma__e^8 - 16*sigma__e^6)*sqrt(gamma^2*sigma__d^2*sigma__e^4 + 4*sigma__e^2 + 4*sigma__v^2) + (2*sigma__d^2*sigma__v^8 + (12*sigma__d^2*sigma__e^2 + 8)*sigma__v^6 + 2*(12 + gamma^2*sigma__d^4*sigma__e^4 + sigma__d^2*(gamma^2 + 13)*sigma__e^2)*sigma__e^2*sigma__v^4 + 8*(3 + gamma^2*sigma__d^4*sigma__e^4 + sigma__d^2*(gamma^2 + 6)*sigma__e^2/2)*sigma__e^4*sigma__v^2 + sigma__e^6*(gamma^2*sigma__d^2*sigma__e^2 + 4)*(gamma^2*sigma__d^4*sigma__e^4 + 2*sigma__d^2*sigma__e^2 + 2))*sigma__v^2*gamma*sigma__d)*sigma__d/(4*(sigma__e^2 + sigma__v^2)^2*(gamma^2*sigma__d^2*sigma__e^4 + 4*sigma__e^2 + 4*sigma__v^2)^2);

-(1/4)*sigma__v^2*(((-2*gamma^2*sigma__d^4*sigma__e^4-16)*sigma__v^6+(-6*gamma^2*sigma__d^4*sigma__e^6-4*gamma^2*sigma__d^2*sigma__e^4-48*sigma__e^2)*sigma__v^4-sigma__e^4*(gamma^4*sigma__d^6*sigma__e^6+4*gamma^2*sigma__d^4*sigma__e^4+8*gamma^2*sigma__d^2*sigma__e^2+48)*sigma__v^2-4*gamma^2*sigma__d^2*sigma__e^8-16*sigma__e^6)*(gamma^2*sigma__d^2*sigma__e^4+4*sigma__e^2+4*sigma__v^2)^(1/2)+(2*sigma__d^2*sigma__v^8+(12*sigma__d^2*sigma__e^2+8)*sigma__v^6+2*(12+gamma^2*sigma__d^4*sigma__e^4+sigma__d^2*(gamma^2+13)*sigma__e^2)*sigma__e^2*sigma__v^4+8*(3+gamma^2*sigma__d^4*sigma__e^4+(1/2)*sigma__d^2*(gamma^2+6)*sigma__e^2)*sigma__e^4*sigma__v^2+sigma__e^6*(gamma^2*sigma__d^2*sigma__e^2+4)*(gamma^2*sigma__d^4*sigma__e^4+2*sigma__d^2*sigma__e^2+2))*sigma__v^2*gamma*sigma__d)*sigma__d/((sigma__e^2+sigma__v^2)^2*(gamma^2*sigma__d^2*sigma__e^4+4*sigma__e^2+4*sigma__v^2)^2)

(2)

# Limits

A__0 := limit(A, gamma = 0);
A__inf_wo_assumptions := limit(A, gamma = infinity);
A__inf_with_assumptions := limit(A, gamma = infinity) assuming 0 < sigma__e, 0 < sigma__v, 0 < sigma__d;

(1/2)*sigma__v^2*sigma__d/(sigma__e^2+sigma__v^2)^(1/2)

 

signum(sigma__d^3*sigma__e^2*sigma__v^4*(-sigma__d*sigma__e^2+(sigma__d^2*sigma__e^4)^(1/2))/(sigma__e^2+sigma__v^2)^2)*infinity

 

0

(3)

Download limits_signum.mw

Question is attached:

I describe in words the problem I want to solve with Maple. I'll need to work with random variables.

I want to compute Var[A+B+C] where A, B, and C are not independent of each other. In particular, I don't know how to compute Cov[A,B], Cov[A,C], and Cov[B,C]. The model specifications follow.

Let:

A = X__1*(-lambda__1*X__1-lambda__1*delta__1+nu__1-nu__01);
B = X__2*(-lambda__2*X__2-lambda__2*delta__2+nu__2-nu__02);
A = X__3*(-lambda__3*X__3-lambda__3*delta__3+nu__1+nu__2-nu__01-nu__02);

A = X__1*(-X__1*lambda__1-delta__1*lambda__1-nu__01+nu__1)

 

B = X__2*(-X__2*lambda__2-delta__2*lambda__2-nu__02+nu__2)

 

A = X__3*(-X__3*lambda__3-delta__3*lambda__3-nu__01-nu__02+nu__1+nu__2)

(1)

where lambda__1, lambda__2, and lambda__3 are constants. Moreover, nu__01 is the mean of nu__1~N(nu__01,sigma__nu^2)
and nu__02 is the mean of nu__2~N(nu__02,sigma__nu^2). Note that nu__1 and nu__2 have the same variance and are independent of each other.

In addition:

X__1 = beta__1*(nu__1+nu__2-nu__01-nu__02)+alpha__1*delta__1+alpha__2s*delta__2;
X__2 = beta__2*(nu__1+nu__2-nu__01-nu__02)+alpha__2*delta__2+alpha__1s*delta__1;
X__3 = beta__3*(nu__1+nu__2-nu__01-nu__02)+alpha__3*delta__3;

X__1 = beta__1*(nu__1+nu__2-nu__01-nu__02)+alpha__1*delta__1+alpha__2s*delta__2

 

X__2 = beta__2*(nu__1+nu__2-nu__01-nu__02)+alpha__2*delta__2+alpha__1s*delta__1

 

X__3 = beta__3*(nu__1+nu__2-nu__01-nu__02)+alpha__3*delta__3

(2)

where beta__1, beta__2, beta__3, alpha__1, alpha__2, alpha__3, alpha__1s, alpha__2s are constants. Moreover, delta__1~N(0,sigma__d^2), delta__2~N(0,sigma__d^2), and delta__3~N(0,sigma__d3^2) (note the different variance for delta__3). The variables delta__1, delta__2, and delta__3 are independent of each other. Moreover, nu__1 and nu__2 are independent of delta__1, delta__2, and delta__3.

Now, A, B, C are all products of the form W*Q. In general, Var[W*Q] can be found by applying a formula*** which here reduces to Var[W*Q] = sigma__W^2*sigma__Q^2+(Cov[W,Q])^2, where Cov[W,Q] is simply E[W*Q] since E[W]=0 and E[Q]=0 in my three cases. In short, it's relatively straightforward to find Var[A], Var[B], and Var[C]. However, I don't know about the covariance terms. How to tackle the covariance terms, i.e., Cov[A,B], Cov[A,C], and Cov[B,C]?


***See @whuber's comment in Prof. Dilip Sarwate's answer here https://stats.stackexchange.com/questions/15978/variance-of-product-of-dependent-variables


Perhaps it would be useful to automate the computation of E[A+B+C] as well. However, I managed to compute the expectation by hand, with pen and paper. It would be nice to double check with a script.

Download variance_of_sum_of_products.mw

I have an expression Z_val which I would like to rewrite in a compact, more readable form. Assuming that simplify() did its job, I thought of using (1) alias(), and (2) eval() with some combination of my parameters, since such combination occurs repetitively in my expression.

(1) is not particularly useful for my problem at hand. In particular, powers are not recognized and the alias I defined did not substitute the combination in all the places I was expecting to.

(2) is somehow effective but my expression becomes arguably even more complicated.

What else would you suggest?

EDIT:

restart;

local gamma;

gamma

(1)

M := -lambda*(beta^2*(sigma__v^2+sigma__e^2)+alpha*sigma__d^2*(alpha+1))+beta*sigma__v^2;
V := simplify((1+(Cov__XY/(sigma__X*sigma__Y))^2)*(sigma__X*sigma__Y)^2);

-lambda*(beta^2*(sigma__e^2+sigma__v^2)+alpha*sigma__d^2*(alpha+1))+beta*sigma__v^2

 

sigma__X^2*sigma__Y^2+Cov__XY^2

(2)

# Specify the terms, calculated by hand

sigma__X := beta^2*(sigma__v^2+sigma__e^2)+alpha^2*sigma__d^2;
sigma__Y := lambda^2*(beta^2*(sigma__v^2+sigma__e^2)+sigma__d^2*(alpha+1)^2)+sigma__v^2*(1-2*lambda*beta);
Cov__XY := M;

beta^2*(sigma__e^2+sigma__v^2)+alpha^2*sigma__d^2

 

lambda^2*(beta^2*(sigma__e^2+sigma__v^2)+sigma__d^2*(alpha+1)^2)+sigma__v^2*(-2*beta*lambda+1)

 

-lambda*(beta^2*(sigma__e^2+sigma__v^2)+alpha*sigma__d^2*(alpha+1))+beta*sigma__v^2

(3)

V;

(beta^2*(sigma__e^2+sigma__v^2)+alpha^2*sigma__d^2)^2*(lambda^2*(beta^2*(sigma__e^2+sigma__v^2)+sigma__d^2*(alpha+1)^2)+sigma__v^2*(-2*beta*lambda+1))^2+(-lambda*(beta^2*(sigma__e^2+sigma__v^2)+alpha*sigma__d^2*(alpha+1))+beta*sigma__v^2)^2

(4)

Z := M-(gamma/2)*V;

-lambda*(beta^2*(sigma__e^2+sigma__v^2)+alpha*sigma__d^2*(alpha+1))+beta*sigma__v^2-(1/2)*gamma*((beta^2*(sigma__e^2+sigma__v^2)+alpha^2*sigma__d^2)^2*(lambda^2*(beta^2*(sigma__e^2+sigma__v^2)+sigma__d^2*(alpha+1)^2)+sigma__v^2*(-2*beta*lambda+1))^2+(-lambda*(beta^2*(sigma__e^2+sigma__v^2)+alpha*sigma__d^2*(alpha+1))+beta*sigma__v^2)^2)

(5)

# Specify lambda, beta, and alpha

l := simplify(-gamma*sigma__e^2*sigma__v^2/(2*(sigma__e^2 + sigma__v^2)) + sigma__v^2*sqrt(gamma^2*sigma__d^2*sigma__e^4 + 4*sigma__e^2 + 4*sigma__v^2)/(2*(sigma__e^2 + sigma__v^2)*sigma__d));
b := simplify(eval(sigma__v^2/((gamma*sigma__e^2 + 2*lambda)*sigma__v^2 + 2*lambda*sigma__e^2), lambda = l));
a := simplify(eval(-lambda*(sigma__e^2 + sigma__v^2)/((gamma*sigma__v^2 + 2*lambda)*sigma__e^2 + 2*lambda*sigma__v^2), lambda = l));

(1/2)*sigma__v^2*(-gamma*sigma__e^2*sigma__d+(gamma^2*sigma__d^2*sigma__e^4+4*sigma__e^2+4*sigma__v^2)^(1/2))/((sigma__e^2+sigma__v^2)*sigma__d)

 

sigma__d/(gamma^2*sigma__d^2*sigma__e^4+4*sigma__e^2+4*sigma__v^2)^(1/2)

 

(1/2)*(gamma*sigma__e^2*sigma__d-(gamma^2*sigma__d^2*sigma__e^4+4*sigma__e^2+4*sigma__v^2)^(1/2))/(gamma^2*sigma__d^2*sigma__e^4+4*sigma__e^2+4*sigma__v^2)^(1/2)

(6)

Z_val := simplify(eval(Z, [lambda = l, beta = b, alpha = a]));

-(1/4)*sigma__d*sigma__v^2*(((-2*gamma^2*sigma__d^4*sigma__e^4-16)*sigma__v^6+(-6*gamma^2*sigma__d^4*sigma__e^6-4*gamma^2*sigma__d^2*sigma__e^4-48*sigma__e^2)*sigma__v^4-sigma__e^4*(gamma^4*sigma__d^6*sigma__e^6+4*gamma^2*sigma__d^4*sigma__e^4+8*gamma^2*sigma__d^2*sigma__e^2+48)*sigma__v^2-4*gamma^2*sigma__d^2*sigma__e^8-16*sigma__e^6)*(gamma^2*sigma__d^2*sigma__e^4+4*sigma__e^2+4*sigma__v^2)^(1/2)+(2*sigma__d^2*sigma__v^8+(12*sigma__d^2*sigma__e^2+8)*sigma__v^6+2*(12+gamma^2*sigma__d^4*sigma__e^4+sigma__d^2*(gamma^2+13)*sigma__e^2)*sigma__e^2*sigma__v^4+8*(3+gamma^2*sigma__d^4*sigma__e^4+(1/2)*sigma__d^2*(gamma^2+6)*sigma__e^2)*sigma__e^4*sigma__v^2+sigma__e^6*(gamma^2*sigma__d^2*sigma__e^2+4)*(gamma^2*sigma__d^4*sigma__e^4+2*sigma__d^2*sigma__e^2+2))*sigma__d*sigma__v^2*gamma)/((sigma__e^2+sigma__v^2)^2*(gamma^2*sigma__d^2*sigma__e^4+4*sigma__e^2+4*sigma__v^2)^2)

(7)

eval(Z_val, gamma = Gamma/sigma__e/sigma__d);

-(1/4)*sigma__d*sigma__v^2*(((-2*Gamma^2*sigma__d^2*sigma__e^2-16)*sigma__v^6+(-6*Gamma^2*sigma__d^2*sigma__e^4-4*Gamma^2*sigma__e^2-48*sigma__e^2)*sigma__v^4-sigma__e^4*(Gamma^4*sigma__d^2*sigma__e^2+4*Gamma^2*sigma__d^2*sigma__e^2+8*Gamma^2+48)*sigma__v^2-4*Gamma^2*sigma__e^6-16*sigma__e^6)*(Gamma^2*sigma__e^2+4*sigma__e^2+4*sigma__v^2)^(1/2)+(2*sigma__d^2*sigma__v^8+(12*sigma__d^2*sigma__e^2+8)*sigma__v^6+2*(12+Gamma^2*sigma__e^2*sigma__d^2+sigma__d^2*(Gamma^2/(sigma__e^2*sigma__d^2)+13)*sigma__e^2)*sigma__e^2*sigma__v^4+8*(3+Gamma^2*sigma__e^2*sigma__d^2+(1/2)*sigma__d^2*(Gamma^2/(sigma__e^2*sigma__d^2)+6)*sigma__e^2)*sigma__e^4*sigma__v^2+sigma__e^6*(Gamma^2+4)*(Gamma^2*sigma__d^2*sigma__e^2+2*sigma__d^2*sigma__e^2+2))*sigma__v^2*Gamma/sigma__e)/((sigma__e^2+sigma__v^2)^2*(Gamma^2*sigma__e^2+4*sigma__e^2+4*sigma__v^2)^2)

(8)

Download expression_to_simplify.mw

How to compare the magnitude (the absolute value, ignoring the sign) of two multi-parameter functions f_1 and f_2?

Note that all my parameters can only take stricly positive values. Specifically, I want to know the ranges of parameter values for which f_1 > f_2, f_1 < f_2, and f_1 = f_2. Is solve(f_1 > f_2) etc. the best way to do this? If so, how to specify solve() so that it incorporates all three (>,<,=) comparisons and do not ignore the strict positivity assumption? Is there any other command other than solve()?   

Example with only two parameters sigma__v and sigma__d:

restart

 # Parameters always positive

assume(0 < sigma__d, 0 < sigma__v);
interface(showassumed=0);

1

(1)

Diff('lambda__1', sigma__v) = sqrt(5)/(5*sigma__d);
f__1 := rhs(%);
Diff('lambda__1', sigma__d) = -sqrt(5)*sigma__v/(5*sigma__d^2);
f__2 := abs(rhs(%));

Diff(lambda__1, sigma__v) = (1/5)*5^(1/2)/sigma__d

 

(1/5)*5^(1/2)/sigma__d

 

Diff(lambda__1, sigma__d) = -(1/5)*5^(1/2)*sigma__v/sigma__d^2

 

(1/5)*5^(1/2)*sigma__v/sigma__d^2

(2)

plot3d([f__1,f__2], sigma__v=0.001..10, sigma__d=0.001..10, view=0..5, color=[red,blue]);

 

``

NULL

Download parametric_comparison.mw

Note that f_1 depends only on sigma__d but f_2 depends on both sigma__v and sigma__d. Of course I can directly plot the two curves in 3d in this simple case, but I am looking for a systematic way to do parametric comparisons so that I don't have to "eyeball" the threshold values (if any exist). Most importantly, I can't plot at all once my functions depend on more than two parameters.

 Thanks.

EDIT: perhaps "variables" is a better word than "parameters" here.

I want to approximate a positive function that is decreasing in Gamma, say f(Gamma), that is very complicated yet very smooth. I need this in order to obtain a tractable and compact version of its derivative, which enters in the partial derivative of another (very simple) function.

Along the way, three related questions emerge: Derivatives_and_Approximations.mw

Thanks a lot!

3 4 5 6 7 8 9 Page 5 of 9