If I evaluate brf[AAA, WWW]
there are no instances of AAA
or WWW
. This is because the definition,
brf[a_, w_] := ArgMax[{v, e >= 0, e <= 1, Uem > Uun}, e];
is a "literal" rewrite rule. It replaces the instances of a
and w
that literally appear in the (unevaluated) text ArgMax[{v, e >= 0, e <= 1, Uem > Uun}, e]
. However there are no symbols a
or w
present before it is evaluated. The a
and w
appear only when the RHS is evaluated, which happens after the literal replacement has finished. But I second Gianluca Gorni's suggestion that the plot looks like there were numerical issues.
If you wish not to write the RHS with a
and w
present, you could try to define brf
as follows:
brf[a0_, w0_] :=
Block[{a = a0, w = w0}, ArgMax[{v, e >= 0, e <= 1, Uem > Uun}, e]];
Note that Plot[]
and Table[]
effectively use Block[]
to give values to w
and a
respectively, so the functions almost work inside those commands. In the first plot, brf[w]
is evaluated when w
has been given a value by Plot[]
; so it works properly, more or less. I get an error from NMaximize
which you don't mention. In the second plot, brf[a, w]
is evaluate when Table[]
has given a
the value 0.9
but w
has no value. The result is then evaluated in Plot[]
after w
has been given a value. Maybe this works, maybe not; it may explain the difference. I couldn't track it down.
I would define brf[]
as follows:
brf // ClearAll;
brf[a0_?NumericQ, w0_?NumericQ] :=
Block[{a = a0, w = w0}, ArgMax[{v, e >= 0, e <= 1, Uem > Uun}, e]];
Or I would make the dependence of Uem
on w
etc. explicit (define it to be a function Uem[w,...]
).
See https://support.wolfram.com/12502 for a discussion. I don't know if the above fixes the plot because Plot[]
ran for several minutes, longer than it took to type this up. I wasn't sure when it would finish and had to move on to other things.