# Command for vector dot with some power

So what I am trying to type is the square of the derivative of vector x. I tried \dot{vec{x}}^{\,2} as well as \dot{\vec{x}^2}, but the outputs came out to be very offset. Is there a correct way to do this?

The code I used is:

$$L=\frac{1}{2} m \dot{\vec{x^2}}$$


which give me

• One reason more for not using the arrow for vectors. – egreg Dec 7 '18 at 8:46

I'd probably do

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$L=\frac{1}{2} m \Dot{\vec{x}}^2$$
\end{document}


because the Lagrange function is a function of the square of the time derivative of x (and not the time derivative of the square of x).

• That's what I wanted to write, but did not know how to. Thanks. – Kane Billiot Dec 7 '18 at 5:27
• Is there a difference between \dot and \Dot? – Kane Billiot Dec 7 '18 at 5:29
• @KaneBilliot Short answer: \Dot works also when you already have something on top of the symbol. So it would not shift. – user121799 Dec 7 '18 at 5:30
• @marmot - For the case at hand, using \dot and \Dot produce the same result. – Mico Dec 7 '18 at 5:35
• At the beginning, amsmath provided capitalized versions of the math accent commands, which had to be used for “nested accents”. A later version of amsmath made the standard commands (all lowercase) “nesting aware”. The other commands remained for back compatibility. – egreg Dec 7 '18 at 8:46

The first or third option below may be close to what you're looking for. Or, switch from Newton-style to Leibniz-style notation for the derivative, as shown by the fourth option (newly fixed to incorporated @marmot's comment). A separate comment: to make the \frac{1}{2} term less visually dominant, consider using \tfrac instead of \frac.

\documentclass{article}
\usepackage{amsmath} % for \tfrac macro and general accent-placement support
\begin{document}
$\tfrac{1}{2}m \dot{\vec{x}} ^2 \quad \tfrac{1}{2}m{\dot{\vec{x}}}^2 \quad \tfrac{1}{2}m{\dot{\vec{x}}}^{\,2} \quad \tfrac{1}{2}m\bigl(\tfrac{\mathrm{d}\vec{x}}{\mathrm{d}t}\bigr)^{\!2}$
\end{document}

• I'm pretty sure Leibniz didn't use upright d's. ;-) – egreg Dec 7 '18 at 8:52
• @egreg - I'm pretty sure of that too... I switched to slanted to upright d's mainly on the (now deleted) suggestion of marmot. :-) – Mico Dec 7 '18 at 10:25
• @egreg That's a very bold statement. Did you know Leibniz personally? I would bet a lot of money on having him typeset the d's upright. Assume you have diameter $d$ that depends on time. How would you typeset its time derivative? \frac{dd}{dt}? Not really, right? And after all this is a question on the typesetting a physics Lagrange function, and at least in physics people won't hurt others' eyes by typesetting \frac{dd}{dt}. – user121799 Dec 7 '18 at 13:46
• @marmot - Wouldn't it be nice to have access to a few first-edition originals -- facsimiles will do too, I suppose -- of Leibniz's own publications? (In case you're curious: I'm afraid I have no such access...) – Mico Dec 7 '18 at 14:08
• @Mico I guess we will not be able to figure out how Leibniz would have typeset it. However, I have a reason for pushing for upright d's, namely examples of the type \frac{dd}{dt}. Do you have examples in which upright d's lead to an unfortunate output? – user121799 Dec 7 '18 at 19:10