The question is mathematical with underpinnings of economics so I will try to explain so that the question can be understood without any knowledge of economics.
I need to maximize dividends in two periods with respect to investment (I):
max D2
D2 = f(I) + (1-a)I
The caveat is that "a" is a random variable which takes on values 1 with probability p and 0 with probability (1-p)
I substitute in the value of D2 and differentiate with respect to Investment.
I wrote D2 = p*(f(I))* + (1-p){f(I)) + (1-a)I}
as a is 1 if probability is p so it drops out in the first part
When I differentiate with respect to I, I get the answer as: (f'(I)) + 1 - p
Is this correct? The reason I ask is economically it doesn't make much sense.
When you set the derivative to zero, you are finding a stationary point, not necessarily a maximum. Is $f(I)$ a concave function? If not you might be hitting a saddle point or a minimum
Also, when you plug-in the outcomes of the random variable, it shouldn’t appear in the expectation expression. You should have $\mathbb{E}[D_2] = pf(I) + (1-p)(f(I) + I)$