tag:blogger.com,1999:blog-11295132.post3880470744869663438..comments2018-04-24T08:59:21.783-07:00Comments on A Neighborhood of Infinity: Vectors, Invariance, and Math APIsDan Piponihttps://plus.google.com/107913314994758123748noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-11295132.post-77440787634121403472009-10-13T08:41:39.674-07:002009-10-13T08:41:39.674-07:00This comment spells out the free theorem instantia...This comment spells out the free theorem instantiation in which invariance properties are free theorems.<br /><br />First, I do not think that the rotational invariance of (.+), (.*), dot and cross are free theorems. Rather, for all other operations made out of those primitives, the fact that it too is rotation invariant is a free theorem.<br /><br />With a class annotation like (Vector v =>), the free relation corresponding to the type v can be any relation as long as it satisfies the free theorems corresponding to the types of the class methods. In our case, we wish to use the relation (Rx == x'), which needs to satisfy the following requirements:<br /><br />R (x + y) == Rx + Ry<br />R (a * x) == a * Rx<br />dot x y == dot Rx Ry<br />R (cross x y) == cross Rx Ry<br /><br />Those requirements are specifically stating that the (.+), (.*), dot and cross primitives are rotation invariant.<br /><br />Now if those requirements are satisfied (which they are), we can compute the free relation corresponding to the right-hand side of (Vector v =>) and we will obtain a free theorem. With the f example at the end of the post, for example, the free theorem is<br /><br />map rotpair (f (x,y,a)) == f (Rx, Ry, a)<br />where<br /> rotpair (s, t) = (Rs, Rt)<br /><br />which, as desired, states that f is rotation invariant.gelisamhttps://www.blogger.com/profile/10619127479176568208noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-44684193930015179902009-10-12T14:27:00.237-07:002009-10-12T14:27:00.237-07:00Isn't this really just a distinction between l...Isn't this really just a distinction between linear versus non-linear transformations? I think as a matter of practicality, lots of people stick all sorts of vector operations into libraries but don't make the distinction that certain operations are most definitely *not* linear transformations. <br /><br />And there is probably a lot of misunderstanding among users of libraries as to what rules apply to linear or non-linear transformations. <br /><br />Rotation is a linear transformation and thus preserves vector addition and scalar multiplication. So you can do all sorts of stuff with it and the order of the operations doesn't really matter. <br /><br />The component-wise multiplication of vectors is not a linear transformation and so none of those rules apply. <br /><br />I think you are right, that the segregation of APIs makes some sense, but even more important is getting the user's of APIs to understand the distinctions between different types of transformations. (But maybe I'm missing your point and being too simplistic).Andrew Sackville-Westhttps://www.blogger.com/profile/01000548530750598012noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-84625122331005997212009-10-11T12:39:39.738-07:002009-10-11T12:39:39.738-07:00Amazing post as usual! I'll soon learn Haskell...Amazing post as usual! I'll soon learn Haskell just to try out your mind warping examples. :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11295132.post-79974231278042286502009-10-10T14:55:56.647-07:002009-10-10T14:55:56.647-07:00As I'm sure you well know, the geometric algeb...As I'm sure you well know, the geometric algebra and particularly the conformal geometric algebra makes it easier and clearer to recognize and maintain these invariants. For example, in any geometric algebra the distinction between a free vector and a normal vector is clear as normals are represented by tangent bivectors and which automatically transform appropriately under reflections. Similarly, the conformal geometric algebra distinguishes free vectors, tangent vectors, position vectors and normal "vectors" readily. Usually when I write my own 3D code, I make a Point type distinct from a Vector type, and also, Bivector, Spinor, and Pseudoscalar types.<br /><br />Any rotationally invariant function is a natural transformation between (products of) the inclusion of the category of vectors and orthogonal transformations into the category of vectors and general linear transformations (or more or less general categories, e.g. it could be the identity functor).<br /><br />Call the inclusion I, then g : I -> I means for a vector space V and an orthogonal transformation on it, R, we have g(IRv) = IRg(v).Derek Elkinsnoreply@blogger.com