Wikipedia:Reference desk/Archives/Mathematics/2020 June 23

From Wikipedia, the free encyclopedia
Mathematics desk
< June 22 << May | June | Jul >> Current desk >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


June 23[edit]

Curve fitting[edit]

What mathematical shape fits the part of the southeast Mediterranean that looks like a curve best? Sagittarian Milky Way (talk) 17:57, 23 June 2020 (UTC)[reply]

The whole border of the Mediterranean is one very long curve. Given a precise specification of what should be approximated from where to where, it can be approximates to any desired precision by a mathematical shape. Without further constraints, the question has no answer. An example of a constrained problem could be: what elliptic arc offers the best approximation of the Mediterranean coastline from Tobruk to Alexandria. Even then, there are several reasonable candidates for measuring the goodness of fit (among which the little-known Hausdorff distance has good papers); different measures will produce different optimal fits.  --Lambiam 18:36, 23 June 2020 (UTC)[reply]
From before the bumpity bump near Haifa south till either the point in Sinai where the latitude stops decreasing or up to a few miles before that if that fits much better. I do not know if the best elliptic curve is better than the best parabola, y=x^z etc. if I did I would've only wondered about which ellipse. I'm not wondering about complex curves like polynomials with many terms, only relatively simple ones or ones commonly used for curve fitting (but not long equations like those polynomials). For fit I will say minimizing the maximum distance between a point on the coast and the nearest point on the curve, with the endpoints on the coast. I've always thought that part of the coast resembled something mathematical and not too "overfitted looking" and it's aesthetic to me and I wonder what it is. Sagittarian Milky Way (talk) 20:33, 23 June 2020 (UTC)[reply]
After smoothing out the tiny bumps and kinks along that stretch, so that you get a sleek slide down the coast, you obtain a swooshy curve for which the curvature changes very gradually and seemingly uniformly along the length of the curve. I guess this is the property that you find aesthetically pleasing, rather than this curve being representable by some particular simple mathematical shape. If the purpose is to describe the shape parsimoniously yet accurately, then splines are the tool of choice. Ellipses and parabolae are both conic sections; I bet you can get a reasonably good fit with a parabolic arc and a slightly better one with an elliptic arc. But perhaps some of the well-known spirals, such as the Archimedean spiral or the Euler spiral, will give an even better fit. You can also fiddle with the map projectionMercator, Lambert conformal conic, Werner, ... – each will give a different best fit. The main practical problem in trying to find a tight fit, other than the plethora of options, may be to obtain a digital file of the coordinates of that stretch of coastline.  --Lambiam 09:40, 24 June 2020 (UTC)[reply]
Can you do it on a sphere or ellipsoid? Are the simplish curve types all well-defined on a sphere or ellipsoid? How many points will probably be enough if collecting the points manually? (manually also makes sure there aren't database errors and allows human judgement on what shouldn't be included i.e. anything artificial-looking like piers, sand caught by jetty and so on) What's the most efficient way to space the points? Equal distance apart? Is spending time on getting more points better than spending extra seconds equalizing distance to the last point? Is x points as good as you can do at max practical satellite layer zoom better than x+y points to the nearest z feet? Best balance of point numerousness and accuracy that is. Or if say 102to 102.5 points very accurate, roughly evenly spaced is enough then I could just not care about quickest balance of count and accuracy and collect points as accurate as I can. Do you have a recommendation on best software to do this in on Windows, Android and website? (my phone is full) How do I move the origin and/or rotate the coordinate frame of the final equation to make the equation simplest? I was truant every millisecond the last 2.5 grades and a little before and only learned the boring side of school enough to get Ds and Cs so if I should've learned that in school this is why. Sagittarian Milky Way (talk) 17:39, 24 June 2020 (UTC)[reply]
That is a lot of questions. Curves on non-flat surfaces are not an extensively studied subject. It is, of course, possible to take a plane curve and apply an inverse map projection to get a curve on a sphere. The segment in question being rather small in comparison to the size of Earth (about 200 km on a radius of 6370 km, corresponding to a hump of less than 800m compared to a straight line between the end points), I don't see why one should bother. The ellipsoidal aspect of the shape of Earth is even less consequential. Take the local radius of curvature as a measure – which can be estimated by putting a coin or small circular lid so that the curve bends somewhat equidistantly around it and taking the distance of the coin centre to the curve. If the desired precision as a fraction of that radius is , then the distance between the points should locally not be larger than a fraction of of the radius. For example, let the desired precision be 1 mm . If the local radius of curvature is 120 mm, that corresponds to a relative precision of . The relative distance between successive points should then not exceed times the radius, or 0.25+ times 120 mm, which is slightly more than 3 mm. Equalizing distances is not important; not leaving large gaps between points is. So spend the time on keeping the largest distance small – and smaller where the curvature is high. I have no idea what available software could help with the optimizations; I am not at all familiar with Wolfram Mathematica and have no idea of its capabilities. If this was my personal project I'd just write the necessary programs from scratch. If you are going for a conic section defined by a formula of the form , you can do a translation to make the linear coefficients vanish, ending up with something of the form . A rotation can then get rid of the term. You can do this by substituting for and for , rewriting the resulting lhs in the form , in which the coefficient will be an expression involving , and then solving for . I don't think this is something you'd learn in high school. All together not something to do in a lost moment; your main reward after all the frustration may be that in the end you acquired some mathematical skill.  --Lambiam 21:20, 24 June 2020 (UTC)[reply]
Maybe it's easier to just type my points into something I can set to subtract a constant I can set from each x and a different constant from each y before pasting those points into the curve fitter, it might also be able to multiply each longitude by the cosine of (max lat+min lat)/2 which is needed for a reasonable conversation from geographic to Cartesian anyway. Sagittarian Milky Way (talk) 18:20, 25 June 2020 (UTC)[reply]
Subtracting a constant and multiplying by a constant both change the scale according to a linear function. That will not make the task in any way easier for curve fitting software. For plotting without too much distortion, you do indeed need to adjust the scales using the cosine of the latitude.  --Lambiam 20:39, 25 June 2020 (UTC)[reply]
It will make the task easier for someone with poor math skills like me to neither have to understand how to move the shape with equation surgery nor manually subtract latitudes and manually cosine corrected longitudes from each point before feeding into the curve fitter if I could just type it into a web form or software that's like the Single Instruction Multiple Data of data entry. And then copy those to paste into the curve fitter. If my uneducated guess of putting the Sinai endpoint of no slope at the origin is wrong for any of these equation types then trial and error to try to find the focus or whatever's the right point will be a pain in the ass without being able to try different offsets quickly. Or maybe I can still understand how to strip the positioning or rotation data from the equation if it's explained to me in something that's more English and less mathese. It's probably trivial in English or lower grade math. Sagittarian Milky Way (talk) 21:08, 25 June 2020 (UTC)[reply]
And you're right it might be a spiral. I always thought the curvature looks decreasing towards Haifa and one of the things I was picturing is apparently called a Euler spiral. I always wondered if the curvature would go to zero if continued and what the slope would be. Sagittarian Milky Way (talk) 21:21, 25 June 2020 (UTC)[reply]

