How to force evaluation of ArgMax before its output gets used in Solve? Background: I'm trying to solve for the Nash equilibrium in various games using Mathematica. As a minimal example, I tried a Cournot competition game that I can solve by hand. It should be simple: for each of two players use ArgMax to find the optimal action given some conjectured action by the other player, then equate the chosen action to the conjectured action for each player and use Solve to find the equilibrium actions. The code I tried is

$Assumptions = {p, qa, qb, qachosen, qbchosen} >= 0
p[qa_, qb_] := 1 - qa - qb
qachosen[qb_] = ArgMax[qa*p[qa, qb], qa]
qbchosen[qa_] = ArgMax[qb*p[qa, qb], qb]
Solve[{qachosen[qb] == qa, qbchosen[qa] == qb}, {qa, qb}]

The output gives the warning

Solve::dinv: "The expression ArgMax[qa (1-qa-qb),qa] involves unknowns in more than one argument, so inverse functions cannot be used"

and does not give the answer. In the above example, ideally qachosen would become the function (1-qb)/2, qbchosen would be (1-qa)/2 and the Solve output would be qa=1/3, qb=1/3. It seems forcing evaluation of ArgMax before applying Solve should do the trick, but Evaluate[Argmax[...]] returned the same thing as ArgMax[...].

  • $\begingroup$ You are using = where you want :=, but I cannot reproduce your error. $\endgroup$ – Xerxes Mar 5 '13 at 19:11
  • $\begingroup$ It works for me without error (8.0.4 linux) It's possible some old definitions are used try Clear[p,qa,qb,qachosen,qbchosen] and then run the code again $\endgroup$ – ssch Mar 5 '13 at 19:12
  • 1
    $\begingroup$ Same error occurs with ´:=´ and after using ´Clear´. I'm using Mathematica 6 with Windows XP. $\endgroup$ – Sander Heinsalu Mar 5 '13 at 19:14
  • $\begingroup$ It's ` to escape code and not ´ (notice they are pointing different ways) $\endgroup$ – ssch Mar 5 '13 at 19:16
  • 1
    $\begingroup$ Perhaps ArgMax was introduced in version 7 Does qa /. Last@Maximize[qa (1 - qa - qb), qa] give anything useful? If it does you can define ArgMax as Clear@ArgMax; Attributes[ArgMax] = {HoldAll}; ArgMax[expr_, vars_] := vars /. Last@Maximize[expr, vars] $\endgroup$ – ssch Mar 5 '13 at 19:27

ArgMax was introduced in version 7, but version 6 has Maximize so you can define ArgMax as:

Attributes[ArgMax] = {HoldAll};
ArgMax[expr_, vars_, domain___] := vars /. Last@Maximize[expr, vars, domain]

Taken from documentation which says:

ArgMax[...,vars,...] is effectively equivalent to vars/.Last[Maximize[...,vars,...].

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.