f(x) having fixed significant digits in Table

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












Define function f



Clear[f, x];
f[x_] := 2^x;


N[ f[arg], #sig. digits]



data = Table[
N[Pi, n],
N[ f[N[Pi, n]], 10 ]
, n, 1, 8
];


Text gridding...



Text@Grid[Prepend[data, "x", "f(x)"],
Alignment -> Left,
Dividers -> Center, 2 -> True
]


beginarrayl
textx & textf(x) \
hline
3. & 0. \
3.1 & 9. \
3.14 & 8.8 \
3.142 & 8.82 \
3.1416 & 8.825 \
3.14159 & 8.8250 \
3.141593 & 8.82498 \
3.1415927 & 8.824978 \
endarray



How do I show the following instead?



beginarrayl
textx & textf(x) \
hline
3. & 8.000000 \
3.1 & 8.574188 \
3.14 & 8.815241 \
3.142 & 8.821353 \
3.1416 & 8.824411 \
3.14159 & 8.824962 \
3.141593 & 8.824974 \
3.1415927 & 8.824978 \
endarray










share|improve this question







New contributor




R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    4
    down vote

    favorite












    Define function f



    Clear[f, x];
    f[x_] := 2^x;


    N[ f[arg], #sig. digits]



    data = Table[
    N[Pi, n],
    N[ f[N[Pi, n]], 10 ]
    , n, 1, 8
    ];


    Text gridding...



    Text@Grid[Prepend[data, "x", "f(x)"],
    Alignment -> Left,
    Dividers -> Center, 2 -> True
    ]


    beginarrayl
    textx & textf(x) \
    hline
    3. & 0. \
    3.1 & 9. \
    3.14 & 8.8 \
    3.142 & 8.82 \
    3.1416 & 8.825 \
    3.14159 & 8.8250 \
    3.141593 & 8.82498 \
    3.1415927 & 8.824978 \
    endarray



    How do I show the following instead?



    beginarrayl
    textx & textf(x) \
    hline
    3. & 8.000000 \
    3.1 & 8.574188 \
    3.14 & 8.815241 \
    3.142 & 8.821353 \
    3.1416 & 8.824411 \
    3.14159 & 8.824962 \
    3.141593 & 8.824974 \
    3.1415927 & 8.824978 \
    endarray










    share|improve this question







    New contributor




    R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      Define function f



      Clear[f, x];
      f[x_] := 2^x;


      N[ f[arg], #sig. digits]



      data = Table[
      N[Pi, n],
      N[ f[N[Pi, n]], 10 ]
      , n, 1, 8
      ];


      Text gridding...



      Text@Grid[Prepend[data, "x", "f(x)"],
      Alignment -> Left,
      Dividers -> Center, 2 -> True
      ]


      beginarrayl
      textx & textf(x) \
      hline
      3. & 0. \
      3.1 & 9. \
      3.14 & 8.8 \
      3.142 & 8.82 \
      3.1416 & 8.825 \
      3.14159 & 8.8250 \
      3.141593 & 8.82498 \
      3.1415927 & 8.824978 \
      endarray



      How do I show the following instead?



      beginarrayl
      textx & textf(x) \
      hline
      3. & 8.000000 \
      3.1 & 8.574188 \
      3.14 & 8.815241 \
      3.142 & 8.821353 \
      3.1416 & 8.824411 \
      3.14159 & 8.824962 \
      3.141593 & 8.824974 \
      3.1415927 & 8.824978 \
      endarray










      share|improve this question







      New contributor




      R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      Define function f



      Clear[f, x];
      f[x_] := 2^x;


      N[ f[arg], #sig. digits]



      data = Table[
      N[Pi, n],
      N[ f[N[Pi, n]], 10 ]
      , n, 1, 8
      ];


      Text gridding...



      Text@Grid[Prepend[data, "x", "f(x)"],
      Alignment -> Left,
      Dividers -> Center, 2 -> True
      ]


      beginarrayl
      textx & textf(x) \
      hline
      3. & 0. \
      3.1 & 9. \
      3.14 & 8.8 \
      3.142 & 8.82 \
      3.1416 & 8.825 \
      3.14159 & 8.8250 \
      3.141593 & 8.82498 \
      3.1415927 & 8.824978 \
      endarray



      How do I show the following instead?



      beginarrayl
      textx & textf(x) \
      hline
      3. & 8.000000 \
      3.1 & 8.574188 \
      3.14 & 8.815241 \
      3.142 & 8.821353 \
      3.1416 & 8.824411 \
      3.14159 & 8.824962 \
      3.141593 & 8.824974 \
      3.1415927 & 8.824978 \
      endarray







      table






      share|improve this question







      New contributor




      R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Sep 9 at 2:39









      R5-D4

      211




      211




      New contributor




      R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      R5-D4 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          6
          down vote













          Using arbitrary precision arithmetic produces the 1st result you show because Mathematica normally does not show digits with no precision since they are just noise. However, if you are trying to show how having better and better rational approximations to π improves the approximation of $2^pi$, I suggest the following approach.



          data =
          With[x = π, n = 8,
          Table[
          With[u = Round[x, 10^-i], u, Round[f[u], 10^-i]] // N,
          i, 0, n]];
          TableForm[Map[NumberForm[#, 10, 8] &, data, 2],
          TableHeadings -> None, x, f[x]]


          table






          share|improve this answer



























            up vote
            2
            down vote













            It might take some additional formatting to get exactly what you're after, but this is a start. I acknowledge some things may be able to be made simpler.



            Clear[f, x];
            f[x_] := 2^x;
            data = N@Table[
            Table[10^(-j + 1), j, 1, i].RealDigits[N@Pi, 10, i][[1]], i,
            8] /. x_?NumericQ :> NumberForm[x, 8], f[x];

            Text@Grid[Prepend[data, "x", "f(x)"], Alignment -> Left,
            Dividers -> Center, 2 -> True]


            enter image description here






            share|improve this answer




















              Your Answer




              StackExchange.ifUsing("editor", function ()
              return StackExchange.using("mathjaxEditing", function ()
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
              );
              );
              , "mathjax-editing");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "387"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              R5-D4 is a new contributor. Be nice, and check out our Code of Conduct.









               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181533%2ffx-having-fixed-significant-digits-in-table%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              6
              down vote













              Using arbitrary precision arithmetic produces the 1st result you show because Mathematica normally does not show digits with no precision since they are just noise. However, if you are trying to show how having better and better rational approximations to π improves the approximation of $2^pi$, I suggest the following approach.



              data =
              With[x = π, n = 8,
              Table[
              With[u = Round[x, 10^-i], u, Round[f[u], 10^-i]] // N,
              i, 0, n]];
              TableForm[Map[NumberForm[#, 10, 8] &, data, 2],
              TableHeadings -> None, x, f[x]]


              table






              share|improve this answer
























                up vote
                6
                down vote













                Using arbitrary precision arithmetic produces the 1st result you show because Mathematica normally does not show digits with no precision since they are just noise. However, if you are trying to show how having better and better rational approximations to π improves the approximation of $2^pi$, I suggest the following approach.



                data =
                With[x = π, n = 8,
                Table[
                With[u = Round[x, 10^-i], u, Round[f[u], 10^-i]] // N,
                i, 0, n]];
                TableForm[Map[NumberForm[#, 10, 8] &, data, 2],
                TableHeadings -> None, x, f[x]]


                table






                share|improve this answer






















                  up vote
                  6
                  down vote










                  up vote
                  6
                  down vote









                  Using arbitrary precision arithmetic produces the 1st result you show because Mathematica normally does not show digits with no precision since they are just noise. However, if you are trying to show how having better and better rational approximations to π improves the approximation of $2^pi$, I suggest the following approach.



                  data =
                  With[x = π, n = 8,
                  Table[
                  With[u = Round[x, 10^-i], u, Round[f[u], 10^-i]] // N,
                  i, 0, n]];
                  TableForm[Map[NumberForm[#, 10, 8] &, data, 2],
                  TableHeadings -> None, x, f[x]]


                  table






                  share|improve this answer












                  Using arbitrary precision arithmetic produces the 1st result you show because Mathematica normally does not show digits with no precision since they are just noise. However, if you are trying to show how having better and better rational approximations to π improves the approximation of $2^pi$, I suggest the following approach.



                  data =
                  With[x = π, n = 8,
                  Table[
                  With[u = Round[x, 10^-i], u, Round[f[u], 10^-i]] // N,
                  i, 0, n]];
                  TableForm[Map[NumberForm[#, 10, 8] &, data, 2],
                  TableHeadings -> None, x, f[x]]


                  table







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 9 at 4:13









                  m_goldberg

                  81.8k869189




                  81.8k869189




















                      up vote
                      2
                      down vote













                      It might take some additional formatting to get exactly what you're after, but this is a start. I acknowledge some things may be able to be made simpler.



                      Clear[f, x];
                      f[x_] := 2^x;
                      data = N@Table[
                      Table[10^(-j + 1), j, 1, i].RealDigits[N@Pi, 10, i][[1]], i,
                      8] /. x_?NumericQ :> NumberForm[x, 8], f[x];

                      Text@Grid[Prepend[data, "x", "f(x)"], Alignment -> Left,
                      Dividers -> Center, 2 -> True]


                      enter image description here






                      share|improve this answer
























                        up vote
                        2
                        down vote













                        It might take some additional formatting to get exactly what you're after, but this is a start. I acknowledge some things may be able to be made simpler.



                        Clear[f, x];
                        f[x_] := 2^x;
                        data = N@Table[
                        Table[10^(-j + 1), j, 1, i].RealDigits[N@Pi, 10, i][[1]], i,
                        8] /. x_?NumericQ :> NumberForm[x, 8], f[x];

                        Text@Grid[Prepend[data, "x", "f(x)"], Alignment -> Left,
                        Dividers -> Center, 2 -> True]


                        enter image description here






                        share|improve this answer






















                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          It might take some additional formatting to get exactly what you're after, but this is a start. I acknowledge some things may be able to be made simpler.



                          Clear[f, x];
                          f[x_] := 2^x;
                          data = N@Table[
                          Table[10^(-j + 1), j, 1, i].RealDigits[N@Pi, 10, i][[1]], i,
                          8] /. x_?NumericQ :> NumberForm[x, 8], f[x];

                          Text@Grid[Prepend[data, "x", "f(x)"], Alignment -> Left,
                          Dividers -> Center, 2 -> True]


                          enter image description here






                          share|improve this answer












                          It might take some additional formatting to get exactly what you're after, but this is a start. I acknowledge some things may be able to be made simpler.



                          Clear[f, x];
                          f[x_] := 2^x;
                          data = N@Table[
                          Table[10^(-j + 1), j, 1, i].RealDigits[N@Pi, 10, i][[1]], i,
                          8] /. x_?NumericQ :> NumberForm[x, 8], f[x];

                          Text@Grid[Prepend[data, "x", "f(x)"], Alignment -> Left,
                          Dividers -> Center, 2 -> True]


                          enter image description here







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Sep 9 at 2:56









                          user6014

                          2,5721021




                          2,5721021




















                              R5-D4 is a new contributor. Be nice, and check out our Code of Conduct.









                               

                              draft saved


                              draft discarded


















                              R5-D4 is a new contributor. Be nice, and check out our Code of Conduct.












                              R5-D4 is a new contributor. Be nice, and check out our Code of Conduct.











                              R5-D4 is a new contributor. Be nice, and check out our Code of Conduct.













                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181533%2ffx-having-fixed-significant-digits-in-table%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              White Anglo-Saxon Protestant

                              Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                              One-line joke