The Economic Problem
The Original Formulation
\begin{align*} \mathcal{L}[CAP,q,\lambda] &= (v-CAP) \sum_{j=1}^J j \cdot q^j (1-q)^{N-j} \binom{N}{j} \\ & + (v- c + \delta C) \sum_{j=J+1}^{N} J \cdot q^j (1-q)^{N-j} \binom{N}{j} \notag \\ & + \lambda \Bigg\{(CAP-C) \sum_{j=1}^J q^{j-1} (1-q)^{N-1-j} \binom{N-1}{j-1} \notag \\ & - \delta C \sum_{j=J+1}^{N} q^{j-1} (1-q)^{N-1-j} \binom{N-1}{j-1} \Bigg\} \notag && \end{align*}\begin{align*} \mathcal{L}[CAP,q,\lambda] =& (v-CAP) \sum_{j=1}^J j \cdot q^j (1-q)^{N-j} \binom{N}{j} \\ & + (v- c + \delta C) \sum_{j=J+1}^{N} J \cdot q^j (1-q)^{N-j} \binom{N}{j} \notag \\ & + \lambda \Bigg\{(CAP-C) \sum_{j=1}^J q^{j-1} (1-q)^{N-1-j} \binom{N-1}{j-1} \notag \\ & - \delta C \sum_{j=J+1}^{N} q^{j-1} (1-q)^{N-1-j} \binom{N-1}{j-1} \Bigg\} \notag && \end{align*}
Alternative (but equivalent) Formulation
\begin{align*} loss[q]&=( \delta C ) \sum_{j=J+1}^N (j-J) \cdot q^{j} (1-q)^{N-j} \binom{N}{j} + ( v- C ) \sum_{j=0}^J (J-j) \cdot q^{j} (1-q)^{N-j} \binom{N}{j} \end{align*}\begin{align*} loss[q]=&( \delta C ) \sum_{j=J+1}^N (j-J) \cdot q^{j} (1-q)^{N-j} \binom{N}{j} \\ &+ ( v- C ) \sum_{j=0}^J (J-j) \cdot q^{j} (1-q)^{N-j} \binom{N}{j} \end{align*}
Solving the Alternative Formulation
Let us thus differentiate $loss[q]$ and set it equal to zero. \begin{align*} 0=&\frac{d loss[q]}{d q} \\ =& \delta C \sum_{j=J+1}^N (j-J) \Big(j \cdot q^{j-1} (1-q)^{N-j} -(N-j) \cdot q^{j} (1-q)^{N-1-j} \Big) \cdot \binom{N}{j} \\ &+ ( v- C ) \sum_{j=0}^J (J-j) \Big(j \cdot q^{j-1} (1-q)^{N-j} -(N-j) \cdot q^{j} (1-q)^{N-1-j} \Big) \cdot \binom{N}{j} \\ =& \delta C \Bigg( \sum_{j=J+1}^N (j-J) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} - \sum_{j=J+1}^N (j-J) (N-j) \cdot q^{j} (1-q)^{N-1-j} \binom{N}{j} \Bigg) \\ &+ ( v- C ) \Bigg( \sum_{j=0}^J (J-j) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} - \sum_{j=0}^J (J-j) (N-j) \cdot q^{j} (1-q)^{N-1-j} \binom{N}{j} \Bigg) \\ =& \delta C \Bigg( \sum_{j=J+1}^N (j-J) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} - \sum_{j=J+2}^{N+1} (j-1-J) (N+1-j) \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j-1} \Bigg) \\ &+ ( v- C ) \Bigg( \sum_{j=0}^J (J-j) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \\ &- \sum_{j=1}^{J+1} (J+1-j) (N+1-j) \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j-1} \Bigg) \\ =& \delta C \Bigg( \sum_{j=J+1}^N (j-J) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} - \sum_{j=J+1}^N (j-1-J) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \Bigg) \\ &+ ( v- C ) \Bigg( \sum_{j=0}^J (J-j) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} - \sum_{j=0}^J (J+1-j) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \Bigg) \\ =& \delta C \Bigg( \sum_{j=J+1}^N j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \Bigg) - ( v- C ) \Bigg( \sum_{j=0}^J j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} + J \cdot q^{J-1} (1-q)^{N-J} \binom{N}{J} \Bigg) \end{align*}\begin{align*} 0=&\frac{d loss[q]}{d q} \\ =& \delta C \sum_{j=J+1}^N (j-J) \Big(j \cdot q^{j-1} (1-q)^{N-j} \\ &-(N-j) \cdot q^{j} (1-q)^{N-1-j} \Big) \cdot \binom{N}{j} \\ &+ ( v- C ) \sum_{j=0}^J (J-j) \Big(j \cdot q^{j-1} (1-q)^{N-j} -(N-j) \cdot q^{j} (1-q)^{N-1-j} \Big) \cdot \binom{N}{j} \\ =& \delta C \Bigg( \sum_{j=J+1}^N (j-J) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \\ &- \sum_{j=J+1}^N (j-J) (N-j) \cdot q^{j} (1-q)^{N-1-j} \binom{N}{j} \Bigg) \\ &+ ( v- C ) \Bigg( \sum_{j=0}^J (J-j) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \\ &- \sum_{j=0}^J (J-j) (N-j) \cdot q^{j} (1-q)^{N-1-j} \binom{N}{j} \Bigg) \\ =& \delta C \Bigg( \sum_{j=J+1}^N (j-J) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \\ &- \sum_{j=J+2}^{N+1} (j-1-J) (N+1-j) \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j-1} \Bigg) \\ &+ ( v- C ) \Bigg( \sum_{j=0}^J (J-j) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \\ &- \sum_{j=1}^{J+1} (J+1-j) (N+1-j) \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j-1} \Bigg) \\ =& \delta C \Bigg( \sum_{j=J+1}^N (j-J) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \\ &- \sum_{j=J+1}^N (j-1-J) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \Bigg) \\ &+ ( v- C ) \Bigg( \sum_{j=0}^J (J-j) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \\ &- \sum_{j=0}^J (J+1-j) j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \Bigg) \\ =& \delta C \Bigg( \sum_{j=J+1}^N j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} \Bigg) \\ &- ( v- C ) \Bigg( \sum_{j=0}^J j \cdot q^{j-1} (1-q)^{N-j} \binom{N}{j} + J \cdot q^{J-1} (1-q)^{N-J} \binom{N}{J} \Bigg) \end{align*}