diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/physics/physics.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/physics/physics.tex | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/physics/physics.tex b/Master/texmf-dist/doc/latex/physics/physics.tex new file mode 100644 index 00000000000..6a273fbac0f --- /dev/null +++ b/Master/texmf-dist/doc/latex/physics/physics.tex @@ -0,0 +1,177 @@ +\documentclass{article} +\usepackage{fullpage} +\usepackage{parskip} +\usepackage{physics} +\usepackage[colorlinks,urlcolor=blue]{hyperref} +\usepackage{array} +\usepackage{longtable} + +\newcommand\Vtextvisiblespace[1][.3em]{% + \mbox{\kern.06em\vrule height.3ex}% + \vbox{\hrule width#1}% + \hbox{\vrule height.3ex}} + +\begin{document} +\title{The \texttt{physics} package} +\author{Sergio C. de la Barrera} +\maketitle + +\tableofcontents + +\section{Before you start} +\subsection{The purpose of this package} +The goal of this package is to make typesetting equations for physics simpler, faster, and more human-readable. To that end, the commands included in this package have names that make the purpose of each command immediately obvious and remove any ambiguity while reading and editing \texttt{physics} code. From a practical standpoint, it is handy to have a well-defined set of shortcuts for accessing the long-form of each of these commands. The commands listed below are therefore defined in terms of their long-form names and then shown explicitly in terms of the default shorthand command sequences. These shorthand commands are meant make it easy to remember both the shorthand names and what each one represents. + +\subsection{Other required packages} +The \texttt{physics} package requires \texttt{xparse} and \texttt{amsmath} to work properly in your \LaTeX~document. The \texttt{amsmath} package comes standard with most \LaTeX~distributions and is loaded by \texttt{physics} for your convenience. You may also already have \texttt{xparse} installed on your system as it is a popular package for defining \LaTeX macros, however, if you are unsure you can either install it again using your local package manager (comes with most distributions) or by visiting the \href{http://www.ctan.org/}{CTAN} online package database, or you could even just try to use \texttt{physics} without worrying about it. Many modern \LaTeX compilers will locate and offer to download missing packages for you. +\subsection{Using \texttt{physics} in your \LaTeX~document} +To use the \texttt{physics} package, simply insert \verb|\usepackage{physics}| in the preamble of your document, before \verb|\begin{document}| and after \verb|\documentclass{class}|: +\begin{verbatim} +\documentclass{class} +... +\usepackage{physics} +... +\begin{document} + content... +\end{document} +\end{verbatim} + +\section{List of commands} +\subsection{Automatic bracing} +\begin{longtable}[l]{ l l p{6cm} } +\verb|\quantity| & \verb|\qty(a+b)| $\rightarrow \qty(a+b)$ & automatic $\qty(\;)$ braces \\ +& \verb|\qty[a+b]| $\rightarrow \qty[a+b]$ & automatic $\qty[\;]$ braces \\ +& \verb|\qty| \!\!\texttt{|}\!\! \verb|a+b| \!\!\texttt{|} $\rightarrow \qty|a+b|$ & automatic $\qty|\;|$ braces \\ +& \verb|\qty{a+b}| $\rightarrow \qty{a+b}$ & automatic $\qty{\;}$ braces \\ +& \verb|\qty\big{}| $\rightarrow \qty\big{}$ & manual sizing (works with any of the above bracket types) \\ +& \verb|\qty\Big{}| $\rightarrow \qty\Big{}$ & \\ +& \verb|\qty\bigg{}| $\rightarrow \qty\bigg{}$ & \\ +& \verb|\qty\Bigg{}| $\rightarrow \qty\Bigg{}$ & \\ +\verb|\absolutevalue| & \verb|\abs{a}| $\rightarrow \abs{a}$ & automatic sizing; equivalent to \verb|\qty| \!\!\texttt{|a|} \\ +& \verb|\abs\Big{a}| $\rightarrow \abs\Big{a}$ & inherits manual sizing syntax from \verb|\qty| \\ +\verb|\norm| & \verb|\norm{a}| $\rightarrow \norm{a}$ & automatic sizing \\ +\verb|\order| & \verb|\order{x^2}| $\rightarrow \order{x^2}$ & order symbol; automatic sizing and space handling \\ +\verb|\poissonbracket| & \verb|\pb{A}{B}| $\rightarrow \pb{A}{B}$ & same as \verb|\anticommutator| \\ +\verb|\commutator| & \verb|\comm{A}{B}| $\rightarrow \comm{A}{B}$ & automatic sizing \\ +\verb|\anticommutator| & \verb|\acomm{A}{B}| $\rightarrow \acomm{A}{B}$ & same as \verb|\poissonbracket| \\ +& \verb|\acommutator{A}{B}| $\rightarrow \acommutator{A}{B}$ & +\end{longtable} + +\subsection{Vector notation} +\begin{longtable}[l]{ l l p{6cm} } +\verb|\vectorbold| & \verb|\vb{a}| $\rightarrow \vb{a}$ & upright/no Greek \\ +& \verb|\vb*{a}|, \verb|\vb*{\theta}| $\rightarrow \vb*{a}$, $\vb*{\theta}$ & italic/Greek \\ +\verb|\vectorarrow| & \verb|\va{a}| $\rightarrow \va{a}$ & upright/no Greek \\ +& \verb|\va*{a}|, \verb|\va*{\theta}| $\rightarrow \va*{a}$, $\va*{\theta}$ & italic/Greek \\ +\verb|\vectorunit| & \verb|\vu{a}| $\rightarrow \vu{a}$ & upright/no Greek \\ +& \verb|\vu*{a}|, \verb|\vu*{\theta}| $\rightarrow \vu*{a}$, $\vu*{\theta}$ & italic/Greek \\ +\verb|\dotproduct| & \verb|\vdot| $\rightarrow \vdot$ as in $\vb{a} \vdot \vb{b}$ & note that \verb|\dp| is a protected \TeX\ primitive \\ +\verb|\crossproduct| & \verb|\cross| $\rightarrow \cross$ as in $\vb{a} \cross \vb{b}$ & \\ +& \verb|\cp| $\rightarrow \cp$ as in $\vb{a} \cp \vb{b}$ & alternate name \\ +\verb|\vnabla| & \verb|\vnabla| $\rightarrow \vnabla$ versus $\nabla$ & low-level macro for bold version \\ +\verb|\gradient| & \verb|\grad| $\rightarrow \grad$ & \\ +& \verb|\grad{\Psi}| $\rightarrow \grad{\Psi}$ & handles spacing \\ +& \verb|\grad*{\Psi+\Phi}| $\rightarrow \grad*{\Psi+\Phi}$ & long-form (handles spacing and brackets) \\ +\verb|\divergence| & \verb|\div| $\rightarrow \div$ & note \texttt{amsmath} symbol $\divisionsymbol$ renamed \verb|\divisionsymbol| \\ +& \verb|\div{\vb{a}}| $\rightarrow \div{\vb{a}}$ & handles spacing \\ +& \verb|\div*{\vb{a}+\vb{b}}| $\rightarrow \div*{\vb{a}+\vb{b}}$ & long-form \\ +\verb|\curl| & \verb|\curl| $\rightarrow \curl$ & \\ +& \verb|\curl{\vb{a}}| $\rightarrow \curl{\vb{a}}$ & handles spacing \\ +& \verb|\curl*{\vb{a}+\vb{b}}| $\rightarrow \curl*{\vb{a}+\vb{b}}$ & long-form +\end{longtable} + +\subsection{Operators} +\begin{longtable}[l]{ l l p{6cm} } +\verb|\tr| & \verb|\tr\rho| $\rightarrow \tr\rho$ & trace \\ +\verb|\rank| & \verb|\rank M| $\rightarrow \rank M$ & matrix rank \\ +\verb|\erf| & \verb|\erf(x)|$\rightarrow \erf(x)$ & Gauss error function +\end{longtable} + +\subsection{Quick quad text} +This set of commands produces text in math-mode padded by \verb|\quad| spacing on either side. This is meant to provide a quick way to insert simple words or phrases in a sequence of equations. Each of the following commands includes a starred version which pads the text only on the right side with \verb|\quad| for use in aligned environments such as \texttt{cases}. +\begin{longtable}[l]{ l l p{6cm} } +General text: & & \\ +\verb|\qqtext| & \verb|\qq{}| & general quick quad text with argument \\ +& \verb|\qq{word or phrase}| $\rightarrow$\Vtextvisiblespace[1em]$\text{word or phrase}$\Vtextvisiblespace[1em] & normal mode; left and right \verb|\quad| \\ +& \verb|\qq*{word or phrase}| $\rightarrow \text{word or phrase}$\Vtextvisiblespace[1em] & starred mode; right \verb|\quad| only +\end{longtable} +\begin{longtable}[l]{ l l } +Special macros: & \\ +\verb|\qcomma| or \verb|\qc| $\rightarrow ,$\Vtextvisiblespace[1em] & right \verb|\quad| only \\ +\verb|\qif| $\rightarrow$\Vtextvisiblespace[1em]$\text{if}$\Vtextvisiblespace[1em] & left and right \verb|\quad| unless starred \verb|\qif*| $\rightarrow \text{if}$\Vtextvisiblespace[1em] \\ +\verb|\qthen| & similar to \verb|\qif| \\ +\verb|\qelse| & $\quad\quad\cdot$ \\ +\verb|\qotherwise| & $\quad\quad\cdot$ \\ +\verb|\qunless| & $\quad\quad\cdot$ \\ +\verb|\qgiven| & \\ +\verb|\qusing| & \\ +\verb|\qfor| & \\ +\verb|\qall| & \\ +\verb|\qeven| & \\ +\verb|\qodd| & \\ +\verb|\qinteger| & \\ +\verb|\qand| & \\ +\verb|\qor| & \\ +\verb|\qas| & \\ +\verb|\qin| & \\ +\verb|\qcc| $\rightarrow \qcc$ & complex conjugate \\ +\end{longtable} + +\subsection{Derivatives} +\begin{longtable}[l]{ l l p{6cm} } +\verb|\differential| & \verb|\dd| $\rightarrow \dd$ & \\ +& \verb|\dd x| $\rightarrow \dd x$ & no extra spacing for braces, fractions \\ +& \verb|\dd{x}| $\rightarrow \dd{x}$\!\textvisiblespace & proper spacing for typical equations \\ +& \verb|\dd[3]{x}| $\rightarrow \dd[3]{x}$\!\textvisiblespace & optional power \\ +& \verb|\dd*{\cos\theta}| $\rightarrow \dd*{\cos\theta}$ & long-argument; automatic braces \\ +\verb|\derivative| & \verb|\dv{}{x}| $\displaystyle\rightarrow \dv{}{x}$ & \\ +& \verb|\dv{f}{x}| $\displaystyle\rightarrow \dv{f}{x}$ & \\ +& \verb|\dv[n]{f}{x}| $\displaystyle\rightarrow \dv[n]{f}{x}$ & optional power \\ +& \verb|\dv[n]{f}{x}[x=0]| $\displaystyle\rightarrow \dv[n]{f}{x}[x=0]$ & optional evaluation point \\ +\verb|\partialderivative| & \verb|\pderivative{}{x}| $\displaystyle\rightarrow \pderivative{}{x}$ & alternate name \\ +& \verb|\pdv{}{x}| $\displaystyle\rightarrow \pdv{}{x}$ & shorthand name \\ +& \verb|\pdv{f}{x}| $\displaystyle\rightarrow \pdv{f}{x}$ & \\ +& \verb|\pdv[n]{f}{x}| $\displaystyle\rightarrow \pdv[n]{f}{x}$ & optional power \\ +& \verb|\pdv[n]{f}{x}[x=0]| $\displaystyle\rightarrow \pdv[n]{f}{x}[x=0]$ & optional evaluation point \\ +& \verb|\pdv{f}{x}{y}| $\displaystyle\rightarrow \pdv{f}{x}{y}$ & mixed partial \\ +& \verb|\pdv*{f}{x}| $\rightarrow \pdv*{f}{x}$ & shorthand form \\ +& \verb|\pdv*{f}{x}{y}| $\rightarrow \pdv*{f}{x}{y}$ & mixed partial shorthand +\end{longtable} + +\subsection{Dirac bra-ket notation} +The following collection of macros for Dirac notation contains two fundamental commands, \verb|\bra| and \verb|\ket|, along with a set of more specialized macros which are essentially combinations of the fundamental pair. The specialized macros are both useful and descriptive from the perspective of generating \texttt{physics} code, however, the fundamental commands are designed to contract with one another algebraically when appropriate and are thus suggested for general use. For instance, the following code renders correctly\footnote{Note the lack of a space between the bra and ket commands. This is necessary is order for the bra to find the corresponding ket and form a contraction.} +\begin{displaymath} +\verb|\bra{\phi}\ket{\psi}| \rightarrow \bra{\phi}\ket{\psi} \qq{as opposed to} \bra{\phi} \ket{\psi} +\end{displaymath} +whereas a similar construction with higher-level macros will not contract in a robust manner +\begin{displaymath} +\verb|\bra{\phi}\dyad{\psi}{\xi}| \rightarrow \bra{\phi}\dyad{\psi}{\xi}. +\end{displaymath} +On the other hand, the correct output can be generated by sticking to the fundamental commands, +\begin{displaymath} +\verb|\bra{\phi}\ket{\psi}\bra{\xi}| \rightarrow \bra{\phi}\ket{\psi}\bra{\xi} +\end{displaymath} +allowing the user to type out complicated quantum mechanical expressions without worrying about bra-ket contractions. That being said, the high-level macros do have a place in convenience and readability, as long as the user is aware of rendering issues that may arise due to an absence of automatic contractions. +\begin{longtable}[l]{ l l p{6cm} } +\verb|\ket| & \verb|\ket{\psi}| $\rightarrow \ket{\psi}$ & automatic sizing \\ +& \verb|\ket*{\psi}| $\rightarrow \ket*{\psi}$ & complex conjugate (looks like \verb|\bra| but does not inherit contraction) \\ +\verb|\bra| & \verb|\bra{\psi}| $\rightarrow \bra{\psi}$ & automatic sizing \\ +& \verb|\bra*{\psi}| $\rightarrow \bra*{\psi}$ & complex conjugate (looks like \verb|\ket| but does not inherit contraction) \\ +& \verb|\bra{\phi}\ket{\psi}| $\rightarrow \bra{\phi}\ket{\psi}$ & automatic contraction \\ +\verb|\innerproduct| & \verb|\braket{a}{b}| $\rightarrow \braket{a}{b}$ & two-argument contraction; automatic sizing \\ +& \verb|\braket{a}| $\rightarrow \braket{a}$ & single-argument; produces norm \\ +& \verb|\braket*{a}{b}| $\rightarrow \braket*{a}{b}$ & complex conjugate; swaps arguments \\ +& \verb|\ip{a}{b}| $\rightarrow \ip{a}{b}$ & shorthand name \\ +\verb|\outerproduct| & \verb|\dyad{a}{b}| $\rightarrow \dyad{a}{b}$ & two-argument dyad; automatic sizing \\ +& \verb|\dyad{a}| $\rightarrow \dyad{a}$ & single-argument; produces projector \\ +& \verb|\dyad*{a}{b}| $\rightarrow \dyad*{a}{b}$ & complex conjugate; swaps arguments \\ +& \verb|\ketbra{a}{b}| $\rightarrow \ketbra{a}{b}$ & alternative name \\ +& \verb|\op{a}{b}| $\rightarrow \op{a}{b}$ & shorthand name \\ +\verb|\expectationvalue| & \verb|\expval{A}| $\rightarrow \expval{A}$ & implicit form \\ +& \verb|\expval{A}{\Psi}| $\rightarrow \expval{A}{\Psi}$ & explicit form \\ +& \verb|\ev{A}{\Psi}| $\rightarrow \ev{A}{\Psi}$ & shorthand name \\ +\verb|\matrixelement| & \verb|\matrixel{n}{A}{m}| $\rightarrow \matrixel{n}{A}{m}$ & requires all three arguments \\ +& \verb|\mel{n}{A}{m}| $\rightarrow \mel{n}{A}{m}$ & shorthand name \\ +\end{longtable} + +\end{document}
\ No newline at end of file |