This question was from the End-Semester question paper of the previous year of my Course on Wolfram Mathematica - Apparently when I try to code it, something is going wrong with respect to Precision - this is the question :
Numerically integrate the function f(x) [mentioned below in my code] over the limits 0.6 to twenty two different upper limits. The twenty two upper limits are to be generated from the number 0.7687079701073738466984: The sequence should be 0.7, 0.76, 0.768, 0.7687, … ,0.7687079701073738466984.
And this is my code :
ClearAll["Global`*"]
SetPrecision[$MachinePrecision, 200];
f[x_] := x*Sin[1/x^3];
lower = 0.6;
num = 0.7687079701073738466984;
lst = {};
For[i = 1, i <= 22, i++, AppendTo[lst, N[10^(-i)*Floor[10^i*num]]];]
lst
and this was the output I got :
{0.7, 0.76, 0.768, 0.7687, 0.7687, 0.768707, 0.768708, 0.768708,
0.768708, 0.768708, 0.768708, 0.768708, 0.768708, 0.768708, 0.768708,
0.768708, 0.768708, 0.768708, 0.768708, 0.768708, 0.768708, 0.768708}
Can someone please help me figure out where I'm going wrong?
N
. For exampleN[10^(-i)*Floor[10^i*num], 25]
$\endgroup${0.7000000000000000000000000, 0.7600000000000000000000000, \ 0.7680000000000000000000000, 0.7687000000000000000000000, \ 0.7687000000000000000000000, 0.7687070000000000000000000, \ 0.7687079000000000000000000, 0.7687079700000000000000000, \ 0.7687079700000000000000000, 0.7687079701000000000000000, \ 0.7687079701000000000000000, 0.7687079701070000000000000, \ 0.7687079701073000000000000, 0.7687079701073700000000000, \ 0.7687079701073730000000000, 0.7687079701073738000000000, \ 0.7687079701073738400000000, 0.7687079701073738460000000, \ 0.7687079701073738466000000, ...}
$\endgroup$