Hi Jasvesta,
There are a couple of issues
Y[m_] := Max[ystar[m]]
If ystar[m]
returns multiple solutions then Max
will not return the rule with the largest RHS. e.g.
solutions = {{y -> 1}, {y -> 2}}
Max @ solutions
(* Max[y -> 1, y -> 2] *)
It will only work if there is one solution
solutions = {{y -> 1}}
Max @ solutions
(* y -> 1 *)
Change it to
Y[m_] := ystar[m] // MaximalBy[Last] // Extract[{1, 1}]
Since Y[m]
returns a Rule
, the following will not work because >
is not defined for a Rule
?H[f_, ?_, m_] := If[Y[m] > 0, ?1H[f, ?, m], ?0[f, ?, m]]
Change it to
?H[f_, ?_, m_] := If[Last@Y[m] > 0, ?1H[f, ?, m], ?0[f, ?, m]]
Then evaluating the TH
table gives
{{0, ?0[9.5493, 89., 0]}, {1, ?0[9.5493, 89., 1]},
{2, ?1H[9.5493, 89., 2]}, {3, ?1H[9.5493, 89., 3]},
{4, ?1H[9.5493, 89., 4]}, {5, ?0[9.5493, 89., 5]},
{6, ?0[9.5493, 89., 6]}, {7, ?0[9.5493, 89., 7]}}
Is that the result you expect?