1
$\begingroup$

So I have a really sample task i would love to solve without things getting overly (and unnecessarily) complex.

I have a list of imported data coming from some instrument measurements in the form:

{1.23694*10^-6, 5.27894*10^-6, 6.07567*10^-7, ...}

I want to create an associated list containing the instrumental error which is obtainable from the above just by taking half of the flooring to the last digit. This means that the list of number I'm looking for the above will look as follows:

{5*10^-12, 5*10^-12, 5*10^-13,..}

I cannot find a simple solution to this trivial problem inside of Mathematica.

Identifying the number of decimal digits as they are imported and the order of magnitude would be enough but I cannot get the former. Stuff I've checked without results: RealDigits[], Precision[], Accuracy[]. Anyone care to help?

$\endgroup$
3
  • $\begingroup$ What do you want to happen with 1.23450*10^-6 (number ending in zero)? If the error should be 5*10^-12, then you need to import these numbers as strings, not numbers, or else the trailing zero will be forgotten. $\endgroup$
    – Roman
    May 31 '19 at 11:30
  • 2
    $\begingroup$ Your numbers all have exactly five digits after the decimal point. Can you guarantee that that's always the case? If yes, then 5*10^(Floor[Log[10,x]]-6) could work. $\endgroup$
    – Roman
    May 31 '19 at 11:30
  • $\begingroup$ @Roman thanks you Roman, i did not notice that :). $\endgroup$
    – deppep
    May 31 '19 at 12:35
2
$\begingroup$

As written in the comment above,

data = {1.23694*10^-6, 5.27894*10^-6, 6.07567*10^-7};
errorbars = 5*10^-6 * 10^Floor[Log[10, data]]

{1/200000000000, 1/200000000000, 1/2000000000000}

N[errorbars]

{5.*10^-12, 5.*10^-12, 5.*10^-13}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.