Wikipedia:Reference desk/Archives/Mathematics/2010 June 15

= June 15 =

Data analysis help
Suppose there is a row of 8 posts; the distances between the posts are the same. I take a measuring tape and precisely measure the distance from goal post 2 to every other goal post. Now, I need to calculate the distance between the posts as precisely as possible.

How should the data be analyzed? Should I do a linear regression, plotting distance against "m", where "m" is the mth post from post #2? If so, m=1 has two measurements (one from the second post to the first, another from the second to the third); how do I handle that? Also, when plotting the graph in Excel, should I make the y-intercept 0?

If a linear regression isn't the most accurate approach, what is? BTW, I'm actually trying to analyze some diffraction data I've taken. This isn't homework; the diffraction experiment was done to find the wavelength of a laser, but the different analysis methods I've tried give different results, and worse, this difference is well outside experimental error! --Bowlhover (talk) 06:30, 15 June 2010 (UTC)
 * I think linear regression is probably the best approach. Certainly better than taking differences between successive measurements and averaging these differences, which would amount to using only the distance from the first to the last. I'd call your reference post from which you took the measurements post 0, then the other posts are numbered –1, 1, 2, 3, 4, 5, 6. Plot the displacement (vector) from the reference post against the post number, i.e. the displacement to post –1 is negative. You can probably force the y-intercept to be zero, but i think i'd want to know more about exactly how you took the measurements to be completely sure (presumably the lines have finite width — did you measure to and from the centre of each line or the edge? Do they all have the same width?) --Qwfp (talk) 07:36, 15 June 2010 (UTC)
 * When the precisions dyi are proportional to the measurements yi, you should take the logarithm before you do the linear regression: log(|yi|) = log(|i|)+k. Then you naturally have the y-intercept to be zero. Bo Jacoby (talk) 08:17, 15 June 2010 (UTC).


 * If you were careful to always measure from the same point of post 2 then you are trying to get the m in c+m*x+error, which is what linear regression is good at. The y intercept doesn't matter, the slope is what you want since c is the negative of the error for x=2. Dmcq (talk) 09:18, 15 June 2010 (UTC)
 * I think it's better if you describe the diffraction problem you have. The best course of action will crucially depend on a model for the measurement errors.
 * If you have several measurements of a quantity, each equal to the quantity plus an error which is normally distributed and independent of the other errors, then the optimal estimate will be a weighted average of the measurements, each weighted by the inverse of its error's variance. -- Meni Rosenfeld (talk) 09:30, 15 June 2010 (UTC)

To Meni & Qwfp: here's a pretty detailed description of my experiment. I shone a 532 nm laser onto a human hair so that the diffraction pattern appeared on a wall that's roughly perpendicular to the laser beam. I put a piece of paper on the wall so that the diffraction pattern was on the paper, and used a pencil to indicate where the minima were, and where the central bright region was. I repeated the experiment with a red laser whose wavelength I didn't know (and incidentally, isn't on the label). Then I used a plastic ruler to measure the distances of all the minima from the central region for both lasers. I measured from the center of the line I drew for the central minima to the center of the line for the minima in question. If this isn't the best approach, I can go back and remeasure the minima in a different way, though repeating the experiment itself would take quite a while. --Bowlhover (talk) 17:48, 15 June 2010 (UTC)


 * Instead of using a human hair, wouldn't it be easier to calibrate the wavelength of a laser by single slit diffraction? The relationships between the nulls and maxima from the central node are quite simple if you know the width of the slit. ~Amatulić (talk) 18:41, 15 June 2010 (UTC)


 * The outer lines will be further apart because the wall is flat. Dmcq (talk) 19:34, 15 June 2010 (UTC)


 * Assuming the posts or hairs aren't moving relative to each other, it sounds like your major source of error is in your measurement technique (the plastic ruler and pencil). Try repeating the experiment a few hundred times, then compute the mean and standard deviation as per usual.  Science is fun sometimes - usually it's just hard yakka like anything else.  Zoonoses (talk) 14:35, 18 June 2010 (UTC)

