# Absolute uncertainty and error propagation with lists [closed]

I am trying to do some error propagation using mathematica. This is my second day using the program.

I am trying to take the derivative of a numerical function that is made up of the following lists.

f = Log[(currentI/Inot) + 1]
currentI = nfordata[[All, 2]]


{1.6*10^-10, 2.6*10^-10, 5.8*10^-10, 1.02*10^-9, 1.74*10^-9, 6.1*10^-9, 2.86*10^-8, 67/1000000000, 4.93*10^-7, 1.65*10^-6, 0.00001092, 0.0001216, 0.000628, 0.00134, 0.00358, \ 0.00591, 0.012696, 0.01901}

Inot = newnrev[[All]]


{2.01496*10^-10, 1.97487*10^-10, 1.91907*10^-10, 1.87144*10^-10, 1.82655*10^-10, 1.80109*10^-10, 1.92204*10^-10, 2.08256*10^-10, 2.60135*10^-10, 2.95558*10^-10, 3.27915*10^-10, 3.45166*10^-10, 3.47394*10^-10, 3.61041*10^-10, 4.10134*10^-10, 4.01291*10^-10, 3.60103*10^-10, 4.64213*10^-10}

errorI = {0.05*^-9, 0.01*^-9, 0.01*^-9, 0.01*^-9, 0.01*^-9, 0.15*^-9, 0.1*^-9, 0.1*^-9, 0.001*^-6, 0.01*^-6, 0.1*^-6, 0.2*^-6, 0.001*^-3, 0.01*^-3,0.01*^-3, 0.01*^-3, 0.01*^-3, 0.01*^-3}
errorInot = {0.01*^-9, 0.01*^-9, 0.01*^-9, 0.01*^-9, 0.01*^-9, 0.01*^-9, 0.01*^-9, 0.01*^-9, 0.1*^-9, 0.01*^-9, 0.01*^-9, 0.02*^-9, 0.02*^-9, 0.02*^-9, 0.02*^-9, 0.02*^-9, 0.02*^-9, 0.02*^-9}


This is so that I can find the uncertainty of the function f, at many points on my curve of the function.

Uncert =
N[Block[{currentI, errorI, Inot, errorInot},
Sqrt[(D[f, Inot]*errorInot)^2 + (D[f, currentI]*errorI)^2]]]


{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.} Is there any way to get non-zero values from this function?

## closed as off-topic by Oleksandr R., m_goldberg, Yves Klett, MarcoB, dr.blochwaveJun 14 '15 at 17:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Oleksandr R., m_goldberg, Yves Klett, MarcoB, dr.blochwave
If this question can be reworded to fit the rules in the help center, please edit the question.

• Use the commands in ErrorBarPlots. If the help pages are no help, I can post more suggestions. – xsk8rat Jun 14 '15 at 1:23
• Not directly relevant but maybe useful for you in the future: mathematica.stackexchange.com/questions/16793/… – Oleksandr R. Jun 14 '15 at 11:05
• I answered, but I also vote to close as a simple mistake. After tidying up your question, whatever problem you were having essentially vanished, so in light of that it is not really clear to me what you really sought to ask here. The good news is that your approach was (is) essentially correct. – Oleksandr R. Jun 14 '15 at 13:24
• So I have been reading the reference pages of each of these functions. I don't know exactly how the derivative function works. – Daniel Schulze Jun 14 '15 at 19:28
• If you define f by f[u_, v_] := Log[(u/v) + 1] (which I think you should do), and evaluate N[Block[{currentI, errorI, Inot, errorInot}, Sqrt[(D[f[currentI, Inot], Inot]*errorInot)^2 + (D[f[currentI, Inot], currentI]*errorI)^2]]] you will get {0.140047, 0.036138, ... 0.0555452, 0.0430869}, which I believe is what you are looking for. – m_goldberg Jun 15 '15 at 1:36

Initially I had simply wanted to tidy up your question and correct your code to make it easier to understand what you are asking for. However, in so doing, I ended up essentially solving the problem, since (as I understood it) there was not much to it after all. Therefore, I take the rather unconventional approach of restating your question in a corrected form (i.e., my edit as it was going to be) as an answer:

I am trying to do some error propagation using Mathematica. This is my second day using the program.

I am trying to take the derivative of a numerical function f:

f = Log[(currentI/Inot) + 1]


currentI and Inot are the following lists:

currentI = {1.6*10^-10, 2.6*10^-10, 5.8*10^-10, 1.02*10^-9, 1.74*10^-9,
6.1*10^-9, 2.86*10^-8, 67/1000000000, 4.93*10^-7, 1.65*10^-6,
0.00001092, 0.0001216, 0.000628, 0.00134, 0.00358, 0.00591, 0.012696, 0.01901}

Inot = {2.01496*10^-10, 1.97487*10^-10, 1.91907*10^-10, 1.87144*10^-10,
1.82655*10^-10, 1.80109*10^-10, 1.92204*10^-10, 2.08256*10^-10,
2.60135*10^-10, 2.95558*10^-10, 3.27915*10^-10, 3.45166*10^-10,
3.47394*10^-10, 3.61041*10^-10, 4.10134*10^-10, 4.01291*10^-10,
3.60103*10^-10, 4.64213*10^-10}


There are errors for each point in currentI and Inot as follows:

errorI = {...} (* a list of measured uncertainty values with the same length as currentI *)
errorInot = {...} (* same as above *)


Now I need to find the uncertainty of the function f at many points:

Uncert = Block[{currentI, errorI, Inot, errorInot},
Sqrt[(D[f, Inot]*errorInot)^2 + (D[f, currentI]*errorI)^2]
]


If anyone uses Mathematica for physics applications, I would appreciate your suggestions and any aid you can provide.

I also need some help putting error bars onto a plot of this data.

If you merely define errorI and errorInot, then Uncert will take the correct value automatically. The key here is that this is not a vector-valued function; it is merely a table of values calculated in the same way for different inputs. Hence, Mathematica's threading of numerical functions over lists is sufficient to deal with the latter.

As for the plot, you should consult the documentation and examples for the ErrorBarPlots package.

• However, when I run this code. the output gives: {0., 0., 0....} Is there a way I can tell the code to give more values? – Daniel Schulze Jun 14 '15 at 20:33
• Your problem is that you have defined currentI and Inot before f, and so the definition of f is not an expression but a list of values. A derivative with respect to a constant is, of course, zero. I had assumed that you had put the code in the order it appears in your post so as to avoid this issue. But maybe you were unaware of it. – Oleksandr R. Jun 14 '15 at 20:40
• To solve it: Block[{currentI, Inot}, f = Log[(currentI/Inot) + 1]]. Now it does not matter whether these have been defined or not. Alternatively, you could define f` as a function rather than an expression with some parts referring to other expressions. – Oleksandr R. Jun 14 '15 at 20:42
• I am trying to do the same computation with a different set of data. And I am still running into this zero problem – Daniel Schulze Jun 14 '15 at 23:25