# Grid with recurrence relation terms

I want to get the recurrence relation for several values of n in a grid form. At the moment I am using

RecurrenceTable[{a[n + 2] == (1 - n)/(n + 1) a[n], a[2] == a0, a[3] == 0}, a, {n, 2, 20}]


To get

{a0, 0, -(a0/3), 0, a0/5, 0, -(a0/7), 0, a0/9, 0, -(a0/11), 0, a0/13, 0, -(a0/15),
0, a0/17, 0, -(a0/19)}


But I need it with the values of $n$ in one column running from 2 to 20 with heading n and the above list as a second column with heading a[n]. I tried something funny but it failed horribly:

Grid[Table[{a0, 0, -(a0/3), 0, a0/5, 0, -(a0/7), 0, a0/9, 0, -(a0/11), 0,
a0/13, 0, -(a0/15), 0, a0/17, 0, -(a0/19)},
{i, {i, 2, 20}}
]
]


I think this does what you want.

list = RecurrenceTable[{a[n + 2] == (1 - n)/(n + 1) a[n], a[2] == a0, a[3] == 0},
a, {n, 2, 20}];

TableForm[{Range[2, 20], list}, TableHeadings -> {{"n", "a[n]"}}, TableDirections -> Row]


For Mathematica versions 10.0, 10.1 or 10.2 add the option TableAlignments -> Center to get around this bug:

• The specified setting for the option GridBoxOptions, RowAlignments cannot be used. Feb 16, 2016 at 17:28
• @rhermans Yes, which is what I need to look at. It appears to be a bug in TableForm. Nevertheless the output appears correct, no? Feb 16, 2016 at 17:30
• @rhermans Turns out it's a known bug I hadn't noticed until today: (95321) Feb 16, 2016 at 17:32
• You are correct. +1 Feb 16, 2016 at 17:35
• Thanks. Although it gives an error, it works. Feb 16, 2016 at 18:00