2

I am new to maple and have run into an issue optimizing wrt a term within sum() and or product(). Suppose I want to optimize a profit function function given by

\begin{align} Q : = p \cdot A \prod_{l=1}^{L-1} z_l^{a_l} - \sum_{l=1}^{L-1}w_lz_l \end{align}

wrt to input $z_l$. diff(Q,z[l]) yields nonsense and diff(Q,z[1]) zero. I am having trouble finding alternative methods generating the FOC. Any help is appreciated.

  • Differentiating by $z_l$ does not make sense as there is nothing like that in your expression (it exists only inside the products/sums, but not in the expression itself). Also differentiating by $z_1$ probably does not work because Maple does not know the $L$, it is just too generic ($L$ could be $1$ for what it knows, and there would be no $z_1$ in that case, but still this behavior looks a little bit strange). I would try defining $Q$ as a function of $L$, and then check what Maple gives for specific values of $L$ when differentiating by $z_1$ etc... – Sil Sep 02 '18 at 09:06

1 Answers1

0

As @Sil already has mentioned in a comment below your question, your problem is that you have a undetermined sum and product. For example assume you want to take derivative with respect to z2, how can Maple check if there is a z2 in your expression? L is not defined so it's not clear what indices exist in your expression. What you can do is as following. If you need the Q expression for different values of L, then define a function of L or a procedure with L as its input. So when you want to compute something related to Q of a specific L, you just put Q equal to the output of that procedure for your choice of L, then do the computations.

Qproc := proc(L) 
local l; 
return(p*A*product(z[l]^a[l],l=1..L-1)-add(w[l]*z[l],l=1..L-1); 
end proc:

This procedure returns you your Q expression for a given choice of L. Let's say I want $L=3$. Then I do as following.

Q:=Qproc(3);

The Maple output will be;

enter image description here

Then you can ask derivatives with respect to z1 and z2, because now they are in your expression (not like when you had an undetermined sum and product!).

for l to 3 - 1 do
print(expand(z[l]*diff(Q,z[l])));
end do;

The Maple output is;

enter image description here