# The maximum output precision of InterpolatingFunction[]?

Posted 7 months ago
1206 Views
|
8 Replies
|
2 Total Likes
|
 Hello, I am using Interpolation[] to connect the data points in the attachment DATA.nb and trying with high precision(70). However it seems that Interpolation[] suppresses the precision of the table it acts on, so the values of the resulting interpolating function become all the same with 16 precision in the range(the notebook below shows the beginning and ending values):I searched for the precision option of it in Wolfram documentation center but found nothing. How can I refine the result of such interpolation? Thanks! Attachments: Answer
8 Replies
Sort By:
Posted 7 months ago
 Try using exact numbers Interpolation@Rationalize[data, 0] Answer
Posted 7 months ago
 Nice method, thank you! What if the InterpolatingFunction[] is given by NDSolve solution? Or similarly, just rationalize the equations first? Answer
Posted 6 months ago
 Dear Dr. Namjoshi! Here are two issues I found related to the InterpolatingFunction[] result obtained by NDSolve[], which I've tried my best to work out but still failed:First, since some of the solution is large and requires one to store manually, he can use the result without losing precision by means of % exactly referred to the output, while after copying the solution of interpolated function and paste it somewhere else, the value of the function becomes no longer as precise as the original output; the problem is, does it mean one can't totally store the data(to be used the other day after restarting MMA)? How can I store complete information of the solution?Second, sometimes I try to manually store the InterpolatingFunction[] obtained by NDSolve, however, clicking the storing button doesn't work. What's wrong? I guess the reason might be the lack of memory. Additionally referred to the first problem, is the data completely stored when storing button seems to work?These are the problems I've encountered, I'd be glad if you help me solve them, thank! Answer
Posted 6 months ago
 Hi 旭龙I rarely make use of the "Data not in notebook; Store now" feature. It can significantly increase the size of the notebook resulting in slow loading/saving time. If you want to save the results of computations for use later in a different session then take a look at Save and Get. e.g. SetDirectory[NotebookDirectory[]] iFunc = Interpolation@Rationalize[data, 0] Save["iFunc.wl", iFunc] Close notebook, quit kernel or restart Mathematica SetDirectory[NotebookDirectory[]] ClearAll@iFunc Get["iFunc.wl"] iFunc This will also work for persisting the solutions from NDSolve. The round-trip from Save to Get should not cause any loss of precision. If you find it does, it is a bug. e.g. you can try this ClearAll@iFunc Get["iFunc.wl"] iFuncNew = Interpolation@Rationalize[data, 0] iFunc == iFuncNew (* True *) Answer
Posted 6 months ago Answer
Posted 6 months ago
 Hi, Rohit! I trided what you told me last time. Though iFunc == iFuncNew gave True result, the sizes of them differed: 3.5M(initial) and 2.2M(New). Next are the screenshots:     The function SOMA[] is and 210418.nb here, Answer
Posted 6 months ago
 Hi 旭龙,That is strange. If you look at InputForm@iFunc and compare it with the file iFunc.wl (it is a text file) you will see that the InputForm includes a long list of numbers like 5.715581102622704*^11 at the end. I have no idea what those numbers are. What matters is that the expressions are identical. I would trust Equal more than some approximate number computed by the frontend.If you are still concerned, generate some random rational numbers within the domain of the interpolating function and evaluate both functions at that value and compare the result. Answer
Posted 5 months ago
 Hi Rohit, as your suggestion directed, I get some functions rationalized, but the solution of this NDSolve, still gives results that hasn't been rationalized, what can I do? Thanks. Answer