I'm working in a (Economics) problem where I want to add two concave (profit) functions in order to maximize them together through one variable (quantity). My problem is that one of the two functions shouldn't take negative values. I've built it as to take either the result of the function or 0, with Piecewise.
Afterwards, when I derive the added profit function, I get a doubled expression, that takes in consideration the two pieces of the piecewise equation. However, when I Solve that result equal to 0, I get nothing. I could do it manually, but the exercice goes further and the inability to restrain the function to be positive makes the results wrong (a negative price is keeping the firm from getting the quantity that would otherwise maximize both profits together).
p1 = Piecewise[{{0.8 - q,0.8 - q1>0}}];
p2 = 1 - q;
profit1 = (p1) * \[Gamma] * q;
profit2 = (p2 - cost) * q;
totalprofits = profit1 + profit2
dq = D[totalprofits, q]
Solve[dq == 0, q]
Thanks!