Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.8K Views
|
5 Replies
|
5 Total Likes
View groups...
Share
Share this post:

How to initialize a list of floating point numbers with a precision higher than machine precision?

Posted 11 months ago

Hi, I have an apparently simple problem but cannot figure out how to solve it: I want to initialize a list of floating point numbers which have more significant digits than MachinePrecision, but unfortunately the result returned by Precision[] is always MachinePrecision. How to force the presence of more significant digits in the result? Using N[] in the initialization does not seem to help.

acoeffs={
0.56418958354775628695,
-0.015625,
0.00067409146187813363572,
-0.00003034259404800769274,
1.378193114316683932*10^-6};
Precision[acoeffs]

Leslaw

POSTED BY: Leslaw Bieniasz
5 Replies
Posted 11 months ago

SetPrecision does it:

numbers={
  0.56418958354775628695,
  -0.015625,
  0.00067409146187813363572,
  -0.00003034259404800769274,
  1.378193114316683932*10^-6
};

acoeffs = SetPrecision[numbers, 15]

Precision[acoeffs]
(* 15. *)

In[1]:= acoeffs
Out[1]= {0.564189583547756, -0.0156250000000000, \
0.000674091461878134, -0.0000303425940480077, 1.37819311431668*10^-6}
POSTED BY: Hans Milton

A vector is an object that you can specify up to a certain precision. If a component is uncertain, it make the whole vector uncertain. However, this is just my guess, I am not very expert in Mathematica numerics.

POSTED BY: Gianluca Gorni
Posted 11 months ago

I don't understand. What else is the "precision of the vector", if not the precision of its elements? Leslaw

POSTED BY: Leslaw Bieniasz
Posted 11 months ago

I'm also not an expert on numerics, but very generally we expect to only lose precision during computations, never gain it. So, at the very least we expect that the precision of an expression be no greater than the minimum precision of the numbers within it. So, for your vector, the minimum precision of the numbers within it is MachinePrecision. Granted, it may seem like a vector doesn't really have a precision, but what else would you suggest that its precision should be? If we were to apply some numeric computation to it that combined all the elements, we'd expect the resulting precision to not exceed the minimum precision of the elements. However I do think Mathematica will try to preserve as much precision as it can without losing correctness, so it might be able to "increase" precision of some numbers for some computations. But I'm way out of my depth here, so take it with a grain of salt.

Having said all of that, what is your actual problem that you're trying to solve?

POSTED BY: Eric Rimbey

With Precision[acoeffs] you get the precision of the vector. Try

Precision /@ acoeffs
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard