Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to zoom the interval arround $0.333\cdots$ with:

Manipulate[
 ListLinePlot[Table[{n, Sum[3/10^x, {x, n}]}, {n, 1, 20, 1}], 
  Mesh -> All, 
  PlotRange -> {{0, 20}, {(Sum[3/10^t, {t, g}] - 1/10^g), (Sum[3/10^t, {t, g}] + 1/
       10^g)}}], {g, 2, 20, 0.001}]

I know that I can use the interval (Sum[3/10^t, {t, g}] - 1/10^g), (Sum[3/10^t, {t, g}] + 1/10^g) because I've evaluated this:

Table[N[Sum[3/10^t, {t, n}] - 1/10^n, n], {n, 2, 10}]

Which yields:

(* {0.32, 0.332, 0.3332, 0.33332, 0.333332, 0.3333332, 0.33333332, 0.333333332, 0.3333333332} *)

And:

Table[N[Sum[3/10^t, {t, n}] + 1/10^n, n], {n, 2, 10}]

which yields:

(* {0.34, 0.334, 0.3334, 0.33334, 0.333334, 0.3333334, 0.33333334, 0.333333334, 0.3333333334} *)

But something weird is happening and the plot is jumping in a weird way. I have no clue of what's going on.

share|improve this question
    
Please don't use backticks + quote for code... use the markdown for code, which is indentation by 4 spaces. See the editing help for details. –  rm -rf Jan 5 at 19:06
add comment

3 Answers 3

The problem is that PlotRange is using $MachinePrecision:

GraphicsGrid@Partition[Table[
   prec = g;
   ListLinePlot[Table[{n, Sum[3/10^x, {x, n}]}, {n, 20}], Mesh -> All,
                PlotRange -> {{0, 20}, {N[1/3 - 1/10^prec, prec], 
                             N[1/3 + 1/10^prec, prec]}}, 
                PlotLabel -> "Precision = " <> ToString@g ], 
   {g, 4, Floor@$MachinePrecision, 1}], 4]

Mathematica graphics

share|improve this answer
add comment

The root of your problem is that the function you are using for the plot range (Sum[3/10^t, {t, g}] + 1/ 10^g) is not continuous. The sum adds a new term only when g crosses an integer boundary. Observe:

ListPlot[Table[(Sum[3/10^t, {t, g}] - 1/10^g), {g, 2.5, 3.5, 0.001}]]

If you use the analytic version of the sum:

(Sum[3/10^t, {t, g}] - 1/10^g) //FullSimplify

$\frac{10^{-g}}{3}(-4 + 10^g)$

Manipulate[ListLinePlot[Table[{n, Sum[3/10^x, {x, n}]}, {n, 1, 20, 1}], 
Mesh -> All, 
PlotRange -> {{0, 20}, {1/3 10^-g (-4 + 10^g), 
 1/3 10^-g (2 + 10^g)}}], {g, 2, 20, 0.1}]

works until g is about 14, which I think is when the limits of machine precision.

share|improve this answer
add comment

Try this to see if it is what you wanted. as I am was exactly sure. This only zooms in the y scale. You can make it also zoom in the x-scale to get closer look.

Manipulate[
 If[low >= high, low = high - 1];
 If[high <= low, high = low + 1];

 ListLinePlot[tbl, Mesh -> All, PlotRange -> {{0, 23}, {tbl[[low, 2]], tbl[[high, 2]]}},
  ImagePadding -> 50, ImageSize -> 400, PlotRangeClipping -> False]
 ,
 Grid[{
   {Control[{{low, 1, "lower limit?"}, 1, 19, 1}], Dynamic@low},
   {Control[{{high, 4, "upper limit?"}, 2, 20, 1}], Dynamic@high}
   }],
 SynchronousUpdating -> True,
 Initialization :>
  (
   tbl = Table[{n, Sum[3/10^x, {x, n}]}, {n, 1, 20, 1}];
   )
 ]

Mathematica graphics

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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