%   Style File: Math.Sty
%
%   Updated Aug 18, 2018
%   Y. Tokieda
%   This style file defines and provides LaTeX macro for
%   mathematical expressions complicated mathematical formulea.
%   To look up the specification of the style file, see the 
%   attached documentation.
%
\makeatletter

% <<<<<<<<<< Greek Alphabet for math >>>>>>>>>>
\def\eps{\varepsilon}
\def\mGamma{{\mit\Gamma}}
\def\mDelta{{\mit\Delta}}
\def\mTheta{{\mit\Theta}}
\def\mXi{{\mit\Xi}}
\def\mLambda{{\mit\Lambda}}
\def\mSigma{{\mit\Sigma}}
\def\mPhi{{\mit\Phi}}
\def\mPsi{{\mit\Psi}}
\def\mOmega{{\mit\Omega}}

% <<<<<<<<<<  Arithmetic  >>>>>>>>>>
\def\lowsqrt{\@ifnextchar[{\@lowsqrt}{\@lowsqrt[\empty]}}
\def\@lowsqrt[#1]#2{%
  \setbox0\hbox{$#2$}
  \sqrt[#1]{\hbox to\wd0{\hss\vbox to1.7ex{\vss\null\vss}\hss}}%
  \null\hskip-\wd0{#2}}
\def\frtsqrt{\@ifnextchar[{\@frtsqrt}{\@frtsqrt[\empty]}}
\def\@frtsqrt[#1]#2{%
    \setbox0\hbox{$\displaystyle #2$}
    \null\kern0.32em\sqrt[#1]{%
    \raise-1.8ex\hbox to\wd0{\hss\vbox to5ex{\vss\null\vss}}}%
    \null\hskip-\wd0\hbox to\wd0{\hss$\displaystyle #2$\hss}}

%%
\def\lowsuffix@#1#2#3{#2_{\raise-0.2ex\hbox{%
    \kern-0.03em$#1 {#3}$}}}
\def\lowsuffix#1#2{\mathchoice{\lowsuffix@{\scriptstyle}{#1}{#2}}%
    {\lowsuffix@{\scriptstyle}{#1}{#2}}%
    {\lowsuffix@{\scriptscriptstyle}{#1}{#2}}% 
    {\lowsuffix@{\scriptscriptstyle}{#1}{#2}}}

%%%% Fraction in displaystyle
\def\frt@#1#2#3{#1\frac{%
    {}\mathstrut\hskip 0.2em #2 \hskip 0.2em{}}{%
    {}\mathstrut\hskip 0.2em #3 \hskip0.2em{}}}
\def\frt#1#2{\mathchoice{\frt@{\displaystyle}{#1}{#2}}%
    {\frt@{\displaystyle}{#1}{#2}}{\frt@{\scriptstyle}{#1}{#2}}%
    {\frt@{\scriptscriptstyle}{#1}{#2}}}
% Alternative command name
\def\dfrac{\frt}

%%%% Slanted parallel symbol
\def\para@#1{#1/\kern-0.27em\raise-0.25ex\hbox{$#1/$}}
\def\para{\mathchoice{\para@{\displaystyle}}{\para@{\displaystyle}}
                     {\para@{\scriptstyle}}{\para@{\scriptscriptstyle}} }

% <<<<<<<<<<  Linear Algebra  >>>>>>>>>>
\def\transpose#1{{}\,^{\rm t}\hskip-0.1em#1}

% <<<<<<<<<<  Vector Algebra  >>>>>>>>>>
\def\vc@#1#2{\mbox{#1\boldmath$#2$}}
\def\vc#1{\mathchoice{{\vc@{\normalsize}{#1}}}{{\vc@{\normalsize}{#1}}}%
       {{\vc@{\scriptsize}{#1}}}{{\vc@{\tiny}{#1}}}}
\def\ftvc#1{\mathchoice{{\vc@{\footnotesize}{#1}}}{{\vc@{\footnotesize}{#1}}}%
       {{\vc@{\tiny}{#1}}}{{\vc@{\tiny}{#1}}}}
\def\Div{\nabla\!\cdot\kern-0.07em{}}
\def\Curl{\nabla\!\times\!{}}

% <<<<<<<<<<  Integrodifferentiation  >>>>>>>>>>
\def\dlt{{\rm d}}
\def\odf{\@ifnextchar[{\@odf}{\@@odf}}
\def\@odf[#1]#2#3{\frt{\dlt^{#1}\kern-0.08em#2}{\dlt #3^{#1}}}
\def\@@odf#1#2{\frt{\dlt #1}{\dlt #2}}
\def\odd#1#2{\frt{\dlt^2#1}{\dlt #2^2}}
\def\pdf{\@ifnextchar[{\@pdf}{\@@pdf}}
\def\@pdf[#1]#2#3{\frt{\partial^{#1}\kern-0.08em#2}{\partial #3^{#1}}}
\def\@@pdf#1#2{\frt{\partial #1}{\partial #2}}
\def\pdd#1#2{\frt{\partial{}^2\hskip-0.08em#1}{\partial #2{}^2}}
\def\pdm#1#2#3{\frt{\partial{}^2\hskip-0.08em#1}{%
    \partial #2\kern0.07em\partial #3}}

\def\todf{\@ifnextchar[{\@todf}{\@todf[\empty]}}
\def\@todf[#1]#2#3{\dlt^{#1}\kern-0.08em#2/\dlt #3^{#1}}
\def\todd#1#2{\dlt^2\kern-0.08em#1/\dlt #2^2}
\def\tpdf{\@ifnextchar[{\@tpdf}{\@@tpdf}}
\def\@tpdf[#1]#2#3{\partial^{#1}\kern-0.08em#2/\partial #3^{#1}}
\def\@@tpdf#1#2{\partial #1/\partial #2}
\def\tpdd#1#2{\partial^2\kern-0.08em#1/\partial #2^2}
\def\tpdm#1#2#3{\partial^2\kern-0.08em#1/\partial#2\partial#3}

% <<<<<<<<<<  Differential Geometry  >>>>>>>>>>
\def\Chris#1#2{{\mit\Gamma}^{#1}\!_{#2}}
\def\Chrisi#1#2{{\mit\Gamma}\!_{#1,#2}}
\def\chris#1#2{\{\!\!\vbox to1ex{\vss%
    \hbox{$\begin{array}{c}{\scriptstyle#1}\\[-10pt]%
    {\scriptstyle#2}\\[-2.6ex]{}\end{array}$}\vss}\!\!\}}
\def\chrisi#1#2{[\raisebox{0.5ex}{%
    ${}_{#1,\,#2}$}]}

% <<<<<<<<<<  Integers >>>>>>>>>>
\def\floor#1{\left\lfloor#1\right\rfloor}
\def\ceil#1{\left\lceil#1\right\rceil}

% <<<<<<<<<<  Quantum Mechanics  >>>>>>>>>>
\def\avrg#1{\left\langle #1 \right\rangle}
\def\bra#1{\left\langle #1 \right|}
\def\ket#1{\left| #1 \right\rangle}
\def\braket#1#2{\left\langle #1 \left|\right. #2 \right\rangle}
\def\Braket#1#2#3{\left\langle #1 \left| #2 \right| #3 \right\rangle}
\def\tavrg#1{\langle #1 \rangle}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% eqnarray environment 
%
\def\eqnarray{\stepcounter{equation}\let\@currentlabel\theequation
\global\@eqnswtrue\m@th
\global\@eqcnt\z@\tabskip\@centering\let\\\@eqncr
$$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne
  \hskip .57\arraycolsep \hfil${##}$\hfil
  &\global\@eqcnt\tw@ \hskip .57\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}

\def\endeqnarray{\@@eqncr\egroup
      \global\advance\c@equation\m@ne$$\global\@ignoretrue}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% eqnarraya environment
%
\def\eqnarraya{\eqn@rraya \eqnarray}
\newif\ifnakaguro \nakagurotrue
\def\niten{\mbox{.}}
%\def\niten{\mbox{$\cdot$}}
%\def\niten{\hbox to .5zw{\hfil\raise.5ex\hbox{.}\hfil}}
\def\eqn@rraya{\c@enumi=\c@equation
  \advance\c@enumi by1\relax
  \c@equation=0\relax
  \@ifundefined{chapter}%
{\def\theequation{\theenumi\alph{equation}}}%
{\def\theequation{\ifnakaguro
\thechapter\niten\theenumi\alph{equation}%
\else\thechapter.\theenumi\alph{equation}\fi}}}
\def\endeqnarraya{\endeqnarray
\global\c@equation=\c@enumi}

%%%%%%% delta in mathematics style
\newdimen\th@line    \th@line=0.06pt % for 1200 dpi printers
\newdimen\th@majline \th@majline=0.065em
\newdimen\th@minline \th@minline=0.025em
\newdimen\xa@kern %
\newdimen\len@xa  %
\newdimen\len@max %
\newdimen\cur@yy  %

\def\mdelt@{%
  \cur@yy=1.6ex%
  \th@majline=0.065em%
  \th@minline=0.025em%
  \leavevmode\raise\z@%\cur@yy%
  \vbox{\offinterlineskip%
     \xa@kern=0.7\cur@yy \len@xa=\z@ % 0.5\th@majline%\z@ 
     \len@max=\th@majline  % \advance\len@max\th@minline
     \loop\hbox{\kern\xa@kern\vbox to\th@line{%
        \hrule width\len@xa height\th@line}}
     \advance\len@xa0.6\th@line
     \advance\xa@kern-0.7\th@line
     \advance\cur@yy-\th@line
     \ifdim\len@xa<\len@max\relax%
     \repeat %
     \len@xa=-\th@minline%\z@
     \loop\hbox{\kern\xa@kern\vbox to\th@line{%
         \hrule width\th@minline height\th@line}\kern\len@xa%
         \vbox to\th@line{\hrule width\th@majline height\th@line}}
     \advance\len@xa0.6\th@line
     \advance\xa@kern-0.7\th@line
     \advance\cur@yy-\th@line
     \ifdim\cur@yy>\th@majline\relax%
     \repeat%
     \advance\len@xa\th@majline %\advance\len@xa-\th@minline
     \advance\len@xa\th@minline %\advance\len@xa-\th@minline
     \loop\hbox{\kern\xa@kern\vbox to\th@line{%
         \hrule width\len@xa height\th@line}}
     \advance\cur@yy-\th@line%
     \advance\xa@kern-0.7\th@line
     \advance\len@xa0.6\th@line
     \ifdim\cur@yy>\z@\relax%
     \repeat %end while
}\kern0.07em\relax}
\def\mdelta{\mathchoice{{\mdelt@}}{{\mdelt@}}%
    {{\mbox{\scriptsize$\mdelt@$}}}{{\mbox{\tiny$\mdelt@$}}}}

%%
\makeatother
