Plot a graphic of a function with domain of rational numbers?

I would like to present to my students of the functions Exp[x] near x=Sqrt[2], letting x vary only over the rational numbers. The reason is to be able to present to them the notion of limit and continous functions.

I’m not sure exactly what kind of output you would like to get here. The rational numbers are dense in the reals, so you would be plotting your function for 14/10 and 15/10, but then also for the midpoint 29/20, and the midpoint between that and the boundaries, and the midpoints between midpoints. Even so, that would only give a subset of the rationals equivalent to the set of binary fractions.

I guess you could use ListPlot, with the argument of ListPlot being some set of rational numbers, maybe even ordering them by where they appear in the famous snake-like path through the rationals

1/1 2/1 3/1
1/2 2/2 3/2
1/3 2/3 3/3

Then the code would be

ListPlot[ Table[{x,Exp[x]}, {x, {1,2,1/2,1/3,2/3,3/2,3}}] ]

Do you have a more detailed description of what you have in mind? Maybe with an example?

Explaining better: I want to give a sequence o rational numbers, x_n converging to sqrt[2] and I want to be able to plot in a nice visible way the correponding sequence of y_n=Exp[x_n];
Better yet a want to be able to plot y_n as a function of x_n in order to visualize where y_n is converging to.

Explaining better: I want to give a sequence o rational numbers, x_n converging to sqrt[2] and I want to be able to plot in a nice visible way the correponding sequence of y_n=Exp[x_n];
Better yet a want to be able to plot y_n as a function of x_n in order to visualize where y_n is converging to.

Your code above may work but I want to be able to get to a accuracy or precision level “as high as I wish” …

Okay, if you specifically want, not just rational numbers, but successively better rational approximations to Sqrt[2], then you could use

Table[Rationalize[N[Sqrt[2], n], 0], {n, 1, 20}]

To break this down

N[Sqrt[2], n]

returns a floating-point approximation of Sqrt[2] to ‘n’ digits.

Rationalize[..., 0]

returns the rational number closest to the input, with ‘0’ indicating the error tolerance.

Table[..., {n, 1, 20}]

returns the input for each value of ‘n’ from 1 to 20.

Tying it all together, we can put this list of rational numbers in as an argument to ListPlot:

vals=Table[Rationalize[N[Sqrt[2], n], 0], {n, 1, 10}];
ListPlot[
    Table[
        {x, Exp[x]}, 
        {x, vals}
    ]
]

If you’re new to the syntax of the Wolfram Language, there is a wide range of free resources at Wolfram Support Quick Answers: How can I get started with Wolfram Language?, and you can learn about each of the functions used here in the documentation center at Wolfram Language & System Documentation Center .

Thanks Duncan !
It kind of worked…but the problem is the the accuracy or the precision to make a visiable plotting with ListPlot…What do I have to do for the machine to distinguish number in 20th decimal place, in the plotting comand, I mean.

I am afraid I don’t really understand what you want. Perhaps this? The last points virtually coincide.

n = 5;
x[1] = 1;
x[n_] := 1/2 (x[n - 1] + 2/x[n - 1])
rn = Table[ x[j], {j, n}]  (* rational numbers converging to sqrt (2) *)
pp = {#, Exp[#]} & /@ rn
pp // N
ListPlot[pp, PlotStyle -> PointSize[.02]]
ListLinePlot[pp, Epilog -> {PointSize[.02], Point /@ pp}]

Thanks Hans.
Kind of it but I thought about using something like Manipulate to be able to zoom in near and near to be able to “see” the sequence of Exp[x_n] getting near and near the value of Exp[Sqrt[2]]

Perhaps your “zoom” can be achieved like this (I would be careful to make sure that a < b ; but in fact this seems not to be necessary )

p1[a_, b_] :=  ListLinePlot[pp, Epilog -> {PointSize[.02], Point /@ pp},   PlotRange -> {{a, b}, All}]

p1[1.4, 1.51]  (* check other values of a and b *)

or

Manipulate[
 p1[a, b],
 {a, 0, 1.4}, {b, .5, 2}]

Thanks for the hints guys.
I think my question really can be put as:
How can I Plot the graphic of f(x)=2^x, for instance, in the interval (N[Sqrt[2],n],N[Sqrt[2],n+1]) ?
take n=10 for example…

Perhaps like this

fx[n_] := Module[{a},
  a = Drop[RealDigits[N[Sqrt[2], n]][[1]], 1];
  1 + FromDigits[a]/10^Length[a]]

Then

n = 5;
x1 = fx[n]
x2 = fx[n + 1]
Plot[2^x, Evaluate[{x, x1, x2}]]

Thanks Hans,

Yet it does not work for n >12…
I need it to work for big n…20 or more…

As I understand your

fx[n_] equals to

Rationalize[N[Sqrt[2], n]]

except that you have a rational number…Yet, for big number the machine does not recognize
fx[n} and fx[n+1] as distinct numbers…

Yes, fx[n_] is basically equivalent to Rationalize, albeit a bit different.

What about

max=40;
fx[n_] := Module[{a},
  a = Take[RealDigits[SetPrecision[N[Sqrt[2]], max]][[1]], 2 ;; n];
  1 + FromDigits[a]/10^Length[a]]

But does that really make sense? For these small differences your function will be a straight line.