5
$\begingroup$

I have:

f[t_] := 4 t^3 - 3; g[t_] := -t^3 + 2;
TableForm[
 Table[{t, f[t], g[t]}, {t, 0, 2, .5}],
 TableHeadings -> {{}, {t, x, y}},
 TableAlignments -> Center]

Which gives the following output:

enter image description here

Is it possible to align each column on its decimal point? Further, is it possible to add zeros so that each number in the first column has one digit to the right of the decimal point, each number in the second column has one digit to the right of the decimal point and each number in the third column has three digits to the right of the decimal point?

$\endgroup$
1

1 Answer 1

9
$\begingroup$
TableForm[
 Table[{NumberForm[t, {Infinity, 1}], NumberForm[f[t], {Infinity, 1}], 
  NumberForm[g[t], {Infinity, 3}]}, {t, 0, 2, .5}],
 TableHeadings -> {{}, {t, x, y}}, TableAlignments -> "."]

enter image description here

$\endgroup$
1
  • $\begingroup$ A very nice answer. Just what I needed. $\endgroup$
    – David
    Commented Dec 14, 2014 at 2:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.