I'm trying to solve the first part of a Quantal Response Equilibrium (QRE).
I'm the situation of needing analytical solutions to a large system of equations (Logit-type). Solution will be up to a single parameter: I have, say, $n$ variables and $n-1$ equations.
Variables are in the form a[h]a[q]
, for example a1a3
, plus the parameter d
.
Each equation of the system of equations to be solved is in the following form:
a1a3 == Exp[d*pay[1, 3]]/Sum[Exp[d*pay[1, s]], {s, 0, qmax[1]}]
where pay[h, q]
and qmax[h]
are functions that I have previously defined.
My code appears to work up to the last line, where I receive an error message:
Solve::ivar: {a1a0,a1a1,a1a2....} is not a valid variable. >>
Here the code.
qmax[h_] := Floor[8 Sqrt[2] Sqrt[h]]
pay[h_, q_] :=
(32 - q^2/(4h))*(1/10)*
Sum[Sum[Symbol["a" <> ToString[t] <> "a" <> ToString[s]], {s, 0, (q-1)}]+
0.5*Symbol["a"<>ToString[t]<>"a" <>ToString[q]], {t, 1, 10}]
equations =
Table[
Table[
Symbol["a" <> ToString[h] <> "a" <> ToString[q]] ==
Exp[d*pay[h, q]]/Sum[Exp[d*pay[h, s]], {s, 0, qmax[h]}],
{q, 0, qmax[h]}],
{h, 1, 10}]
vars =
Table[Symbol["a" <> ToString[h] <> "a" <> ToString[q]], {h, 1, 10}, {q, 0,qmax[h]}]
Solve[{equations}, vars]
Edit
Setting a value for d
and using FindRoot
is perfectly fine for me, but I'm still not able to solve the problem.
vars
list generate by yourTable
is nested, whereasSolve
wants a flat list of variables. That's an easy fix:vars = Flatten @ Table[... rest of your code ...]
. You might have the same problem with your equations too. More in general, your problem seems like a challenge forSolve
to generate analytical solutions. Do you know that analytical solutions must exist for your equations? $\endgroup$equations
variable to see that it is correct and shaped as you expect; now it is a nested list, which you nest further by wrapping it in{}
withinSolve
, which I don't think you need. 2) A solution might exist, but it may not be possible to express it analytically, i.e. with a formula or equation, in which case you should use numerical solvers (e.g.FindRoot
) to get its value. $\endgroup$