The cost of keeping a unit of inventory is a.

The cost of being short a unit is b.

b>a

The expected demand is normally distributed with mean m and std. dev. c.

I'm trying to find a formula for the optimum amount of inventory.

I'm currently plugging in values for q in the following formula:

aq+b*Integral of(normal distribution*(x-q)) from q to infinite

q is the inventory in excess of the expected demand.

Is this correct? If so, what would the derivative of this formula be so I can find the maximum.