/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/
/* [ Created with wxMaxima version 11.04.0 ] */

/* [wxMaxima: comment start ]
Eric Doviak
26 April 2012

Math Methods 7025X
simple profit maximization
   [wxMaxima: comment end   ] */

/* [wxMaxima: comment start ]
profit = TR  - TC
profit = p*Q - w*L
Q = Q(L)

so maximize profit with respect to labor
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
Q(A,L) := A*sqrt(L) ;
TR(p,A,L) := p*''(Q(A,L)) ;
TC(w,L) := w*L ;
profit(p,w,A,L) := ''(TR(p,A,L)) - ''(TC(w,L)) ;
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
necessary condition for a maximum is that firms
hire labor up to the point where w = p*MPL
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
assume( p > 0 , w > 0 , A > 0 )$
print("at profit max, L = ",subst(solve(''(diff(profit(p,w,A,L),L))=0,L)[1],L))$
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
p*MPL is the marginal revenue from hiring another worker
w is the marginal cost of hiring another worker
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
MPL(A,L)  :=''(diff(Q(A,L),L));
MR(p,A,L) :=''(diff(TR(p,A,L),L));
MC(w,L)   :=''(diff(TC(w,L),L));
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
necessary condition for a maximum is that firms
hire labor up to the point where w = p*MPL
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
print("at profit max, L = ",subst(solve(MR(p,A,L)=MC(w,L),L)[1],L))$
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
sufficient condition for a maximum is:
(d MR / d L) < (d MC / d L)
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
print("")$
print("sufficient condition for a maximum:")$
print(("d MR"/"d L")," "," < ",("d MC"/"d L"))$
print(diff(MR(p,A,L),L)," "," < ",diff(MC(w,L),L))$
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
Assume:
  * p = 10 
  * w =  5
  * A = 10 
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
p:10$ w:5$ A:10$

print("")$
profit(L):=''(profit(p,w,A,L));
TR(L):=''(TR(p,A,L));
TC(L):=''(TC(w,L));

print("")$
MPL(L)  :=''(MPL(A,L));
MR(L) :=''(MR(p,A,L));
MC(L)   :=''(MC(w,L));

print("")$
print("at profit max, L = ",subst(solve(MR(L)=MC(L),L)[1],L))$
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
Let's plot: 
  * profit function
  * revenue and cost functions
  * marginal revenue and marginal cost functions
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
wxplot2d(profit(L),[L,0,500],[xlabel,"Labor"],[ylabel,"Profit"])$
wxplot2d([TR,TC],[L,0,500],[xlabel,"Labor"],[ylabel,"TR and TC"])$
wxplot2d([MR,MC],[L,5,500],[xlabel,"Labor"],[ylabel,"MR and MC"])$
/* [wxMaxima: input   end   ] */

/* Maxima can't load/batch files which end with a comment! */
"Created with wxMaxima"$
