I am trying to find optimal quantity for which I have to equate differentiation of Total Revenue Equation with Marginal cost. I dont know how to solve for x here. Differentiation works on expression type variable and returns the same, and solve() take numeric equation with only coefficient. I dont want to manually input coefficent.
TR = expression(Quantity * (40- 3*Quantity))
MR = D(TR,"Quantity")
Optimal_Quantity = solve(MR-MC) to get Q
The last line is pseudo code on what I want to achieve, Please help. I can manually enter the values, But wish to make it universal. MC = constant numeric value on RHS
I am not completely understanding but if you want to optimize a function, find that functions derivative then find the derivative's zeros.
Created on 2022-11-19 with reprex v2.0.2
Edit
To make the function
dTRmore general purpose, I have included an argumentFUN. Above it would only evaluateMR, it can now evaluate any function passed to it.The code below plots
dTRin a large range of values, from -10 to 100, hoping to catch negative and positive end points. Then, after drawing the horizontal axis, boxes the root between 20 and 30.Created on 2022-11-22 with reprex v2.0.2