# Solve Lagrange-Function under specific constraints?

GROUPS:
 Hello everyone,I am working on my thesis and am currently checking whether my calculations are correct by using Mathematica. I extend a classical binary agency model, where a principal lets a agent fulfill tasks for him, by adding a third profit state x3. The principal cannot observe the agent so he must create financial rewards or incentives to motivate the agent to take the desired actions. The principal can only evaluate the outcome x (with x1 < x2 < x3), not the agent's level of effort, which can either be high (H) or low (L). The outcome and effort level are linked via different possibilities Phi, which sum up to 1 and lie between 0 and 1. The principal wants to maximize his expected profit Z and therefore uses different remuneration schemes (bonus or malus).I set up a Lagrange-Function, which needs to fulfill the Kuhn-Tucker constraints. The first derivative of Lagrangea3a after u1a and after u3a need to be 0. (u1a([Phi]H1 + [Phi]H2) + u3a[Phi]H3 <= vH + U and u1a([Phi]H1 + [Phi]H2) + u3a[Phi]H3 - vH <= u1a([Phi]L1 + [Phi]L2) + u3a[Phi]L3 - vL a (u1a ([Phi]H1 + [Phi]H2) + u3a [Phi]H3 - (vH + U)) and b (-vH + vL + u1a ([Phi]H1 + [Phi]H2) + u3a [Phi]H3 - u1a ([Phi]L1 + [Phi]L2) - u3a [Phi]L3) must equal 0 And a>=0 and b>=0 So how could I solve my Lagrange-function for the Lagrange variables a and b under the given conditions?Thank you so much!Mariana In[1]:= ClearAll Out[1]= ClearAll In[2]:= $Assumptions = 0 < \[Phi]H1 < \[Phi]H2 < \[Phi]H3 < 1$Assumptions = 0 < \[Phi]L1 > \[Phi]L2 > \[Phi]L3 < 1 $Assumptions = 0 < \[Phi]H1 < \[Phi]L1 < 1$Assumptions = 0 < \[Phi]L3 < \[Phi]H3 < 1 $Assumptions = 0 < vL < vH$Assumptions = vL != vH $Assumptions = a >= 0$Assumptions = b >= 0 Out[2]= 0 < \[Phi]H1 < \[Phi]H2 < \[Phi]H3 < 1 Out[3]= 0 < \[Phi]L1 && \[Phi]L1 > \[Phi]L2 > \[Phi]L3 && \[Phi]L3 < 1 Out[4]= 0 < \[Phi]H1 < \[Phi]L1 < 1 Out[5]= 0 < \[Phi]L3 < \[Phi]H3 < 1 Out[6]= 0 < vL < vH Out[7]= vL != vH Out[8]= a >= 0 Out[9]= b >= 0 In[10]:= Za3a[\[Phi]H1, \[Phi]H2, \[Phi]H3, x1, x2, x3, u1a, u3a] = \[Phi]H1*(x1 - u1a^2) + \[Phi]H2*(x2 - u1a^2) + \[Phi]H3*(x3 - u3a^2) Out[10]= (-u1a^2 + x1) \[Phi]H1 + (-u1a^2 + x2) \[Phi]H2 + (-u3a^2 + x3) \[Phi]H3 In[11]:= PCa = u1a*(\[Phi]H1 + \[Phi]H2) + u3a*\[Phi]H3 == vH + U ICa = u1a*(\[Phi]H1 + \[Phi]H2) + u3a*\[Phi]H3 - vH == u1a*(\[Phi]L1 + \[Phi]L2) + u3a*\[Phi]L3 - vL Out[11]= u1a (\[Phi]H1 + \[Phi]H2) + u3a \[Phi]H3 == U + vH Out[12]= -vH + u1a (\[Phi]H1 + \[Phi]H2) + u3a \[Phi]H3 == -vL + u1a (\[Phi]L1 + \[Phi]L2) + u3a \[Phi]L3 In[20]:= Lagrangea3a[\[Phi]H1, \[Phi]H2, \[Phi]H3, \[Phi]L1, \ \[Phi]L2, \[Phi]L3, x1, x2, x3, u1a, u3a, a, b] = (\[Phi]H1*u1a^2 + \[Phi]H2*u1a^2 + \[Phi]H3*u3a^2) - a (u1a (\[Phi]H1 + \[Phi]H2) + u3a \[Phi]H3 - (vH + U)) - b (u1a*(\[Phi]H1 + \[Phi]H2) + u3a*\[Phi]H3 - vH - (u1a*(\[Phi]L1 + \[Phi]L2) + u3a*\[Phi]L3 - vL)) Out[20]= u1a^2 \[Phi]H1 + u1a^2 \[Phi]H2 + u3a^2 \[Phi]H3 - a (-U - vH + u1a (\[Phi]H1 + \[Phi]H2) + u3a \[Phi]H3) - b (-vH + vL + u1a (\[Phi]H1 + \[Phi]H2) + u3a \[Phi]H3 - u1a (\[Phi]L1 + \[Phi]L2) - u3a \[Phi]L3) In[24]:= Solve[ Lagrangea3a[\[Phi]H1, \[Phi]H2, \[Phi]H3, \[Phi]L1, \[Phi]L2, \ \[Phi]L3, x1, x2, x3, u1a, u3a, a, b], {a, b}] During evaluation of In[24]:= Solve::naqs: u1a^2 \[Phi]H1+u1a^2 \[Phi]H2+u3a^2 \[Phi]H3-a (-U-vH+u1a (\[Phi]H1+\[Phi]H2)+u3a \[Phi]H3)-b (-vH+vL+u1a (\[Phi]H1+\[Phi]H2)+u3a \[Phi]H3-u1a (\[Phi]L1+\[Phi]L2)-u3a \[Phi]L3) is not a quantified system of equations and inequalities. >> Out[24]= Solve[ u1a^2 \[Phi]H1 + u1a^2 \[Phi]H2 + u3a^2 \[Phi]H3 - a (-U - vH + u1a (\[Phi]H1 + \[Phi]H2) + u3a \[Phi]H3) - b (-vH + vL + u1a (\[Phi]H1 + \[Phi]H2) + u3a \[Phi]H3 - u1a (\[Phi]L1 + \[Phi]L2) - u3a \[Phi]L3), {a, b}] 
 Mariana,You have multiple issues. You are not using Solve correctly. Solve takes a series of equations and solves for the variables. The equations are of the form expression == expression. you gave it a single expression. If you want the lagrangea3a equal to zero than you must enter it as expression == 0: Solve[Lagrangea3a[\[Phi]H1, \[Phi]H2, \[Phi]H3, \[Phi]L1, \[Phi]L2, \ \[Phi]L3, x1, x2, x3, u1a, u3a, a, b] == 0, {a, b}, Reals]  This will solve but you did not give enough information to solve for both a and b. I don't know what you want to do so I can't help here. you define Zaz3, PCa and PCb but never use them. (Maybe this is the reason you do not have enough information to find a and b). you define Lagrangea3a[] = expression and Za3a[] = expression. Are you trying to define a function? If so, both are syntactically incorrect. Functions should look like this: func[a_,b_,c_]:= a^2+b^2+c^3  Note the underscores for the pattern matching of the arguments and the := for the function definition. and are called like this: func[Phi1, Ph2,Phi3] I am not suggesting that you should define a function for this problem -- it probably does not warrant it. You probably just want assignments of the form lagrange = expression -- you do not need any arguments because you seem to always have the expressions with the same variables.This is a start...