# Center of mass

If you have seen the freely available Paul's online math notes and more specifically "calculus 2", you have probably noticed the nice formulas about the center of mass of an object. The idea that the boundaries of an object can be determined by functions which intersect is quite interesting, because the functions can be non-trivial and they can be composed of many simpler parts which add something unique to the behavaior of the whole. I think that the Wolfram Demonstrations Project illustrates particularly well what is possible with well-chosen functions (which makes them a design tool). The center of mass is also called a centroid and is also frequently computed in the variants of the k-means algorithm which is used to cluster datasets. That is, by updating a centroid, we understand to which cluster that data belongs.

This means that finding the center of mass of an object is potentially a recurring problem. It is probably a good idea to try to automate anything that we discover more than once. For instance, computing integrals manually can be time-consuming and error-prone. We already have the software to make things work in a more general way. Just by changing the functions in a couple of lines of code, we need to be able to see an update, which shows in which points they intersect, what kind of shape they form, where the new center of mass falls. The manual examples we find can be used to evaluate whether our code performs correctly and to see whether its behavior would be useful in variety of cases.

Here are some functions I tested while trying to understand this: Not all functions will intersect in the [0,1] range by default, but fortunately, this is something we can adjust. In some cases, for no obvious reason, the integration routine may fail, giving us misleading results (like zero). For instance, having a factor of ½ or even converting it to a float value did exactly this in my case. But when changing ½ to 0.5, the integration routine suddenly worked again. Small surprises like this can take some time to fix, but when we are done, the result is pleasing. And it will work for any function we define in the future.

As a final thought, I'd like to add a bit more about formulas. They are nice, but we are frequently trying to use them as quick fixes, which is not optimal. We learn a new formula and immediately think that we are ready to use it. A deeper understanding of the situations in which it would be great to use it would be nice to have. A single formula that can't be connected in any way to other formulas or lead to a useful line of thought may have less value that a collection of formulas that can be mixed together in interesting ways to discover more about the things we examine. We rarely write complex mathematical formulas on a single line; although this is possible, composing a formula in smaller chunks enables us to understand better what each part means. In the context of a geometrical problem, it can be related to scaling, translation, rotation or something else. A bigger formula is therefore built incrementally from smaller ones, which point to various parts from it. Allowing for the paths that the small formulas allow, reveals new ideas that we simply wouldn't come to if we tried to define everything at once.

bit.ly/1Fncq9t