You wrote,
I find that \prime inserts an ugly, large prime, whereas the ' produces something ok. Is there an explanation?
To address this question in depth, it's useful to check how ' (in math mode) is defined relative to \prime. Here's an excerpt from the current version (2020-02-02, patch level 5) of the LaTeX2e "kernel" -- lines 5939 to 5954 from latex.ltx, to be exact -- that provides the code that defines ' in LaTeX. (The Plain-TeX definition of ' is similar.)
\def\active@math@prime{^\bgroup\prim@s}
{\catcode`\'=\active \global\let'\active@math@prime}
\def\prim@s{%
\prime\futurelet\@let@token\pr@m@s}
\def\pr@m@s{%
\ifx'\@let@token
\expandafter\pr@@@s
\else
\ifx^\@let@token
\expandafter\expandafter\expandafter\pr@@@t
\else
\egroup
\fi
\fi}
\def\pr@@@s#1{\prim@s}
\def\pr@@@t#1#2{#2\egroup}
I won't claim that this code is easy to grasp. Here's the gist of what's going on.
The instruction
\catcode`\'=\active
makes the character ' ("apostrophe" or "prime") active, in the TeX sense of the word, if the character is encountered in math mode.
The character is let to \active@math@prime, which is defined as ^\bgroup\prim@s. Note the initiation of an exponent term via ^, followed by \bgroup -- as well as the absence, for now, of a corresponding \egroup directive.
\prim@s, in turn, is defined as \prime\futurelet\@let@token\pr@m@s. Finally, we encounter \prime -- yay! The \prime directive -- recall that it is executed in superscript mode, so the resulting symbol is smaller than the text-style version of \prime -- is followed by
\futurelet\@let@token\pr@m@s
\futurelet\@let@token assigns the next token to \@let@token. So, what does \pr@m@s do?
The code for \pr@m@s covers 10 lines of code; it is by far the most complicated of the macros in this bunch. It basically tells LaTeX to compare the look-ahead token (via a couple of \ifx statements) to a number of possible alternatives. In fact, the code considers three alternatives.
If the look-ahead token is not equal to either ' or ^, then \egroup is issued -- meaning that the exponent term group is closed and can be processed by LaTeX -- and we're done. Whew!
If the next character is equal to ^ (as in, say, g'^2), code needed to handle the exponent term, including an \egroup directive, is executed. (In case you're curious: g'^2 evaluates to g^{\prime2}. If you'd rather have the square term placed a bit further up, you will need to write {g'}^2.)
Finally, if the next character is equal to ', then (after some more stirring of the pot...) another round of \prime\futurelet\@let@token\pr@m@s is executed, i.e., another \prime directive is executed followed by some more looking ahead.
Remembering that \bgroup and \egroup evaluate to { and }, respectively, we come to the following conclusion: the code assures that u'v gets interpreted as u^{\prime}v, w''x gets interpreted as w^{\prime\prime}x, f''' gets interpreted as f^{\prime\prime\prime}, etc. What's really important is to notice that w''x it NOT interpreted as w^{\prime}^{\prime}x, as that would trigger a dreaded "Double superscript" error.
In short, (a) typing f\prime\prime does not trigger an error message but is most definitely incorrect from a typographic perspective; (b) f^{\prime\prime} is both typographically and syntactically correct but also exceedingly tedious; (c) f'' is both correct and easy. Can you guess which method is recommended? For what it's worth, my impression is that Donald Knuth intended users to input f' and f'' all along.
$a'_{i}$is actually$a^{\prime}_{i}$– moewe Apr 13 '20 at 16:38\primejust use'– David Carlisle Apr 13 '20 at 16:40