The language of mathematics is old and heavily explored, so its vocabulary tends to align well with what is asked of it. But occasional holes do turn up when parts of it are borrowed into programming languages and used for purposes different from those they were developed for. I ran into one of these twice recently, for unrelated reasons, while writing vector arithmetic code. In both cases, I had vectors `a`

and `b`

, and needed the component of `a`

in the direction of `b`

— the projection of `a`

on `b`

, except that I needed it as a scalar. My vector library provided `norm`

, `project`

, `unit`

and `dot`

, so I had a choice of `norm (project a b)`

or `dot a (unit b)`

, neither of which is particularly clear.

A little googling reveals that while this operation isn't commonly taught, it is known to mathematicians, who call it the scalar resolute, by analogy to “vector resolute”, which is another name for the ordinary projection operation. It seems to me that I want it considerably more often than either `project`

or `dot`

, so it makes sense to include it in vector libraries. Unfortunately it has no common notation, and while one could be invented (`scalar-project`

? `along`

?), the operation is obscure enough that its would-be users might not recognize it by any name, because they wouldn't be looking for it.

Many uses of scalar resolute also want the component perpendicular to the base vector, i.e. `norm (a - (project a b))`

, because they're really about converting from one coordinate system to another. A vector library could directly support this with a `rotate`

or `rebase`

function. However, a glance through my code suggests this wouldn't be very useful, because the point of the transformation is to obtain the individual components, so they can be operated on as scalars. Producing another vector as an intermediate step would not greatly help clarity. So I think these are most convenient as separate functions:

```
along : (vector, vector) → scalar
along v b = norm (project v b)
across : (vector, vector) → scalar
across v b = norm (v - project v b)
```

Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information. R Programming Training in Bangalore

ReplyDeleteBest R Programming Training in Bangalore offered by myTectra. India's No.1 R Programming Training Institute. Classroom, Online and Corporate training in R Programming

ReplyDeleter programming training

Thanks for helping me to understand basic concepts. Thanks for your informative article. Java Training in Chennai | Pega Training in Chennai

ReplyDelete