# Calculating errors after curve fitting (linearizing) graphs

Tags:
1. Mar 5, 2016

### Orha

1. The problem statement, all variables and given/known data
I did a lab this week measuring periods of swings of a simple pendulum. We need to curve fit the equation T=k*l^n and we got ln(T)=n*ln(l)+ln(k), and we need to plot the data we collected into the linear graph, meaning out y axes is ln(T) and our x axes is ln(l). So far all is well and good, I took ln's of all my data and ploted it into the graph which is more or less linear.

My problem is that my errors are so small, one of them is 0.5*10^(-3) (=0.0005), that when I ln it I get -7.6. At the same time when I ln my data I get values between -0.05 and -0.8. looking at the ln graph I understand why this happens, but it doesn't make sense that my errors would be so unproportionate to my values (and much larger than them), and I am not sure it makes sense to have a negative error, does it? Does having a negative error have any significance? Because in my head all it does is change the signs from "value +- negative error" to "value -+ positive error") which would mean that in this case I have an error of 7.6 on a value that is 0.8 which again, makes no sense..

Do I just keep the errors as they were before?

I am sure I am doing something wrong, or at least understanding the results wrong, but I have no idea what I am suppose to do..

Any help would be greatly appreciated, thanks for your time!

2. Relevant equations
Non really, I changed T=k*l^n to ln(T)=n*ln(l)+ln(k) and am trying to fit the errors..

3. The attempt at a solution
I had a thought that maybe I need to do the opposite, and put my errors to an exponent, but I couldn't realy understand why that would be and in any case that didn't give me good results either as the error valuse I got were close to 1 which is still a problem..

2. Mar 5, 2016

### haruspex

What exactly do you mean by the 'error' here? I would have thought you meant the extent to which one of the ln(T) misses the straight line fit, but then I do not understand why you would be taking the log of that,

3. Mar 5, 2016

### Orha

Thanks for the response, sorry that I wasn't precise.
The error I mean is the one derived by the measurement tool. In this case we used a meter ruler to measure the length of the ruler and a stopwatch to measure the time. The error for the meter ruler is 0.5mm = 0.0005m and for the stopwatch it is 0.001s.
The problem is that the length measured are between 0.450m to 0.952m, and in order to curve fit the graph I need to take their ln, which is between -0.799m to -0.049m. If I take the ln of the error of the ruler (0.0005) I get -7.600m.

I don't know if I am doing something wrong, or just misunderstanding something, but it doesn't make sense to me that measuring something to be -0.049 could have an error of -7.600. Also, this only occured to me as I am writing this now, how can I claim to measure a negative number (after curve fitting)?

4. Mar 5, 2016

### haruspex

This still does not explain why you want to take the log of the error. If the error in a measurement x is +/-Δx then the logarithm is from ln(x-Δx) to ln(x+Δx).

5. Mar 5, 2016

### Orha

Ok, I think I am starting to understand.. but then now I really don't know what to do.
So you are saying the logarithm is from ln(x-Δx) to ln(x+Δx). So the values I calculated to be ln(x) are also wrong, as I need to split the ln(x-Δx) to ln(x+Δx) to look like y +-Δy (where y is some form of x, like ln(x)) in order to get the new values and errors, and not just take ln of the value to get my new value and ln of my error to get my new error.
But then I don't have any way to split up the ln in order to have my Δy separate from my y, so how can I get values and errors to plot?

Why do I get the feeling I am over complicating this?

6. Mar 5, 2016

### haruspex

What is the derivative of ln? Apply a Taylor expansion.

7. Mar 5, 2016

### Orha

Sorry if this is starting to get too much.. my intent really isn't to have you solve the problem for me, but I still not 100% sure of things, for reasons that have a bit less to do with physics maybe.
Using Taylor expansions I think I understand how you mean to solve it and what to generally do, and it makes sense but what bugs me is:

- This is the second lab of a first year undergraduate degree, semester started a month ago and we did not study Taylor series yet (we are very far from it).
- My lab instructor told me that in order to get the values I need to simply ln the values I had. My mistake was forgetting to ask him what to do with the errors during the lab session. After your explanation you convinced me that he might have been incorrect, but I would like to think he knows what he is talking about (I think he is doing his PhD).

I thank you so much for your time and effort, ideally I would ask my lab instructor these questions but they made it very clear to us that we can't as questions after exiting the lab and we must try to deal with it ourselves.

Is there maybe something else I can do that isn't a Taylor expansion?

8. Mar 5, 2016

### haruspex

Well, it's only the first couple of terms you need, which are pretty standard. $f(x+\Delta x) = f(x)+\Delta x f'(x)$ (I don't know the latex for approximately equals.) You can justify that simply by thinking about the slope of the ln curve at x.

9. Mar 5, 2016

### Orha

I have an Idea (I am sorry I am resisting your Taylor expansion, its just I know that it's not what they want us to do..)

If I calculate ln(x-Δx) and ln(x+Δx) and take the average that should bring me my new linearized x value, I will call it y, no? And then I can take that y value and subtract from it ln(x-Δx) and get my Δy,no?

I mean its not a fun thing to do for 20 different calculations, but it should work, shouldn't it?

10. Mar 5, 2016

### haruspex

Isn't that the same as $\frac 12 (ln(x+\Delta x)-ln(x-\Delta x))$?

11. Mar 5, 2016

### haruspex

Actually, I'm not sure why are are trying to find these error terms. Is it to plot error bars on the graph?

12. Mar 5, 2016

### Orha

You are right I I think, the value will be (ln(x+Δx)+ln(x-Δx))/2 and the error will be |(ln(x+Δx)+ln(x-Δx))/2-ln(x-Δx)|=|(ln(x+Δx)-ln(x-Δx))/2|
That saves calculations, thanks!

And yes, we need to say what the errors are for each measurement and then graph it with error bars.

13. Mar 5, 2016

### haruspex

Why would the value not still be just ln(x)? There is no requirement for the value to be half way between the error bars. You could just plot the error bars as ln(x+Δx) and ln(x-Δx).

14. Mar 5, 2016

### Orha

There isn't? How can the value not be half way between the error bars?
I assumed that it has to be in the middle and thus because ln(x+Δx) doesn't equal ln(x) + ln(Δx) then the value of the middle point would not be ln(x).
I thought I understood it but now that you are saying it doesn't have to be in the middle I think I understood it wrong.. Now what I understand is that I take ln of whatever I need and I get the result and I plot it, so the value x is now ln(x) and the errors are ln(x+Δx) and ln(x-Δx). (I realize this is exactly what you wrote).

This all makes sense for graphing, but then if the bottom and top error aren't the same then can I not write the value in the linearization in the shape of y+-Δy? do I not have a Δy? How do I write the value (and not graph it)?

15. Mar 5, 2016

### haruspex

Are you saying that you are also required to fill these numbers into a table, and you only have two entries per data point, one for the value and one for the error?

16. Mar 5, 2016

### Orha

Yes, I am also required to fill it into a table. Up until now (meaning in the previous lab, because this is only the second one we are doing) we have been told the format of a measurement is x±Δx so I assumed that both the upper and lower error bounds have to be the same..

17. Mar 6, 2016

### haruspex

In general, error bars can be asymmetric. Google that.
But in the present case the asymmetry will not be great, so you can fudge it to achieve symmetry. It probably will not matter much if you do what you described, adjusting the data point to be in the middle, but I would rather adjust the error bars slightly.

18. Mar 6, 2016

### Orha

Thanks so much! I am looking up uneven error bars and I also came across a pdf from the University of Washington which explains it fairly well..

You have been so helpful! Thanks again!