I've been working on creating tables of differences in MAA similar to the image below, but with a bit more detail:
I've written a function that will take an anonymous function, a range of values and some optional arguments to create the table:
differenceTable[f_: Function[{g}, g], range_List, n_: 3, diff_: 3, p_: 2] :=
Module[
{a = N[f /@ range, n]},
Grid[
{{"x"} ~ Join ~ {"f[x]"} ~ Join ~ (Table[Superscript[\[CapitalDelta], k], {k, 1, diff}]),
{Column[range, Center, 1]} ~ Join ~ (Column[#, Center, 1] & /@ (SetPrecision[#, p] & /@ diffList[a, diff + 1]))},
Spacings -> 2,
Dividers -> {{False, True}, {False, True}}
]
]
with,
diffList[x_List, n_] :=
Module[{d = Differences[x]}, {x} ~ Join ~diffList[d, n - 1]];
diffList[x_List, 1] := {x}
For example:
differenceTable[Sin[#] &, Range[10, 90, 10] Degree]
gives
Which is great. The problem I run into is that when the function values and the x values take on non-standard formatting (fractional notation and exponentials specifially) the spacing between rows is thrown off.
For example:
differenceTable[Sin[#] &, Range[Pi/18, Pi/2, Pi/18]]
gives:
I'm not sure how to fix this without eliminating the taper in the table, which I would like to keep. Does anyone know of a fix for this?
1.75
. $\endgroup$