If your cost and revenue functions are nonlinear, meaning that they have a changing slope, then you cannot use the formulas above to calculate the profit-maximizing output. Instead, you need to use calculus to find the derivative of the cost and revenue functions, and set them equal to each other. The derivative of a function is the rate of change of the function, and it represents the marginal value of the function. Derivative of Total Revenue = Marginal Revenue Derivative of Total Cost = Marginal Cost Marginal Revenue = Marginal Cost To solve for the profit-maximizing output, you need to find the value of the quantity that makes the equation true. You may need to use algebra, graphing, or numerical methods to find the solution. You can also use the second derivative test to check if the solution is a maximum or a minimum. The second derivative of a function is the rate of change of the derivative, and it represents the concavity of the function. Second Derivative of Total Revenue = Change in Marginal Revenue Second Derivative of Total Cost = Change in Marginal Cost If the second derivative of total revenue is negative, and the second derivative of total cost is positive, then the solution is a maximum. If the opposite is true, then the solution is a minimum. If both are zero, then the solution is a point of inflection, and you need to use other methods to determine if it is a maximum or a minimum.