The general subject of curve fitting falls under interpolation and numerical analysis. If you are willing to allow piecewise curves, a cubic spline interpolation of carefully chosen points would look great.--Jasper Deng (talk) 08:50, 25 June 2020 (UTC)[reply]

Even more useful would be specific techniques used in curve-fitting such as Fourier analysis (which can decompose curves into an arbitrary series of cyclic (sine) functions) and Taylor series (which can decompose curves into an arbitrary series of polynomial functions). Broadly speaking, whether using cyclic functions or polynomial functions, or some combination thereof, any arbitrary curve can be decomposed into a function, limited only be the tolerances of your approximation. If you wanted to write an equation to recreate a specific coastline, you just need to define how "close" you want the resulting function to be, then you can create it using these analytical tools. (see, also relevant here, the coastline paradox, which is a consequence of this property.) --Jayron32 19:24, 25 June 2020 (UTC)[reply]
This is similar to something I wondered in high school, whether you could approximate any island or obscenely asymmetrical squiggle with a billion turns (possibly excluding ones that cross themselves or have infinitely sharp corners or maybe even that too) to any accuracy with a single equation though it might be longer than a book. You're saying it can be done with a series of equations which is trivially obvious, even simple linear equations can have lines at any slope. If each piece of curve is a piece of a different conic section then how is that elegant, as accurate as it might be? Likewise I see astronomical squiggles approximated with things something like y=230.336787337888+3.7679243676768x-0.94647685735x**2+0.109866376458x**3 ... 0.00000000534747x**14 which is a single equation. I'm thinking a simple shape like a conic section or maybe y=x**a or y=a**x or those things with logs (if you translate and (if needed) rotate or reflect the shape to the right way) can still be very close which is more elegant and less unremarkable than simply brute forcing it with tons of terms or even multiple equations. Sagittarian Milky Way (talk) 20:30, 25 June 2020 (UTC)[reply]
Would a graph of the shoreline's curvature as a function of arc-length help identify the simple function most closely resembling the shoreline? -- ToE 01:30, 26 June 2020 (UTC)[reply]
In some special cases it would. Obviously, a constant curvature means a circular arc. If the curvature increases or decreases linearly with the arc-length, we have a segment of an Euler spiral. But for most simple curves the function that produces the curvature given the arc-length is not simple at all and not particularly recognizable from its shape.  --Lambiam 02:47, 26 June 2020 (UTC)[reply]
I took the Commons 1250×1600 px bitmap of the East coast of the Mediterranean and interpreted the coastline as a graph. Keeping pixels as the unit of measure, we can impose an coordinate system whose origin corresponds to (the southmost point along the coastline before it veers up again when moving to the West), with increasing to the East (just like ) and increasing to the North (contrary to ). Taking only the part from to I determined the best fit with a parabola which resulted in with a max deviation of – not a good fit. Allowing other exponents than gave a best fit for with a max deviation of – better, but still not very good.  --Lambiam 22:08, 26 June 2020 (UTC)[reply]
So maybe simple image editors and a curve fitter I found are enough, I remember Microsoft Paint or Gimp or something showed the x and y positions of the cursor, and they can edit Google Maps screenshots so the raw pixel coordinates are pre-adjusted. Sagittarian Milky Way (talk) 14:47, 27 June 2020 (UTC)[reply]
The prospects for a fit with an Euler spiral do not look good. A plot of estimated curvature versus estimated arc-length looks like a rollercoaster ride.  --Lambiam 17:45, 28 June 2020 (UTC)[reply]
Do any large sections look like something? Eyeballing it with a better map it looks like from the curvature change near Beersheba latitude to the bump at about Nazareth's latitude is the most consistent part. Sagittarian Milky Way (talk) 14:35, 29 June 2020 (UTC)[reply]
Not really. No substantive section of the plot looks linear. The part you identify is less wavy (lower amplitude, fewer bumps) but has no familiar shape – although it is reminiscent of the elephant swallowed by a boa.  --Lambiam 15:53, 29 June 2020 (UTC)[reply]
You might get more helpful answers if you explained why you are trying to do this (i.e., once you choose a curve that approximates the coastline, you will use that curve to ...). --JBL (talk) 17:05, 29 June 2020 (UTC)[reply]
Once you've found a proof of the Collatz conjecture, you will use that proof to ...  What about pursuing something because it is interesting, without an ulterior utilitarian goal?  --Lambiam 21:50, 29 June 2020 (UTC)[reply]
Evidently you can read minds, but as a mere professor of pure mathematics, I content myself with reading the words people write. --JBL (talk) 00:03, 30 June 2020 (UTC)[reply]
"I've always thought that part of the coast resembled something mathematical and not too 'overfitted looking' and it's aesthetic to me and I wonder what it is." ... "I'm thinking a simple shape like a conic section or maybe y=x**a or y=a**x ... can still be very close which is more elegant and less unremarkable than simply brute forcing it...". It just takes the ability to read texts to see there is no utilitarian goal here.  --Lambiam 09:41, 30 June 2020 (UTC)[reply]