1
$\begingroup$

I want to create a table of values, and the values are defined recursively as follows: $$ b_{t,m} = \begin{cases} b_{t+1,m} + b_{t+1,m-1}\delta^{t-T} & \text{ if } t \in \{2,\ldots,T-1\} \text{ and } m \in \{2,\ldots,T-t+1\} \\ % 1 & \text{ if } t\in \{2,\ldots,T\} \text{ and } m = 1 \\ % 0 & \text{ otherwise } \end{cases} $$

I need to create the table for $t=\{1,\ldots,T\}$ and $m=\{1,\ldots,T\}$ I'm new to Mathematica, and trying to accomplish this by mapping a recursive function over a list. My current attempt is as follows:

Clear[capT, delta, indexTable, bFunc, bMat]
capT = 3;

bFunc[{t_Integer, 1}] /; 2 <= t <= capT = 1;

bFunc[{t_Integer, m_Integer}] /; 
  m < 1 || m > capT - t + 1 || ( 
    1 <= m <= capT - t + 1  && (t < 2 || t > capT - 1)) = 0;

bFunc[{t_Integer, m_Integer}]  /; 
  2 <= t <= capT - 1 && 2 <= m <= capT - t + 1 := 
 bFunc[{t, m}] = 
  bFunc[{t + 1, m}] + bFunc[{t + 1, m - 1}]*delta^(t - capT)

indexTable = Reverse[Table[{t, m}, {t, 1, capT, 1}, {m, 1, capT, 1}]];
bMat = Map[bFunc, indexTable, 2]

Which produces the following output

{bFunc[{1, 0, 0}], bFunc[{1, 1/delta, 0}], bFunc[{0, 0, 0}]}

I must be missing something. This approach partially works, because all the values I need are there, but they are wrapped inside of additional function calls. The output that I want to have would look like

{{1, 0, 0}, {1, 1/delta, 0}, {0, 0, 0}}

What am I not seeing?

$\endgroup$

closed as off-topic by march, m_goldberg, Bob Hanlon, Feyre, Edmund Feb 3 '17 at 21:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – march, m_goldberg, Bob Hanlon, Feyre, Edmund
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ You want to feed each of the ordered pairs of that list of lists (indexTable) to bfunc? Then: bMat = Map[bFunc, indexTable, {2}], because you want to Map only at Level 2. Without the braces, it tries to map at both levels 1 and 2. $\endgroup$ – march Feb 3 '17 at 19:52
  • $\begingroup$ yes! That was it. Thanks! $\endgroup$ – FalafelPita Feb 3 '17 at 19:53

Browse other questions tagged or ask your own question.