Message Boards Message Boards

GROUPS:

The maximum output precision of InterpolatingFunction[]?

Posted 1 month ago
506 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:
8 Replies
Posted 1 month ago

Try using exact numbers

Interpolation@Rationalize[data, 0]
Posted 1 month ago

Nice method, thank you! What if the InterpolatingFunction[] is given by NDSolve solution? Or similarly, just rationalize the equations first?

Posted 26 days 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!

Posted 26 days 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 *)
Posted 26 days ago

OK, I‘ll try your timely advice, thanks!

Posted 17 days 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:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here The function SOMA[] is

and 210418.nb here,

Posted 17 days 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.

Posted 1 day 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.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract