Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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[...].

share|improve this question
    
You are using = where you want :=, but I cannot reproduce your error. –  Xerxes Mar 5 '13 at 19:11
    
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 –  ssch Mar 5 '13 at 19:12
    
Same error occurs with ´:=´ and after using ´Clear´. I'm using Mathematica 6 with Windows XP. –  Sander Heinsalu Mar 5 '13 at 19:14
    
It's ` to escape code and not ´ (notice they are pointing different ways) –  ssch Mar 5 '13 at 19:16
1  
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] –  ssch Mar 5 '13 at 19:27
show 3 more comments

1 Answer 1

up vote 4 down vote accepted

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

Clear@ArgMax;
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,...].

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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