f(x) having fixed significant digits in Table
Clash 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
table
add a comment |Â
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
table
add a comment |Â
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
table
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
table
asked Sep 9 at 2:39
R5-D4
211
211
add a comment |Â
add a comment |Â
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]]
add a comment |Â
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]
add a comment |Â
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]]
add a comment |Â
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]]
add a comment |Â
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]]
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]]
answered Sep 9 at 4:13
m_goldberg
82.1k869190
82.1k869190
add a comment |Â
add a comment |Â
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]
add a comment |Â
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]
add a comment |Â
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]
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]
answered Sep 9 at 2:56
user6014
2,5721121
2,5721121
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password