# What is the advantage of using $f^\prime$ instead of $f'$?

Although the two outputs look quite similar, what is the advantage of using $f^\prime$ instead of $f'$? By the way, here is my code:

\documentclass‎{article‎}‎
\begin{document}‎‎‎
$‎ ‎f^‎\prime ‎(x)=y‎ ‎$‎
$‎ ‎f'‎ ‎(x)=y‎ ‎$‎‎
\end{document}

-
There's no advantage in using $f^\prime$; it's just more awkward to type than $f'$ and the result is exactly the same. –  egreg Dec 15 '12 at 17:14

' is defined in latex.ltx as active math character:

\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}


The active ' looks for following ' and puts them together as superscript, a''' becomes a^{\prime\prime\prime}. Thus using ' makes the input easier to write.

-

Sometimes you may want to pass LaTeX code as an argument to another program. In that case the code is typically wrapped in quotes. Using quote to mean a prime will confuse the second program. For example to type TeX in graphical output of MATLAB one may use something like

str='$$F^\prime$$'
text(0,0,str,'Interpreter','latex')


to print $F'$ at location $(0,0)$. Using $F'$ in the code however becomes problematic.

-
use double quotes or escapes for the String? –  MaxNoe Jan 26 at 10:21
@MaxNoe Double quotes don't work in Matlab. String escaping is done with a double quote. So you'd have to write things like 'The symbol f'' is used to represent the first derivative of a function', which looks wrong at a first glance. All things considered, f^\prime` doesn't look so bad. –  Federico Poloni Feb 9 at 22:18