In physics (I'm thinking of Taylor's Classical Mechanics or Griffith's Classical Electrodynamics) it is common to use "hat" vectors to denote unit vectors like $\hat{x}$ or $\hat{r}$. If I wanted to write in Mathematica (and still be able to use all the vector analysis functionality) using this notation I could evaluate
Overhat[x,^] = {1, 0};
Overhat[y,^] = {0, 1};
and then just let it sit in the background while I type equations in "unit vector" notation and Mathematica doesn't have any trouble. And if I wanted to make something more complicated, like with coordinate systems whose unit vectors change with position (such as polar) I could do this
Overhat[r][r_, θ_] = Cos[θ]Overhat[x] + Sin[θ]Overhat[y]
Overhat[θ][r_, θ_] = -Sin[θ]Overhat[x] + Cos[θ]Overhat[y]
And type in equations and Mathematica will reduce them down to the standard list form it uses for vectors.
Just to be clear, if you wanted to do this you would also need to write simple substitutions for $r$ and $\theta$ in terms of x and y (because you would likely be using those variables if you were using $\hat{r}$ and $\hat{\theta}$ otherwise the built vector analysis functions wouldn't work as expected). One could even write a function that would take a list like $\{x,y\}$ and write it in terms of such unit vectors, either as $x \hat{x} + y \hat{y}$ or as $r \hat{r}$.
But doing all this in a document would be an awful lot of effort for every computation in say polar coordinates: Write in the nice hat notation, convert to a list, compute say the vector Laplacian (or some other vector related operation), get the output as a list and convert it back to unit vector notation (knowing which coordinate system the output is in).
After that long introduction, what I'm asking is if there is a way to automate all of this. I've been trying to make a function called Vect (or something along those lines) that could store a vector internally and output it in any coordinate system (using the nice unit vector notation) which ones could also use to do vector derivatives and other operations. In Java we would call this a wrapper class for a list, because it is basically just a list but with added functionality wrapped around it. I'm envisioning something like Quanity (which is basically just a wrapper class for a number) or Around (which is basically just a wrapper class for probability distributions).
The thing that is tricky is that Mathematica uses lists to represent vectors, but lists themselves have no notion of coordinate system. If I evaluate $\{r,0,0\}$ for $r=5, \theta=\Pi/2$ I get a very different vector than $\{x,y\}$ with $x->5, y->0$ even though Mathematica sees them both as $\{5,0\}$. To use the vector analysis functions you pretty much need to keep track yourself what expression should be interpreted as being "in" what coordinate system and apply options accordingly.
So how would one automate this. You would need to use Holds on expression to get them to output using the unit vectors. And you would either need a function to output lists that the built in functions can use or you would need to create wrappers for all the built in functions.
I guess what I'm asking is, is this possible? What would be the general best approach? Am I way over complicating this?
I should point out that I have scored the Internet looking for packages that do this already and haven't been able to find any. None of the tensor calculus packages accomplish this (and are probably overkill anyway). VECT and Symbolic Computing looked at first to be promising but no cigar (as far as I can tell). And most other implementation of these sorts of things tend to be for coordinate free vectors which is clearly not what I'm going for :)
Sorry for the long question, I just wanted to remove any confusion as to what I'm kinda going for here. Any feedback is appreciated, even if it is just a little :)
OverHat[ ]
. It allows you to make the $\hat{x}$ "symbol". The "symbol" can be made using a 3-key sequence: x Ctrl-7 Shft-6, then hit the spacebar. ButOverHat[x]
is not exactly a symbol. You can assign values to it like a symbol, and even use it in calculations like a symbol, at least sometimes. You can'tClear
it, though, but you canRemove[ x ]
. It's good for comments and documentation, but the experts do not advocate using it in calculation. $\endgroup$Overhat[x]
depends formally onx
in the same wayf[x]
depends formally onx
. But I take it that $\hat x$ is the vector $(1,0)$ or $(1,0,0)$ and should be treated formally as independent of $x$. Note also the ambiguity in the definition of $\hat x$, which humans handle with no trouble after they learn the conventions.. $\endgroup$OverHat[r]
to evaluate to anything but what I set usingOverHat[r] = 5;
. For exampleOverHat[r] /. r -> 3
still returns 5. Is there a page where I can read more about the details of this sort of thing, I like using underscores and other symbols in MMA to make it look more like math on paper. I can see how this sort of thing could be dangerous. The Notations tutorials don't seem like they're about this sort of thing... but they might be? $\endgroup$