Getting gradient of a contour
I have three points on an unknown curve in 2d, and need to calculate the gradient at the middle point. My approach is to do a polynomial interpolation (second order, I think, if I have 3 points), solve the system of 3 equations where the points (xi,yi) are used in the equation of the parabola (ax^2 + bx + c = y), and get the gradient from the derivative (2ax+b=0) However, this assumes the parabolas used for the interpolation have to be symmetrical to the y axis.

(1) Should I just rotate everything so that the two side points will be on a horizontal line?

(2) Or are there simpler better methods, maybe a direct equation to get a gradient or a normal vector at one point just by giving its neighbors?

(3) If I have 5 consecutive points, a 5th degree polynomial would result, I think, in overfitting (Runge's phenomenon). Is there a better way to use the points which are only second neighbors of my middle point, to get a better interpolation/approximation? --131.188.3.21 (talk) 11:15, 15 June 2010 (UTC)


 * I'm just considering that the parabola might not be a good idea at all:

x (p2) x (p1)              x (p3)
 * In this case I'll get a very inaccurate solution, the tip of the parabola will be very far from the middle point p2, and even a linear interpolation and getting the median of the angle at p2 would do better (the median has the same direction as the "normal", the gradient would be just its rotation by 90 degrees). --131.188.3.21 (talk) 11:38, 15 June 2010 (UTC)
 * How do you know it's "inaccurate" if you don't know what the true curve is?
 * I can have reasonably many and dense samples, but having them too dense, I feel noise will have a very great effect. --131.188.3.21 (talk) 12:40, 15 June 2010 (UTC)
 * So there's noise! This completely changes the problem. You need to use as many points as possible and do least squares fitting. -- Meni Rosenfeld (talk) 12:48, 15 June 2010 (UTC)
 * I think that if you choose the minimum-curvature parabola as I suggest below, rather than the one with a vertical symmetry axis, the result will be more natural-looking (in particular, with a vertex closer to p2).
 * By "median" did you mean angle bisector? -- Meni Rosenfeld (talk) 12:04, 15 June 2010 (UTC)
 * Yes, I do. I'm sorry, but I'm not that good in English terminology. --131.188.3.21 (talk) 12:40, 15 June 2010 (UTC)
 * [ec] The problem is hopelessly underspecified. Any additional prior information you have about the curve or the points can completely alter the results.
 * It seems plausible that under some reasonable assumptions, a good interpolation will be the parabola for which the curvature at the vertex is minimal (a general parabola in the plane has 4 degrees of freedom; the points constrain 3; you can minimize the curvature over the fourth).
 * For 5 points, I'd use the conic section which passes through all points. -- Meni Rosenfeld (talk) 11:42, 15 June 2010 (UTC)
 * Thanks for the quick answer. The problem itself is that a number of sample points are given which should constitute a contour of some kind. I just need the gradients, normals etc. at those points. I think, for a reasonably smooth curve and samples close enough, 3 or 5 consecutive points would be enough, more would just result in overfitting. Yeah, a neural network to fit it for many points, with higher importance at the middle one and lower at the far ones would be a "perfect" solution, but I need a reasonably fast and simple one (at it has to be calculated maybe millions of times).
 * Do you mean by your suggestion with the parabola to rotate the parabola in the plane so that the "tip" of it will be at the middle point? --131.188.3.21 (talk) 11:50, 15 June 2010 (UTC)
 * hmm, and I think the conic section will not work if the curve is not convex. --131.188.3.21 (talk) 11:53, 15 June 2010 (UTC)


 * Is the position of each point known precisely, or are they measured with error? Error in one coordinate or both, in which case with equal errors or different errors? Are the points equally spaced in one coordinate or the other or in distance along the curve? Qwfp (talk) 11:58, 15 June 2010 (UTC)
 * They are not necessarily equally spaced, but by having many samples close to each other, I can choose points that are. I think I'll try out the exact parabola fitting for 3 points, and if it does not works adequately, I'll just approximately fit it to more than 3 points. --131.188.3.21 (talk) 12:40, 15 June 2010 (UTC)
 * [ec] For the oblivious setting, I think I have a simpler solution than my original suggestion: Interpolate with a circle passing through the 3 points. The center should be easy to calculate, and then the normals are just vectors from the center.
 * If you want something more advanced, splines is what you probably want. For more advice we do need some more details about your problem:
 * Where do the contours come from? Are they completely general, do they follow some simple algebraic formula, are they smooth (how smooth)?
 * How many points do you have per curve?
 * How fast is "fast"? Is that millions of calculations per second, per millisecond, per hour? Modern computers can do quite a lot millions of times per second.
 * How accurate should the results be?
 * Are the points known exactly or approximately?
 * Is there a significance to orientation, location and\or scale? Is an upright parabola as likely a priori as a lying down one? Is a circle as likely as a larger circle, or one that is centered on a distant point?
 * -- Meni Rosenfeld (talk) 12:44, 15 June 2010 (UTC)
 * The contours come from real world shapes, so there it not much a priori information about their orientation.
 * I think I'll try the following methods, in this order, if the accuracy of first one will not suit my needs:


 * 1. Fit a circle through 3 points
 * 2. Fit a parabola with minimum curvature through 3 points. (have 3 equations for the 3 points, + one for the curvature (what do you mean by that? Max radius of a circle at a point and two close neighboring points? I could not find how the term "curvature" is used for parabolas), but 5 unknowns from (Ax + By)^2 + Cx + Dy + E ... did I understood something wrong?  )
 * 3. Some numerical minimization for many points and a parabola or spline


 * Thanks for the ideas. --131.188.3.20 (talk) 13:06, 15 June 2010 (UTC)
 * Regarding parabolas: I mean Curvature in a non-parabola-specific sense. The curvature at the vertex of the parabola is inversely proportional to the distance between the vertex and the focus. I can't think of a reason the minimum-curvature parabola will necessarily have the middle point as a vertex, but I can't rule it out either. Anyway, finding this parabola is complicated and should give similar results to the circle, which is much simpler.
 * A parabola actually has 4 unknowns, because multiplying A, B, C, D and E by a constant gives the same parabola. -- Meni Rosenfeld (talk) 14:02, 15 June 2010 (UTC)


 * It sounds to me you are talking about a normal graph one value of y for each x like the way a hill goes up and down in vertical section rather than a 2d contour round a hill which forms a loop. For the graph a straightforwrd parabola would be the usual choice for three points though you might know better - for instance a sandpile might form a sharp triangle or you might know there is a lot of local variability in which case a flatter parabola which didn't go through the points might be an appropriate smoothening. There are articles on curve fitting and polynomial interpolation and others plus lots of packages to do it, but saying one interpolation is better than another is a difficult thing. Dmcq (talk) 14:51, 15 June 2010 (UTC)

Riddle (which I invented):
Try to define the constant-symbol "i" as an imaginary unit, using merely: the very constant-symbol "i" (having no interpretation given in advance), quantifiers (universal/existential), conjunction (no other connectives), parentheses, identity, addition, multiplication, and two (bound) variables only. The formula is to be true if and only if the constant-symbol "i" is interpreted as an imaginary unit. The answer will be given here within 2 days if nobody has preceded me by Thursday midnight. HOOTmag (talk) 21:35, 15 June 2010 (UTC)


 * Working on the basis that 1 - 1 + 1 - 1 + ... can be defined as 1/2, I say that i = (-1) * (1/-1) * (-1) * (1/-1) * ... -mattbuck (Talk) 21:45, 15 June 2010 (UTC)


 * Who has let you use the symbols "1", "/", "-" ? HOOTmag (talk) 21:49, 15 June 2010 (UTC)
 * It doesn't make sense anyway... A divergent series can be made to equal anything you like, pretty much, and I don't see how that relates to a divergent product. --Tango (talk) 22:03, 15 June 2010 (UTC)
 * Of course. HOOTmag (talk) 22:15, 15 June 2010 (UTC)


 * Your challenge isn't particularly clearly defined, but is something like this acceptable: $$\Complex=\R(i) \text{ such that } i\cdot i=x\in\R \text{ where } \forall y\in\R \,(x\cdot x\cdot y=y) \text{ and not } \forall y\in\R \,(x\cdot y=y)$$? --Tango (talk) 21:53, 15 June 2010 (UTC)
 * So why not simply: (y)(iiiiy=y) and not (y)(iiy=y)? HOOTmag (talk) 22:15, 15 June 2010 (UTC)
 * That is slicker, but of course it doesn't distinguish i from &minus;i. Neither does Tango's, of course.  In fact i cannot be defined in the language of the real numbers with plus and times, if the only constant symbols you're allowed are to be interpreted as reals.  That's because there's an automorphism of the complex numbers, in that language, that takes i to &minus;i. --Trovatore (talk) 22:28, 15 June 2010 (UTC)
 * Sorry, but I didn't talk about the "number" i, but rather about the "constant-symbol i", which should be defined as "an imaginary unit", i.e. you should define the constant-symbol "i" as an either imaginary unit. HOOTmag (talk) 22:44, 15 June 2010 (UTC)
 * If you have a constant symbol whose intended interpretation is the imaginary unit, then there's nothing left to do. The answer to your riddle is just i. --Trovatore (talk) 22:46, 15 June 2010 (UTC)
 * I didn't talk about a constant symbol whose "intended interpretation" is the imaginary unit, but rather about a constant symbol "to be defined" as an either imaginary unit. i.e. you have to find a formula (containing just the symbols mentioned in the riddle), which is a true formula iff the constant symbol "i" is interpreted as an imaginary unit. HOOTmag (talk) 22:54, 15 June 2010 (UTC)
 * Well, you weren't very specific about that. I don't think it's standard to refer to &minus;i as "an imaginary unit".  What you have is the imaginary unit, which is only i, not &minus;i. --Trovatore (talk) 22:56, 15 June 2010 (UTC)
 * When I talked about "an imaginary unit", I simply meant "a root of the equation: xx+1=0". If it hadn't been clear enough, then I've made it clear now. HOOTmag (talk) 23:06, 15 June 2010 (UTC)
 * You are, of course, right. You can't distinguish between i and -i. Any distinction is entirely arbitrary. I don't see why -i can't be considered an imaginary unit. It's a unit (in the number theory sense) in the Gaussian integers and it's imaginary. That seems like as good an interpretation of "imaginary unit" as any. --Tango (talk) 23:41, 15 June 2010 (UTC)
 * Depends on what you mean by "can't distinguish". There are precise senses in which you can't distinguish between i and &minus;i, but they assume some sort of limitation on the expressive power of the language you're using.  If you have a language that has a constant symbol for i, then it's easy to define i &mdash; it's already done.
 * By the way, HOOTmag, that's part of the problem with the way you expressed your riddle. If you have a constant symbol, then you don't need a definition for it.  If you want a definition, then what you want is a formula that accepts one free variable, not constant.
 * Tango, I think you have in mind some more philosophical issue about whether i is really well-specified when we talk about it in natural language. That's an interesting question, but doesn't really bear on whether &minus;i is "an" imaginary unit.  As far as I know, when people talk about "the" imaginary unit, they mean i. --Trovatore (talk) 05:10, 16 June 2010 (UTC)
 * I've been talking about the constant-symbol "i" not yet interpreted. Note that a given language is not necessarily associated with any interpretation, untill you determine the very interpretation. Actually, I'm talking about a language in which the constant-symbol "i" is the only symbol which has no interpretation given in advance, and the formula should "define" the meaning of "i", so that the formula is to be true if and only if one interprets the constant-symbol "i" as an imaginary unit. Anyways, if you are not satisfied with constant-symbols having no interpretation given in advance, then I let you replace the constant-symbol by a free variable (which would be the third variable in the formula, since the formula is allowed to have also two bound variables). HOOTmag (talk) 08:03, 16 June 2010 (UTC)
 * What I'm explaining to you is the standard usages in mathematical logic. You can go ahead and make up your own if you want, but it will impede communication. --Trovatore (talk) 08:11, 16 June 2010 (UTC)
 * Our controversy over the "standard usages" (or over whether a language is necessarily associated with any interpretation) is not the issue, because I've already let you replace the constant-symbol by a free variable (which would be the third variable in the formula, since the formula is allowed to have also two bound variables). HOOTmag (talk) 08:38, 16 June 2010 (UTC)
 * It's not about whether a language is ipso facto associated with an interpretation. It's about what constitutes a definition.  If you have a constant symbol i, then i is definable via the one-free-variable formula $$x=i$$, with free variable x.  That's really all there is to it.  I understand your rephrasing, and it's fine once you explain it.  But it isn't standard usage, period. --Trovatore (talk) 08:44, 16 June 2010 (UTC)
 * Again, our controversy over the "standard usages" is not the issue, because I've already let you replace the constant-symbol by a free variable (which would be the third variable in the formula, since the formula is allowed to have also two bound variables). HOOTmag (talk) 08:48, 16 June 2010 (UTC)
 * It is not "our" controversy. The usage I have explained is standard. --Trovatore (talk) 08:52, 16 June 2010 (UTC)
 * Our new controversy over whether the old controversy is ours or not - is not the issue, because I've already let you replace the constant-symbol by a free variable (which would be the third variable in the formula, since the formula is allowed to have also two bound variables). HOOTmag (talk) 09:17, 16 June 2010 (UTC)
 * Hmm? No, there's no controversy there. I already said that your rephrasing, along with the explanation of what you meant by "an imaginary unit", was fine.  --Trovatore (talk) 09:20, 16 June 2010 (UTC)
 * If there's no controversy, then my riddle is looking forward to your solution... HOOTmag (talk) 10:00, 16 June 2010 (UTC)
 * You could go with that, but I felt it was clearer to use x, and I was allowed two variables, so why not use them? I think it helps to make it explicit that i2 is real. --Tango (talk) 23:41, 15 June 2010 (UTC)
 * You've used three variables, because you have quantified the "y" twice, i.e. your y's are two different variables, and x is the third variable. Anyways, you have used the negation, which is not a legitimate connective. To make it clear, I let you only use: the very constant-symbol "i", quantifiers (universal/existential), conjunction (no other connectives), parentheses, identity, addition, multiplication, and two (bound) variables only. HOOTmag (talk) 08:03, 16 June 2010 (UTC)
 * You've edited the question. It did not say that. It said "connectives". Logical connective says (in the 2nd paragraph): "Also commonly, negation is considered to be a unary connective." You can't change the rules half-way through. (As for y being two different things, you have a point, but it's easy enough to re-write it to get around that. I'm not inclined to do that, though, after you've edited the original question.) --Tango (talk) 18:22, 16 June 2010 (UTC)
 * You're right, so you've solved the riddle according to its old (wrong) version. I was wrong and I apologize. Anyways, how would you re-write your suggestion to get around the two y's? HOOTmag (talk) 19:52, 16 June 2010 (UTC)
 * $$\Complex=\R(i) \text{ such that } i\cdot i=x\in\R \text{ where } \forall y\in\R-\{0\} \,(x\cdot x\cdot y=y \text{ and not } x\cdot y=y)$$ --Tango (talk) 20:36, 16 June 2010 (UTC)
 * Who has let you use the zero? The permitted symbols don't contain it. HOOTmag (talk) 21:39, 16 June 2010 (UTC)
 * You didn't explicitly say I could use $$\R$$, either, but if I'm using bound variables you've got to let me bind them. If you like, I can remove the - {0} bit and add "or y+y=y" to the bit in brackets. --Tango (talk) 22:23, 16 June 2010 (UTC)
 * I've provided a detailed list of symbols, none of which is the symbol $$\R$$, so you couldn't have used this symbol either. Anyways, now I understand how you can use only one "y" (provided that the list of permitted connectives is unlimited). HOOTmag (talk) 23:33, 16 June 2010 (UTC)
 * Take i to be the Pauli matrix sigma_x and take the identity to be the 2 by 2 identity matrix. Count Iblis (talk) 02:48, 16 June 2010 (UTC)
 * I'm looking for a formula which uses very specific symbols, but you haven't supplied such a formula yet. HOOTmag (talk) 08:03, 16 June 2010 (UTC)
 * I see! Also I made a stupid error anyway, as sigma_x^2 = 1. I should ave writen down the matrix which has a 1 and a minus 1 on the anti-diagonal. Count Iblis (talk) 14:04, 16 June 2010 (UTC)
 * As a Wikipedian my answer is
 * constant i = Imaginary unit
 * The problem I see with the question is that one has to assume the imaginary numbers and the various axioms relating to them in the first place if one is going to define i. In which case one might as well write something like i = (0,1) in the complex numbers. Dmcq (talk) 09:34, 16 June 2010 (UTC)
 * I've been talking about the constant-symbol "i" not yet interpreted. Note that a given language is not necessarily associated with any interpretation, untill you determine the very interpretation. Actually, I'm talking about a language in which the constant-symbol "i" is the only symbol which has no interpretation given in advance, and the formula should "define" the meaning of "i", so that the formula is to be true if and only if one interprets the constant-symbol "i" as an imaginary unit. Anyways, if you are not satisfied with constant-symbols having no interpretation given in advance, then I let you replace the constant-symbol by a free variable (which would be the third variable in the formula, since the formula is allowed to have also two bound variables). So, the premitted symbols will be as follows: the free variable "i", quantifiers (universal/existential), conjunction (no other connectives), parentheses, identity, addition, multiplication, and two bound variables only. Note that no usage of "1"/"0" is permitted, Nor is the comma-symbol "," permitted. HOOTmag (talk) 10:00, 16 June 2010 (UTC)

Here's one with no connectives and only one quantifier: $$\forall x\,(i\cdot i\cdot x+x+x=x)$$.—Emil J. 10:04, 16 June 2010 (UTC)
 * Great! I haven't thought about that! Thank you Emil. HOOTmag (talk) 10:12, 16 June 2010 (UTC)

And this one does not meet the specs because of negation, but it is quantifier-free: $$i\cdot i\cdot i+i+i=i\land i+i\ne i$$.—Emil J. 10:28, 16 June 2010 (UTC)
 * I don't think either of those is sufficient. They don't specify that i2 is real, which I think is a key point. Otherwise we could be talking about any number of mathematical objects. There are matrices that satisfy those equations, for instance. $$1\in\Z_2$$ satisfies them. I could probably think of plenty of others given some time. --Tango (talk) 18:31, 16 June 2010 (UTC)
 * The domain of discourse is the set of complex numbers (I forgot to indicate that), so "i" must be a complex number. HOOTmag (talk) 19:52, 16 June 2010 (UTC)
 * That's a big thing to forget. If you've already defined the complex numbers, I'm not sure what the point is of defining i. You must have already done it, or you wouldn't know what "complex numbers" means. --Tango (talk) 20:30, 16 June 2010 (UTC)
 * Oh, I'm sure you haven't figured out what I'd meant by my original riddle (you're innocent of course; it's me who'd had to put things clearer). Given the set of complex numbers as the domain of discourse, I'd been looking for a formula which uses the permitted symbols only, and which is true if and only if the constant-symbol "i" is interpreted as an imaginary unit. Note that Emil did solve this riddle. HOOTmag (talk) 21:39, 16 June 2010 (UTC)
 * Nice answers to a nice riddle -but the challenging problem now is how to put the question so as to be pedantic-proof ;-) --pm a  22:09, 16 June 2010 (UTC)
 * You must be new here: Welcome to the Wikipedia Mathematics Reference Desk! --Tango (talk) 22:25, 16 June 2010 (UTC)
 * :-) --pm a 20:42, 18 June 2010 (UTC)
 * A proof? Oh dear no, that would be WP:OR ;-) Dmcq (talk) 22:32, 16 June 2010 (UTC)
 * That's not particularly challenging;) The question was to find a formula with one free variable in first-order logic with equality using at most two quantifiers, no parameters, and no connectives besides conjunction, which defines {i, −i} in the structure $$(\mathbb C,+,\cdot)$$.—Emil J. 13:19, 17 June 2010 (UTC)
 * well, now the challenging problem is finding a pedantic objection to this --pm a 20:42, 18 June 2010 (UTC)