% derivative.tex % Copyright 2019-2024 Simon Jensen % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3 or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % This work has the LPPL maintenance status `maintained'. % % The Current Maintainer of this work is Simon Jensen. % Contributors: Romain Noel \begin{filecontents*}{macro.mst} headings_flag 1 heading_prefix "\\begingroup \\ttfamily \\color\{RoyalBlue\}" heading_suffix "\\endgroup \\nopagebreak\n" item_0 "\n \\item \\begingroup \\small \\ttfamily \\upshape " delim_0 "\\endgroup, " group_skip "\n\n\\par\\bigskip\n" \end{filecontents*} \begin{filecontents*}{option.mst} item_0 "\n \\item \\begingroup \\color\{RoyalBlue\} " item_x1 "\\endgroup \n \\subitem \\begingroup \\small \\ttfamily \\upshape " item_1 "\n \\subitem \\begingroup \\small \\ttfamily \\upshape " delim_1 "\\endgroup, " group_skip "\n\n\\par\\bigskip\n" \end{filecontents*} \NeedsTeXFormat{LaTeX2e} \documentclass[final,british,10pt]{scrartcl} \reversemarginpar \RequirePackage[british]{babel} \RequirePackage{fontspec} %\RequirePackage{polyglossia} % \setmainlanguage[variant=british]{english} \RequirePackage[style=english,english=british]{csquotes} \RequirePackage[final,babel,auto]{microtype} \RequirePackage{xcolor} \definecolor{RoyalGray}{RGB}{127, 144, 158} \definecolor{RoyalDarkGray}{RGB}{78, 93, 104} \definecolor{RoyalLightGray}{RGB}{250, 250, 250} \definecolor{RoyalRed}{RGB}{157, 16, 45} \definecolor{RoyalBlue}{RGB}{0, 35, 102} \definecolor{RoyalGreen}{RGB}{32, 77, 2} % \definecolor{RoyalGray}{RGB}{75, 75, 75} % \definecolor{RoyalDarkGray}{RGB}{225, 225, 225} % \definecolor{RoyalLightGray}{RGB}{30, 30, 30} % \definecolor{RoyalRed}{RGB}{255, 177, 151} % 207, 102, 121 % \definecolor{RoyalBlue}{RGB}{187, 134, 252} % 55, 185, 255 % \definecolor{RoyalGreen}{RGB}{3, 218, 198} % 52, 177, 20 % \definecolor{RoyalPageCoulor}{RGB}{18, 18, 18} % 30, 30, 30 % \definecolor{RoyalTextCoulor}{RGB}{225, 225, 225} % \pagecolor{RoyalPageCoulor} % \color{RoyalTextCoulor} \RequirePackage{amsmath, amsthm} \allowdisplaybreaks \theoremstyle{remark} \newtheorem*{note}{Note} \RequirePackage{unicode-math} \RequirePackage{booktabs} \RequirePackage{tabularx} \RequirePackage{ragged2e} \RequirePackage{siunitx} \sisetup{locale = UK} \RequirePackage{hologo} \RequirePackage{enumitem} \RequirePackage{listings} \RequirePackage{imakeidx} \RequirePackage{calc} \RequirePackage{mleftright} \RequirePackage{xfrac} \RequirePackage[unicode]{hyperref} \RequirePackage[nameinlink]{cleveref} \makeatletter \ExplSyntaxOn \tl_new:N \pakkenavn \tl_new:N \titel \tl_new:N \email \tl_new:N \forfatter \tl_new:N \dato \tl_new:N \version \NewDocumentCommand{\Pakkenavn}{ m }{ \tl_gset:Nf \pakkenavn { \tl_trim_spaces:n { #1 } } } \NewDocumentCommand{\Titel} { m }{ \tl_gset:Nf \titel { \tl_trim_spaces:n { #1 } } } \NewDocumentCommand{\Forfatter}{ m }{ \tl_gset:Nf \forfatter { \tl_trim_spaces:n { #1 } } } \NewDocumentCommand{\Email} { m }{ \tl_gset:Nf \email { \tl_trim_spaces:n { #1 } } } \NewDocumentCommand{\Dato} { m }{ \tl_gset:Nf \dato { \tl_trim_spaces:n { #1 } } } \NewDocumentCommand{\Version} { m }{ \tl_gset:Nf \version { \tl_trim_spaces:n { #1 } } } \NewDocumentCommand{\mypackage}{ } { \pkg{\pakkenavn} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NewDocumentCommand{\forside}{ m } { \thispagestyle{empty} \null\vspace{15mm}\noindent \begin{minipage}[t]{\textwidth} \centering \rule{\textwidth}{.4pt} \par \bigskip { \Huge \bfseries \tl_use:N \titel \par } \bigskip \rule{\textwidth}{.4pt} \end{minipage} \par \vspace{6mm} \noindent \begin{minipage}[t]{0.5\textwidth} \centering \textsl{Written~by:} \par { \color{RoyalRed} \forfatter \par } { \color{RoyalRed} \email \par } \end{minipage} \hfill \begin{minipage}[t]{0.5\textwidth} \centering \textsl{Released:} \par { \color{RoyalRed} v\version \par } { \color{RoyalRed} \dato \par } \end{minipage} \par \vspace{20mm} \noindent \begin{abstract} \noindent \ignorespaces #1 \end{abstract} \vfill \clearpage } \lstdefinestyle{inlinestyle} { columns = fullflexible, basicstyle = \ttfamily\upshape\small, alsoletter = {\\,-,*,/,!}, keywords = [0]{style-inf, style-inf-num, style-inf-den, style-var, style-var-/, style-var-!, style-var-/!, style-frac, style-frac-/, style-notation, style-notation-*, scale-eval, scale-eval-/, scale-fun, scale-var, scale-var-!, scale-var-*, scale-frac, scale-frac-/, delims-eval, delims-eval-/, delims-fun, delims-var, delims-var-!, delims-var-*, delims-frac, delims-frac-/, sep-inf-ord, sep-inf-fun, sep-ord-fun, sep-frac-fun, sep-inf-var, sep-var-ord, sep-var-inf, sep-ord-inf, sep-ord-ord, sep-ord-var, sep-var-var, sep-eval-sb, sep-eval-sp, sep-begin, sep-end, switch-*, switch-/, switch-!, switch-sort, sort-method, sort-numerical, sort-abs-reverse, sort-lexical-reverse, sort-number-reverse, sort-sign-reverse, sort-symbol-reverse, fun, frac, var, order, ord, mixed-order, mixord, scale-auto}, keywordstyle = [0]\__mydoc_option_font:, keywords = [1]{\\odv, \\pdv, \\mdv, \\fdv, \\adv, \\jdv, \\odif, \\pdif, \\mdif, \\fdif, \\adif, \\NewDerivative, \\RenewDerivative, \\ProvideDerivative, \\DeclareDerivative, \\NewDifferential, \\RenewDifferential, \\ProvideDifferential, \\DeclareDifferential, \\slashfrac, \\derivset}, keywordstyle = [1]\__mydoc_function_font:, } \lstdefinestyle{definitionstyle} { style = inlinestyle, tabsize = 1, escapechar = \%, commentstyle = \footnotesize, frame = single, xleftmargin=3.4pt, xrightmargin=3.4pt, rulesep = 0pt, backgroundcolor = \color{RoyalLightGray}, rulecolor = \color{RoyalGray}, } \lstnewenvironment{definition}{\lstset{style=definitionstyle}\normalmarginpar}{\reversemarginpar} \newlist{todo}{enumerate}{1} \setlist[todo]{label=(\roman{todoi}), ref=\thesubsection(\roman{todoi})} \crefname{todoi}{todo}{todos} \newlist{changes}{enumerate}{1} \setlist[changes]{label=(\roman{changesi}), ref=\thesubsection(\roman{changesi})} \crefname{changesi}{change}{changes} \newlist{consideration}{enumerate}{1} \setlist[consideration]{label=(\roman{considerationi}), ref=\thesubsection(\roman{considerationi})} \crefname{considerationi}{consideration}{considerations} \AtEndPreamble { %\meaning\@idxitem\\ %\meaning\subitem\\ %\meaning\indexspace\\ %\meaning\hangindent %\meaning\indexspace \RenewDocumentCommand{\@idxitem}{}{\par \hangindent 0\p@ } \RenewDocumentCommand{\subitem}{}{\@idxitem \hspace *{0\p@ }} \RenewDocumentCommand{\indexspace}{}{\par \vskip 10\p@ \relax} } \NewDocumentCommand{\marginnote}{ m } { \leavevmode \marginline{\leavevmode \ttfamily\upshape\small \color{RoyalDarkGray} \tl_trim_spaces:n {#1} } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NewDocumentCommand{\ket}{ m } { \lvert #1 \rangle } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NewDocumentCommand{\pkg}{ m } { \group_begin: \sffamily \upshape \small #1 \group_end: } \NewDocumentCommand{\uni}{} % Kræver unicode { \textsuperscript{\texttt{U}} } \NewDocumentCommand{\pdf}{} % Kræver pdflatex { \textsuperscript{\texttt{P}} } \NewDocumentCommand{\req}{} % Kræver pakke { \textsuperscript{\texttt{R}} } \NewDocumentCommand{\tex}{}{\texorpdfstring{\hologo{TeX}}{TeX}} \NewDocumentCommand{\pdftex}{}{\texorpdfstring{\hologo{pdfTeX}}{pdfTeX}} \NewDocumentCommand{\luatex}{}{\texorpdfstring{\hologo{LuaTeX}}{LuaTeX}} \NewDocumentCommand{\xetex}{}{\texorpdfstring{\hologo{XeTeX}}{XeTeX}} \NewDocumentCommand{\latex}{ t2 t3 } { \bool_if:nTF {#1} { \texorpdfstring{\hologo{LaTeX2e}}{LaTeX2e} } { \bool_if:nTF {#2} { \texorpdfstring{\hologo{LaTeX3}}{LaTeX3} } { \LaTeX } } } \NewDocumentCommand{\xmark}{} { \textcolor{red}{\ensuremath{\mathord{\mathpalette\bigcdot@{}}}} } \NewDocumentCommand{\cmark}{} { \textcolor{green}{\ensuremath{\checkmark}} } \bool_new:N \l__mydoc_answer_bool \keys_define:nn {mydoc/answer} { done .bool_set:N = \l__mydoc_answer_bool, done .initial:n = false, done .default:n = true } \NewDocumentCommand{\answer}{ o m m } { \group_begin: \tl_if_novalue:nF {#1} { \mydoc_set_keys:nn {answer} {#1} } \bool_if:NTF \l__mydoc_answer_bool { \fcolorbox{RoyalGray}{RoyalLightGray} { \parbox{\dimexpr\linewidth-2\fboxsep\relax} { \__mydoc_answer:nn {#2} {#3} } } } { \__mydoc_answer:nn {#2} {#3} } \group_end: } \cs_new_protected:Npn \__mydoc_answer:nn #1 #2 { #1 \textbf{Conclusion:} \c_space_tl \group_begin: \slshape #2 \group_end: } \newcommand*{\bigcdot@scalefactor}{1.25} \newcommand*{\bigcdot@widthfactor}{1.15} \newcommand*{\bigcdot@}[2]{ % #1: math style % #2: unused \sbox0{$#1\vcenter{}$}% math axis \sbox2{$#1\vectimes\m@th$} \hbox to \bigcdot@widthfactor\wd2{ \hfil \raise\ht0\hbox{ \scalebox{\bigcdot@scalefactor}{ \lower\ht0\hbox{$#1\vectimes\m@th$} } } \hfil } } \tl_new:N \l__mydoc_ch_version_tl \tl_new:N \l__mydoc_ch_date_tl \tl_new:N \l__mydoc_ch_change_tl \bool_new:N \l__mydoc_ch_beta_bool \bool_new:N \l__mydoc_ch_change_bool \keys_define:nn { mydoc/changelog } { version .tl_set:N = \l__mydoc_ch_version_tl, version .default:n = \c_novalue_tl, date .tl_set:N = \l__mydoc_ch_date_tl, date .default:n = \c_novalue_tl, beta .bool_set:N = \l__mydoc_ch_beta_bool, beta .default:n = {false} } \DeclareDocumentEnvironment{change}{ o } { \IfNoValueTF{#1} { \keys_set:nn { mydoc/changelog } { version, date, beta } } { \keys_set:nn { mydoc/changelog } { version, date, beta, #1 } } \mydoc_change_set: \mydoc_change_begin: } { \mydoc_change_end: } \cs_new_protected:Npn \mydoc_change_set: { \bool_set_true:N \l__mydoc_ch_change_bool \tl_set:Nn \l__mydoc_ch_change_tl { \leavevmode \marginline { \upshape \scriptsize \ttfamily %\leavevmode \null\vspace{-3.5\baselineskip}\null \tabular[t]{ r } \toprule v\tl_use:N \l__mydoc_ch_version_tl \\ \tl_use:N \l__mydoc_ch_date_tl \bool_if:NT \l__mydoc_ch_beta_bool { \\ \color{RoyalRed} Beta } \\ \bottomrule \endtabular } \ignorespaces } } \cs_new_protected:Npn \mydoc_change_begin: { \let\mydoc_item:\item \DeclareDocumentCommand{\item}{ o } { \tl_if_novalue:nTF {##1} { \mydoc_item: } { \mydoc_item: [##1] } \bool_if:NT \l__mydoc_ch_change_bool { \tl_use:N \l__mydoc_ch_change_tl \bool_set_false:N \l__mydoc_ch_change_bool } } \itemize[itemsep=0pt] } \cs_new_protected:Npn \mydoc_change_end: { \enditemize %\let\item\mydoc_item: } \NewDocumentEnvironment{changelog}{ } { \mydoc_ch_begin: } { \mydoc_ch_end: } \cs_new_protected:Npn \mydoc_ch_begin: { } \cs_new_protected:Npn \mydoc_ch_end: { } \ExplSyntaxOff \ExplSyntaxOn \tl_new:N \l__mydoc_number_tl \tl_new:N \l_mydoc_index_item_tl \tl_new:N \l_mydoc_index_subitem_tl \tl_new:N \l_mydoc_index_entry_tl \seq_new:N \l__mydoc_macro_arg_seq \seq_new:N \l__mydoc_group_seq \seq_new:N \l__mydoc_type_seq \seq_new:N \l__mydoc_function_seq \seq_new:N \g__mydoc_syntax_seq \seq_new:N \l__deriv_earg_seq \int_new:N \l__mydoc_earg_int \int_new:N \g__mydoc_function_int \int_new:N \g__mydoc_option_int \bool_new:N \l__mydoc_number_bool \tl_set:Nn \l__mydoc_number_tl {0123456789} \seq_new:N \l__mydoc_example_seq \int_new:N \g__mydoc_example_int %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \mydoc_define_vars_keys:nnnn #1 #2 #3 #4 { \seq_set_from_clist:Nn \l__mydoc_group_seq {#4} \seq_map_inline:Nn \l__mydoc_group_seq { \mydoc_define_var:nnnn {#1} {#2} {#3} {##1} \mydoc_define_key:nnnn {#1} {#2} {#3} {##1} } } \cs_new_protected:Npn \mydoc_define_var:nnnn #1 #2 #3 #4 { \use:c { #3_new:c } { #2__mydoc_#1_#4_#3 } } \cs_new_protected:Npn \mydoc_define_key:nnnn #1 #2 #3 #4 { \str_if_eq:nnTF {#2} { g } { \keys_define:nn { mydoc/#1 } { #4 .#3_#2set:c = { #2__mydoc_#1_#4_#3 } } } { \keys_define:nn { mydoc/#1 } { #4 .#3_set:c = { #2__mydoc_#1_#4_#3 } } } } %\cs_new_protected:Npn \mydoc_define_inital:nnn #1 #2 #3 %{ \keys_define:nn { mydoc/#1 } { #3 .initial:n = {#2} } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \mydoc_set_keys:nn #1 #2 { \keys_set:nn { mydoc/#1 } {#2} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \mydoc_define_font_i:n #1 { \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { colour, family, shape, size } \cs_new_protected:cpn { __mydoc_#1_font: } { \color { \use:c { l__mydoc_#1_colour_tl } } \tl_use:c { l__mydoc_#1_family_tl } \tl_use:c { l__mydoc_#1_shape_tl } \tl_use:c { l__mydoc_#1_size_tl } } } \cs_new_protected:Npn \mydoc_define_font_ii:n #1 { \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { family, shape, size } \mydoc_define_vars_keys:nnnn {#1} { l } { bool } { familyb, shapeb, sizeb } \cs_new_protected:cpn { __mydoc_#1_font: } { \bool_if:cT { l__mydoc_#1_familyb_bool } { \tl_use:c { l__mydoc_#1_family_tl } } \bool_if:cT { l__mydoc_#1_shapeb_bool } { \tl_use:c { l__mydoc_#1_shape_tl } } \bool_if:cT { l__mydoc_#1_sizeb_bool } { \tl_use:c { l__mydoc_#1_size_tl } } } } \cs_new_protected:Npn \mydoc_define_index:n #1 { \mydoc_define_vars_keys:nnnn {#1} { l } { bool } { index } \mydoc_define_vars_keys:nnnn {#1} { l } { bool } { definition } \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { cat } } \cs_new_protected:Npn \mydoc_define_updated:n #1 { \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { new } \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { updated } } \cs_new_protected:Npn \mydoc_define_default:n #1 { \mydoc_define_vars_keys:nnnn {#1} { g } { clist } { default } \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { sepa } \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { sepb } \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { sepc } } \cs_new_protected:Npn \mydoc_define_tabular:n #1 { \mydoc_define_vars_keys:nnnn {#1} { l } { bool } { result } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \mydoc_define_type:nn #1 #2 { \seq_set_from_clist:Nn \l__mydoc_type_seq {#2} \seq_map_inline:Nn \l__mydoc_type_seq { \str_case:nn {##1} { { font_i } { \mydoc_define_font_i:n {#1} } { font_ii } { \mydoc_define_font_ii:n {#1} } { index } { \mydoc_define_index:n {#1} } { default } { \mydoc_define_default:n {#1} } { tabular } { \mydoc_define_tabular:n {#1} } { updated } { \mydoc_define_updated:n {#1} } } } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mydoc_define_type:nn { function } { font_i, index, updated } \mydoc_define_type:nn { macro } { font_ii, index } \mydoc_define_type:nn { syntax } { font_ii } \mydoc_define_type:nn { argument } { font_i, updated } \mydoc_define_type:nn { arg } { font_ii, } \mydoc_define_type:nn { option } { font_i, index, updated } \mydoc_define_type:nn { key } { font_ii, index } \mydoc_define_type:nn { values } { font_ii, default } \mydoc_define_type:nn { val } { font_ii } \mydoc_define_type:nn { example } { font_ii, tabular } \mydoc_define_type:nn { marg } { font_ii } \mydoc_define_type:nn { narg } { font_ii } \mydoc_define_type:nn { oarg } { font_ii } \mydoc_define_type:nn { targ } { font_ii } \mydoc_define_type:nn { meta } { font_ii } \mydoc_define_type:nn { cs } { font_ii } \mydoc_set_keys:nn { function } { family=\ttfamily, shape=\upshape, size=\small, colour=RoyalRed, index=true, definition=true, cat=\c_novalue_tl } \mydoc_set_keys:nn { macro } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, index=true, definition=false, cat=\c_novalue_tl } \mydoc_set_keys:nn { syntax } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true } \mydoc_set_keys:nn { argument } { family=\rmfamily, shape=\upshape, size=\small, colour=RoyalBlue } \mydoc_set_keys:nn { arg } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true } \mydoc_set_keys:nn { option } { family=\ttfamily, shape=\upshape, size=\small, colour=RoyalGreen, index=true, definition=true, cat=\c_novalue_tl } \mydoc_set_keys:nn { key } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, index=true, definition=false, cat=\c_novalue_tl } \mydoc_set_keys:nn { values } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, default=\c_novalue_tl, sepa={ ,~}, sepb={ ,~}, sepc={ ,~} } \mydoc_set_keys:nn { val } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true } \mydoc_set_keys:nn { example } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, result=true } \mydoc_set_keys:nn { marg } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true } \mydoc_set_keys:nn { narg } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true } \mydoc_set_keys:nn { oarg } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true } \mydoc_set_keys:nn { targ } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true } \mydoc_set_keys:nn { meta } { family=\rmfamily, shape=\slshape, size=\small, familyb=true, shapeb=true, sizeb=true } \mydoc_set_keys:nn { cs } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \prg_new_protected_conditional:Npnn \mydoc_if_int:n #1 { T, F, TF } { \tl_map_inline:Nn {#1} { \tl_if_in:NnTF \l__mydoc_number_tl {##1} { \bool_set_true:N \l__mydoc_number_bool } { \tl_map_break:n { \bool_set_false:N \l__mydoc_number_bool } } } \bool_if:NTF \l__mydoc_number_bool { \prg_return_true: } { \prg_return_false: } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \mydoc_vspace:n #1 { \vspace{#1\baselineskip} } \cs_new_protected:Npn \mydoc_margin:n #1 { \leavevmode \marginline { \leavevmode #1 } \ignorespaces } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \__mydoc_function_begin:n #1 { \par \bool_if:NF {#1} { \mydoc_vspace:n { 0.3 } } \@afterindentfalse \@afterheading } \cs_new_protected:Npn \__mydoc_function_end: { \seq_gclear:N \g__mydoc_syntax_seq \par \noindent \ignorespacesafterend } \cs_new_protected:Npn \__mydoc_function_margin:n #1 { \seq_set_from_clist:Nn \l__mydoc_function_seq {#1} \int_gzero:N \g__mydoc_function_int \mydoc_margin:n { \tabular[t]{ @{} r @{} } %\group_begin: \seq_map_inline:Nn \l__mydoc_function_seq { \__mydoc_function_font: \int_gincr:N \g__mydoc_function_int \mydoc_cs_to_str:N ##1 \mydoc_index_cs:Nnn ##1 { function } { macro } \int_compare:nNnF { \g__mydoc_function_int } = { \seq_count:N \l__mydoc_function_seq } { \\ } } %\group_end: \deriv_new_updated:NN \l__mydoc_function_new_tl \l__mydoc_function_updated_tl \endtabular } } \cs_new_protected:Npn \deriv_new_updated:NN #1 #2 { \tl_if_empty:NTF #1 { \tl_if_empty:NF #2 { \\ \midrule \deriv_add_updated:N #2 } } { \\ \midrule \deriv_add_new:N #1 \tl_if_empty:NF #2 { \\ \deriv_add_updated:N #2 } } } \cs_new_protected:Npn \deriv_add_new:N #1 { \group_begin: \small \ttfamily New: \tl_use:N \c_space_tl \tl_if_head_eq_charcode:fNTF {#1} v { \tl_use:N #1 } { v\tl_use:N #1 } \group_end: } \cs_new_protected:Npn \deriv_add_updated:N #1 { \group_begin: \small \ttfamily Updated: \tl_use:N \c_space_tl \tl_if_head_eq_charcode:fNTF {#1} v { \tl_use:N #1 } { v\tl_use:N #1 } \group_end: } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \__mydoc_syntax_begin: { \ignorespaces } \cs_new_protected:Npn \mydoc_syntax:n #1 { \seq_gset_from_clist:Nn \g__mydoc_syntax_seq {#1} \__mydoc_syntax_font: \seq_use:Nn \g__mydoc_syntax_seq { } } \cs_new_protected:Npn \__mydoc_syntax_end: { \par \mydoc_vspace:n { 0.2 } \noindent \ignorespacesafterend } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \__mydoc_argument_begin:n #1 { \par \bool_if:NF {#1} { \mydoc_vspace:n { 0.3 } } \@afterindentfalse \@afterheading } \cs_new_protected:Npn \__mydoc_argument_end: { \par\noindent\ignorespacesafterend } \cs_new_protected:Npn \__mydoc_argument_margin:n #1 { \mydoc_margin:n { \tabular[t]{ @{} r @{} } \mydoc_set_keys:nn { marg } { familyb = false, shapeb = false, sizeb = false } \mydoc_set_keys:nn { narg } { familyb = false, shapeb = false, sizeb = false } \mydoc_set_keys:nn { oarg } { familyb = false, shapeb = false, sizeb = false } \mydoc_set_keys:nn { targ } { familyb = false, shapeb = false, sizeb = false } \mydoc_set_keys:nn { meta } { familyb = true, shapeb = true, sizeb = false } \mydoc_set_keys:nn { cs } { familyb = false, shapeb = false, sizeb = false } \__mydoc_argument_font: \mydoc_if_int:nTF {#1} { \seq_item:Nn \g__mydoc_syntax_seq {#1} } { #1 } \deriv_new_updated:NN \l__mydoc_argument_new_tl \l__mydoc_argument_updated_tl \endtabular } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \__mydoc_option_begin:n #1 { \par \bool_if:NF {#1} { \mydoc_vspace:n { 0.3 } } \@afterindentfalse \@afterheading } \cs_new_protected:Npn \__mydoc_option_end: { \seq_clear:N \l__mydoc_option_seq \clist_gclear:c { g__mydoc_values_default_clist } \par \noindent \ignorespacesafterend } \cs_new_protected:Npn \__mydoc_option_margin:n #1 { \seq_set_from_clist:Nn \l__mydoc_option_seq {#1} \int_gzero:N \g__mydoc_option_int \mydoc_margin:n { \tabular[t]{ @{} r @{} } \seq_map_inline:Nn \l__mydoc_option_seq { \int_gincr:N \g__mydoc_option_int \__mydoc_option_font: ##1 \mydoc_index_key:nnn {##1} { option } { option } \int_compare:nNnF { \g__mydoc_option_int } = { \seq_count:N \l__mydoc_option_seq } { \\ } } \deriv_new_updated:NN \l__mydoc_option_new_tl \l__mydoc_option_updated_tl \endtabular } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \__mydoc_values_begin: { \ignorespaces } \cs_new_protected:Npn \mydoc_values:n #1 { \seq_gset_from_clist:Nn \g__mydoc_values_seq {#1} \__mydoc_values_font: \seq_use:Nn \g__mydoc_values_seq { ,~} \exp_args:Nf \tl_if_novalue:nF { \clist_item:Nn \g__mydoc_values_default_clist { 1 } } { \hfill \mydoc_clist_use:n { values } } } \cs_new_protected:Npn \mydoc_clist_use:n #1 { \clist_use:cnnn { g__mydoc_#1_default_clist } { \tl_use:c { l__mydoc_#1_sepa_tl } } { \tl_use:c { l__mydoc_#1_sepb_tl } } { \tl_use:c { l__mydoc_#1_sepc_tl } } } \cs_new_protected:Npn \__mydoc_values_end: { \par \mydoc_vspace:n { 0.2 } \noindent \ignorespacesafterend } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareDocumentEnvironment{example}{ s o b } { \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { example } {#2} } \__mydoc_example_begin:nn {#1} {#3} } { \__mydoc_example_end: } \cs_new_protected:Npn \__mydoc_example_end: { \endtabular \endcenter } \cs_new_protected:Npn \__mydoc_example_begin:nn #1 #2 { \seq_set_split:Nnn \l__deriv_example_seq { \\ } {#2} \bool_if:NTF \l__mydoc_example_result_bool { \bool_if:nTF {#1} { \center \tabular{ @{} c @{} } \__mydoc_example_content_star:N \l__deriv_example_seq } { \center \tabular{ @{} r c l @{} } \__mydoc_example_content:N \l__deriv_example_seq } } { \renewcommand{\arraystretch}{0} \center \tabular{ @{} >{\arraybackslash}l @{} } \__mydoc_example_content_nores:N \l__deriv_example_seq } } \cs_new_protected:Npn \__mydoc_example_content:N #1 { \int_gzero:N \g__mydoc_example_int \seq_map_inline:Nn #1 { \int_gincr:N \g__mydoc_example_int \__mydoc_example_font: \__mydoc_print:n {##1} & $\Longrightarrow$ & $\displaystyle ##1$ \int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 } { \\ \addlinespace[0.5em] } } } \cs_new_protected:Npn \__mydoc_example_content_star:N #1 { \int_gzero:N \g__mydoc_example_int \seq_map_inline:Nn #1 { \int_gincr:N \g__mydoc_example_int \__mydoc_example_font: \__mydoc_print:n {##1} \\[0.5em] $\Longrightarrow \qquad \displaystyle ##1$ \int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 } { \\ \addlinespace[0.5em] } } } \cs_new_protected:Npn \__mydoc_example_content_nores:N #1 { \int_gzero:N \g__mydoc_example_int \seq_map_inline:Nn #1 { \int_gincr:N \g__mydoc_example_int \__mydoc_example_font: \__mydoc_print:n {##1} \int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 } { \\ \addlinespace[0.4em] } } } \tl_new:N \l__mydoc_print_tmp_tl \seq_new:N \l__deriv_print_seq \str_new:N \l__deriv_print_str \cs_new_protected:Npn \__mydoc_print:n #1 { \tl_set:Nn \l__mydoc_print_tmp_tl {#1} \regex_replace_all:nnN { . } { \c{string} \0 } \l__mydoc_print_tmp_tl \str_set:Nx \l__deriv_print_str \l__mydoc_print_tmp_tl \__deriv_split_at_star:NN \l__deriv_print_seq \l__deriv_print_str } \cs_new_protected:Npn \__mydoc_inlinecode:n #1 { \lstinline[style=inlinestyle]$#1$ } \cs_new_protected:Npn \__deriv_split_at_star:NN #1 #2 { \seq_set_split:NnV \l_tmpa_seq {*} #2 \bool_set_false:N \l__mydoc_star_bool \seq_clear:N \l__deriv_print_seq \seq_indexed_map_inline:Nn \l_tmpa_seq { \str_if_eq:eeTF { \tl_item:nn {##2} {-1} } { - } { \bool_set_true:N \l__mydoc_star_bool \__mydoc_inlinecode:n {##2*} } { \int_compare:nNnTF {##1} = { 1 } { \__mydoc_inlinecode:n {##2} } { \bool_if:NTF \l__mydoc_star_bool { \bool_set_false:N \l__mydoc_star_bool \__mydoc_inlinecode:n {##2} } { \hspace{0.7pt}\__mydoc_inlinecode:n {*##2} } } } } } %\bool_if:NTF \l__mydoc_star_bool %{ % \seq_put_right:Nn #1 {*##2} % \bool_set_false:N \l__mydoc_star_bool %} %{ \seq_put_right:Nn #1 {##2} } \NewDocumentCommand{\inlinecode}{ m } { \group_begin: \__mydoc_print:n {#1} \group_end: } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareDocumentEnvironment{function}{ s m o } { \tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { function } {#3} } \__mydoc_function_begin:n {#1} \__mydoc_function_margin:n {#2} } { \__mydoc_function_end: } \DeclareDocumentEnvironment{syntax}{ o b } { \tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { syntax } {#1} } \__mydoc_syntax_begin: \mydoc_syntax:n {#2} } { \__mydoc_syntax_end: } \DeclareDocumentEnvironment{argument}{ s m o } { \tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { argument } {#3} } \__mydoc_argument_begin:n {#1} \__mydoc_argument_margin:n {#2} } { \__mydoc_argument_end: } \DeclareDocumentEnvironment{option}{ s m o } { \tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { option } {#3} } \__mydoc_option_begin:n {#1} \__mydoc_option_margin:n {#2} } { \__mydoc_option_end: } \DeclareDocumentEnvironment{values}{ o b } { \tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { values } {#1} } \__mydoc_values_begin: \mydoc_values:n {#2} } { \__mydoc_values_end: } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareDocumentCommand{\default}{ s O{values} } { \group_begin: \mydoc_default:nn {#1} {#2} \group_end: } \cs_new_protected:Npn \mydoc_default:nn #1 #2 { \bool_if:nTF {#1} { \clist_use:cnnn { g__mydoc_#2_default_clist } {~and~} { ,~} {~and~} } { \clist_use:cn { g__mydoc_#2_default_clist } { ,~} } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareDocumentCommand{\macro}{ o m o } { \group_begin: \tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { macro } { #1 } } \mydoc_macro:nn {#2} {#3} \group_end: } \cs_new_protected:Npn \mydoc_macro:nn #1 #2 { \__mydoc_macro_font: \mydoc_if_int:nTF {#1} { \tl_set:Nx \l__mydoc_marg_tl { \seq_item:Nn \l__mydoc_function_seq {#1} } \mydoc_cs_to_str:x { \seq_item:Nn \l__mydoc_function_seq {#1} } \exp_args:NV \mydoc_index_cs:Nnn \l__mydoc_marg_tl { macro } { macro } } { \mydoc_cs_to_str:N #1 \mydoc_index_cs:Nnn #1 { macro } { macro } } \tl_if_novalue:nF {#2} { \seq_set_from_clist:Nn \l__mydoc_macro_arg_seq {#2} \seq_map_function:NN \l__mydoc_macro_arg_seq \mydoc_arg:n } } \DeclareDocumentCommand{\arg}{ o m } { \group_begin: \mydoc_arg:n {#2} \group_end: } \cs_new_protected:Npn \mydoc_arg:n #1 { \__mydoc_arg_font: \mydoc_if_int:nTF {#1} { \seq_item:Nn \g__mydoc_syntax_seq {#1} } { #1 } } \DeclareDocumentCommand{\key}{ O{index=false} m } { \group_begin: \tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { key } {#1} } \mydoc_key:n {#2} \group_end: } \AfterEndPreamble{ \DeclareDocumentCommand{\val}{ s o m } { \group_begin: \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { val } {#2} } \bool_if:nTF {#1} { \mydoc_val_star:n {#3} } { \mydoc_val:n {#3} } \group_end: } } \DeclareDocumentCommand{\keyval}{ s o m m } { \group_begin: \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { key } {#2} } \bool_if:nTF {#1} { \mydoc_keyval_star:nn {#3} {#4} } { \mydoc_keyval:nn {#3} {#4} } \group_end: } \cs_new_protected:Npn \mydoc_key:n #1 { \__mydoc_key_font: #1 \mydoc_index_key:nnn {#1} { key } { option } } \cs_new_protected:Npn \mydoc_val:n #1 { \__mydoc_key_font: #1 } \cs_new_protected:Npn \mydoc_val_star:n #1 { \__mydoc_key_font: \{ #1 \} } \cs_new_protected:Npn \mydoc_keyval:nn #1 #2 { \group_begin: \mydoc_key:n {#1} = \mydoc_val:n {#2} \group_end: } \cs_new_protected:Npn \mydoc_keyval_star:nn #1 #2 { \group_begin: \mydoc_key:n {#1} = \mydoc_val_star:n {#2} \group_end: } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_protected:Npn \mydoc_index_cs:Nnn #1 #2 #3 { \tl_set:Nf \l_mydoc_index_item_tl { \cs_to_str:N #1 } \tl_set:Nx \l_mydoc_index_entry_tl { \cstostr{#1} } \tl_set:Nf \l_mydoc_index_item_tl { \str_uppercase:f { \tl_head:N \l_mydoc_index_item_tl } } \bool_if:cT { l__mydoc_#2_index_bool } { \bool_if:cTF { l__mydoc_#2_definition_bool } { \mydoc_index:VVnn \l_mydoc_index_item_tl \l_mydoc_index_entry_tl {#3} { textbf } } { \mydoc_index:VVnn \l_mydoc_index_item_tl \l_mydoc_index_entry_tl {#3} { textnormal } } } } \cs_new_protected:Npn \mydoc_index_key:nnn #1 #2 #3 { \seq_set_split:Nnn \l__mydoc_index_seq { - } {#1} \mydoc_if_novalue:vTF { l__mydoc_#2_cat_tl } { \tl_set:Nx \l_mydoc_index_item_tl { \seq_item:Nn \l__mydoc_index_seq {1} } } { \tl_set_eq:Nc \l_mydoc_index_item_tl { l__mydoc_#2_cat_tl } } \tl_set:Nx \l_mydoc_index_subitem_tl {#1} \tl_set:Nx \l_mydoc_index_entry_tl {#1} \tl_replace_all:Nnn \l_mydoc_index_subitem_tl { ! } { "! } \tl_replace_all:Nnn \l_mydoc_index_entry_tl { ! } { "! } \bool_if:cT { l__mydoc_#2_index_bool } { \bool_if:cTF { l__mydoc_#2_definition_bool } { \mydoc_index:VVVnn \l_mydoc_index_item_tl \l_mydoc_index_subitem_tl \l_mydoc_index_entry_tl {#3} { textbf } } { \mydoc_index:VVVnn \l_mydoc_index_item_tl \l_mydoc_index_subitem_tl \l_mydoc_index_entry_tl {#3} { textnormal } } } } \prg_new_conditional:Npnn \mydoc_if_novalue:n #1 { TF } { \token_if_macro:NTF {#1} { \exp_args:NV \tl_if_novalue:nTF {#1} { \prg_return_true: } { \prg_return_false: } } { \tl_if_novalue:nTF {#1} { \prg_return_true: } { \prg_return_false: } } } \prg_generate_conditional_variant:Nnn \mydoc_if_novalue:n { v } { TF } \cs_new_protected:Npn \mydoc_index:nnnn #1 #2 #3 #4 { \index[#3]{#1@\protect{#2}|#4} } \cs_new_protected:Npn \mydoc_index:nnnnn #1 #2 #3 #4 #5 { \index[#4]{#1!#2@#3|#5} } \cs_generate_variant:Nn \mydoc_index:nnnnn { VVV } \cs_generate_variant:Nn \mydoc_index:nnnn { VV } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareDocumentCommand{\tsb}{ m }{ \textsubscript{#1} } \DeclareDocumentCommand{\meta}{ m } { \ensuremath{\langle} \group_begin: \__mydoc_meta_font: #1 \group_end: \ensuremath{\rangle} } \DeclareDocumentCommand{\marg}{ m } { \group_begin: \mydoc_marg:n {#1} \group_end: } \DeclareDocumentCommand{\narg}{ m } { \group_begin: \mydoc_narg:n {#1} \group_end: } \DeclareDocumentCommand{\oarg}{ s m } { \group_begin: \bool_if:nTF {#1} { \mydoc_oarg_star:n {#2} } { \mydoc_oarg:n {#2} } \group_end: } \DeclareDocumentCommand{\earg}{ m } { \group_begin: \mydoc_earg:n {#1} \group_end: } \DeclareDocumentCommand{\targ}{ m } { \group_begin: \mydoc_targ:n {#1} \group_end: } \DeclareDocumentCommand{\sarg}{ } { \group_begin: \mydoc_sarg: \group_end: } \DeclareDocumentCommand{\cs}{ m } { \group_begin: \mydoc_cs:n {#1} \group_end: } \DeclareDocumentCommand{\csverb}{ v } { \group_begin: \mydoc_csverb:n {#1} \group_end: } \cs_new:Npn \mydoc_marg:n #1 { \__mydoc_marg_font: \mydoc_arg_delim_format:n { \{ } \meta{#1} \mydoc_arg_delim_format:n { \} } } \cs_new:Npn \mydoc_narg:n #1 { \__mydoc_narg_font: \mydoc_arg_delim_format:n { \{ } #1 \mydoc_arg_delim_format:n { \} } } \cs_new:Npn \mydoc_oarg:n #1 { \__mydoc_oarg_font: \mydoc_arg_delim_format:n { [ } \meta{#1} \mydoc_arg_delim_format:n { ] } } \cs_new:Npn \mydoc_oarg_star:n #1 { \__mydoc_oarg_font: \mydoc_arg_delim_format:n { [ } #1 \mydoc_arg_delim_format:n { ] } } \cs_new:Npn \mydoc_earg:n #1 { \seq_set_from_clist:Nn \l__deriv_earg_seq {#1} \int_zero:N \l__mydoc_earg_int \seq_map_inline:Nn \l__deriv_earg_seq { \int_incr:N \l__mydoc_earg_int \int_if_odd:nTF \l__mydoc_earg_int { \mydoc_arg_delim_format:n {##1} } { \mydoc_marg:n {##1} } } } \cs_new:Npn \mydoc_targ:n #1 { \__mydoc_targ_font: \mydoc_arg_delim_format:n {#1} } \cs_new:Npn \mydoc_sarg: { \mydoc_targ:n { * } } \cs_new:Npn \mydoc_cs:n #1 { \__mydoc_cs_font: \mydoc_arg_delim_format:n { \\#1 } } \cs_new:Npn \mydoc_csverb:n #1 { \__mydoc_cs_font: \group_begin: \ttfamily #1 \group_end: } \cs_new:Npn \mydoc_arg_delim_format:n #1 { \group_begin: \ttfamily \char` #1 \group_end: } \DeclareDocumentCommand{\low}{ O{0,0} m m } { \seq_set_from_clist:Nn \l__low_seq {#1} \mskip -\seq_item:Nn \l__low_seq {1} mu \underbracket { \mskip \seq_item:Nn \l__low_seq {1} mu \vphantom{f} #2 \mskip \seq_item:Nn \l__low_seq {2} mu } \sb{\text{#3}} \mskip -\seq_item:Nn \l__low_seq {2} mu } \DeclareDocumentCommand{\ms}{ m } { {\scriptstyle\langle\texttt{#1}\rangle} } \DeclareDocumentCommand{\here}{} { {\scriptstyle\langle\texttt{here}\rangle} } \cs_new_protected:Npn \mydoc_cs_to_str:N #1 { \char` \\ \cs_to_str:N #1 } \cs_new_protected:Npn \mydoc_cs_to_str:n #1 { \char` \\ \cs_to_str:N #1 } \cs_generate_variant:Nn \mydoc_cs_to_str:n { x } \DeclareDocumentCommand{\cstostr}{ m } { \mydoc_cs_to_str:N #1 } \ExplSyntaxOff \makeatother \Pakkenavn{derivative} \Titel{The \pakkenavn{} package} \Forfatter{Simon Jensen} \Email{sjelatex@gmail.com} \Dato{2024/02/08} \Version{1.4} \RequirePackage{derivative}[\dato] \hypersetup { final = true, bookmarksnumbered = true, colorlinks = true, linkcolor = RoyalRed, urlcolor = RoyalBlue, pdfauthor = \forfatter, pdftitle = \titel, pdfencoding = unicode } \listfiles \setlength{\marginparwidth}{126pt} % 74.68849pt \setlength{\marginparpush}{0pt} % 5.39996pt \makeindex[name=option, title=Index of Options, intoc=true] \makeindex[name=macro, title=Index of Commands, intoc=true] \indexsetup{level=\subsection*, noclearpage=false, toclevel=subsection} \directlua{ pdf.setmajorversion(2) pdf.setminorversion(0) } \begin{document} \forside{The \mypackage{} package provides a set of commands which makes writing ordinary and partial derivatives of arbitrary order in a straight forward manner. Additionally, this package provides a set of commands to define variants of the aforementioned derivatives. A set of optional arguments along with lots of package options allow for easy and great flexibility over the derivative's format, such as where the function is positioned, point of evaluation, and switching between fraction styles. Moreover, the mixed order of the partial derivative and variants hereof is automatically computed. This package is written in the \pkg{expl3} language and requires therefore the \LaTeX3 package bundles \pkg{l3kernel} and \pkg{l3package}. Additionally, the \pkg{mleftright} package is optional and provides the improved automatically scaling \cs{mleft} and \cs{mright}.} \clearpage \tableofcontents \clearpage \section{Introduction} This package originated as a personal package I developed several years ago for various projects. Initially written in \tex{} and \latex{}, it encountered numerous errors as its complexity grew, eventually becoming a convoluted code. Consequently, I rewrote the code using the \latex3 language, allowing for easier maintenance. Originally, I created this package due to the lack of robust derivative packages available. However, I later discovered the \pkg{diffcoeff} package, which served the purpose well. Unfortunately, by that time, I had already written a most of the code, undocumented. To address this, I decided to document the code and transform it into a publicly available package. \bigskip Regarding terminology, I use the abbreviation \texttt{inf} to represent the operator symbols $d, \partial, \delta$, etc., commonly used in derivatives (e.g., $\odv{y}{x}, \pdv{y}{x}, \fdv{y}{x}$) and differentials (e.g., $\odif{x}, \pdif{x}, \fdif{x}$). In the description of macros and options, I often use the notation \emph{cs-\meta{placeholder}} to indicate a comma-separated list of \meta{placeholder}. For instance, \oarg{cs-numbers} is used in the option section to denote a comma-separated list of numbers for math space keys. It is important to note that whenever an argument specifies \meta{keyvalue list}, it refers to a comma-separated list of key-value pairs. \bigskip \noindent The GitHub repository for this package can be accessed at:\\ \href{https://github.com/sjelatex/derivative}{www.github.com/sjelatex/derivative}. \clearpage \section{Derivative}\label{sec:derivative} \begin{function}*{\pdv}[updated=v1.3] \begin{syntax} \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \targ{!}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}} \end{syntax} The partial derivative is defined using the \macro{1} command, which has both mandatory and optional arguments. These arguments allow for the customization of specific parts and the style of the derivative. \begin{definition} \DeclareDerivative{\pdv}{\partial}[style-var=multiple, style-var-/=multiple, style-var-!=mixed, style-var-/!=multiple, delims-eval=(), delims-eval-/=(), delims-eval-!=()] \end{definition} \begin{argument}*{1} The optional first argument of \macro{1} controls the placement of the function in relation to the fraction. By setting \keyval{switch-*}{false}, the function is typeset in the numerator when the star is absent, and next to the fraction when the star is present. Here is an example: \begin{example} \pdv{f}{x,y} \\ \pdv*{f}{x,y} \end{example} The behavior of the star can be reversed by setting \keyval{switch-*}{true}. In other words, the equations in the previous example will be interchanged. \end{argument} \begin{argument}{2}[updated = v1.4] The second argument of \macro{1}, enclosed in square brackets, is optional and used to specify options for the derivative using a \keyval[index=false]{key}{value} syntax. For instance, the order of differentiation can be set using the \key[cat=misc]{order} option. Here is an example: \begin{example} \pdv[order={2,3}]{f}{x,y,z} \\ \pdv[order={\beta,a,n+2a}]{f}{x,y,z} \\ \pdv[sep-var-inf=0]{f}{x,y,z} \\ \pdv[order={3/2-n/3,n/2,1/3}]{f}{x,y,z} \end{example} To ease the cumbersome order key, implicit orders can now be given: \begin{example} \pdv[n+2, \alpha]{f}{x,y,z} \end{example} For a comprehensive list of available options that can be applied to derivatives, please refer to \cref{ssec:options_dv}. %The order may be a number, a symbol and a combination hereof. Note that the total order of differentiation (i.e $\odif[order=n+2]{}$) is automatically calculated and sorted. This is particularly useful when dealing with mixed partial derivatives which is further described in \cref{ssec:DV_pdv,ssec:overall_order} \end{argument} \begin{argument}{3} The first mandatory argument of \macro{1} is used to typeset the function that will be differentiated. Here are some examples: \begin{example} \pdv{f(x,y,z)}{x,y,z} \\ \pdv{e^x\sin(y)\ln(z)}{x,y,z} \end{example} The function is displayed either in the numerator or to the right of the derivative, depending on the presence or absence of the star argument. \end{argument} \begin{argument}{4}[updated = v1.3] The fourth argument of \macro{1} is an optional slash that appears between the function and the variable arguments, indicating an alternative style. Its behaviour depends on the presence or absence of the exclamation mark argument. When the exclamation mark is absent, the slash determines the fraction style in which the derivative is typeset. By default, when the slash is absent, the derivative is typeset with \cs{frac}, and when the slash is present, it is typeset with \cs{slashfrac}\footnote{Note that \cs{slashfrac} is a macro defined by the package, please refer to \cref{ssec:slashfrac} for more details.\label{foot:sfrac}}, as shown in the following example: \begin{example} \pdv{f}{x,y} \\ \pdv{f}/{x,y} \end{example} However, when the exclamation mark argument is present, the slash argument switches between shorthand styles rather than fraction styles. Similar to the star argument, the effect of the slash's presence can be reversed by setting \keyval{switch-/}{true}. In other words, the equations in the previous example will be interchanged. \end{argument} \begin{argument}{5}[new = v1.3] The fifth argument of \macro{1} is an optional exclamation mark that appears between the function and the variable arguments. It allows switching the derivative into shorthand style, as described in \cref{ssec:options_dv}. When \keyval{switch-!}{false} is used, along with the \macro{1}'s default shorthand styles, the derivative is typeset as shown in the example below: \begin{example} \pdv{f}!{x,y} \\ \pdv{f}/!{x,y} \end{example} The effect of the exclamation mark's presence can be reversed by setting \keyval{switch-!}{true}. In other words, the equations in the previous example will be interchanged. \begin{note} The order of the slash and exclamation mark is important. For example, \cs{pdv}\narg{f}\targ{!}\targ{/}\narg{x,y} will give $\pdv{f}!/{x,y}$ and not the indented output $\pdv{f}/!{x,y}$. \end{note} \end{argument} \begin{argument}{6} This is the second and final mandatory argument is used to typeset the variable in which the function is differentiated with respect to. The variables should be provided as a comma-separated list \begin{example} \pdv{f}{x} \\ \pdv{f}{x,y} \end{example} \end{argument} \clearpage \begin{argument}{7} The last optional argument specifies the point(s) of evaluation or variables held constant. It is an \emph{e-type} argument from the \pkg{xparse} package, denoted as \verb|e{_^}|. This means that the subscript \verb|_| and superscript \verb|^| accepts an argument given within braces. The order of the subscript and superscript is independent, as shown in the following examples: \begin{example} \pdv{f}{x,y}_{(x_1,y_1)} \\ \pdv{f}{x,y}^{(x_2,y_2)} \\ \pdv{f}{x,y}_{(x_1,y_1)}^{(x_2,y_2)} \\ \pdv{f}{x,y}^{(x_2,y_2)}_{(x_1,y_1)} \end{example} The subscript argument is commonly used to indicate the point of evaluation or the variables held constant. If needed, the superscript argument can be used to denote a second point of evaluation. \end{argument} \end{function} \subsection{Other derivatives} In addition to the partial derivative, the package also provides five other derivative commands: \begin{itemize} \item Ordinary derivative: \macro{\odv} - Used to represent the rate of change of a single-variable function with respect to its independent variable. \item Material derivative: \macro{\mdv} - Applied in fluid mechanics and continuum mechanics to describe the rate of change of a quantity attached to a moving fluid particle. \item Functional derivative: \macro{\fdv} - Used in functional analysis, calculus of variations, and quantum mechanics to express the derivative of a functional. \item Average rate of change: \macro{\adv} - Used to denote the average rate of change of a quantity over a given interval. \item Jacobian: \macro{\jdv} - Significant in multivariable calculus and linear algebra for representing the derivative of a vector-valued function. \end{itemize} A unique feature of this package is that it allows you to define your own derivatives, as described in \cref{ssec:defvar_dv}. This means you can create custom derivative commands tailored to your specific needs. If you require more information on the usage and customization of these derivative commands, please refer to the documentation in \cref{ssec:defvar_dv}. \clearpage \begin{function}{\odv}[updated=v1.1] \begin{syntax} \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}} \end{syntax} In this package, the ordinary derivative is defined with an upright lowercase d if the package option \keyval[cat=misc]{upright}{true} is used. Otherwise, it is defined with an italic lowercase \textit{d}. This choice was made to align with the convention used in many modern books. \begin{definition} \DeclareDerivative{\odv}{\mathrm{d}}%\marginnote{\keyval[cat=misc]{upright}{true}}% \DeclareDerivative{\odv}{\mathnormal{d}}%\marginnote{\keyval[cat=misc]{italic}{true}}% \end{definition} \noindent The ordinary derivative can then be typeset as: \begin{equation*} \odv{f}{x} = \lim_{h\to 0} \mleft( \frac{ f(x+h) - f(x) }{ h } \mright) \end{equation*} By adjusting the \key{style-inf} or \key{style-inf-num} and \key{style-inf-den} keys, the operator d can be customized to personal preference or specific formatting requirements. \end{function} \begin{function}{\mdv}[updated=v1.1] \begin{syntax} \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}} \end{syntax} The material derivative is defined with an upright uppercase D when the package option \keyval[cat=misc]{upright}{true}. Otherwise, it is defined with an italic uppercase D. \begin{definition} \DeclareDerivative{\mdv}{\mathrm{D}}%\marginnote{\keyval[cat=misc]{upright}{true}}% \DeclareDerivative{\mdv}{\mathnormal{D}}%\marginnote{\keyval[cat=misc]{italic}{true}}% \end{definition} \noindent In physics, the material derivative is defined by \begin{equation*} \mdv{ \varphi(\symbf{r}, t) }{ t } \coloneq \pdv{ \varphi(\symbf{r}, t) }{ t } + \dot{\symbf{r}} \cdot \nabla \varphi(\symbf{r}, t) \end{equation*} By adjusting the \key{style-inf} or \key{style-inf-num} and \key{style-inf-den} keys, the operator D can be customized to personal preference or specific formatting requirements. \end{function} \begin{function}{\fdv} \begin{syntax} \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}} \end{syntax} In this package, the functional derivative is defined with a lowercase delta. By default, it is represented in italic form. The functional derivative can be defined as follows: \begin{definition} \DeclareDerivative{\fdv}{\delta} \end{definition} \noindent In physics, the functional derivative is commonly employed in various equations, such as the Lagrange equation and the derivation of the Hartree-Fock equation. Examples of its usage include: \begin{equation*} \fdv{I}{q_{\alpha}} = \pdv{L}{q_{\alpha}} - \odv*{ \pdv{L}{ \dot{q}_{\alpha} } } { t } = 0, \qquad \fdv{ \symcal{L} }{ \psi_{n}^* } = \hat{F} \ket{\psi_{n}} - \epsilon_{n} \ket{\psi_{n}} = 0 , \end{equation*} \end{function} \begin{function}{\adv} \begin{syntax} \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}} \end{syntax} The average rate of change is defined to use an upright uppercase delta with the default settings. In this package, the average rate of change is defined as \begin{definition} \DeclareDerivative{\adv}{\Delta} \end{definition} \noindent The average rate of change can be expressed as \begin{equation*} \adv{ y }{ x } = \frac{y_2- y_1}{x_2 - x_1} \end{equation*} \end{function} \begin{function}{\jdv}[updated = v1.0] \begin{syntax} \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}} \end{syntax} In this package, the Jacobian is defined with an italic partial differential by default. Additionally, a pair of parentheses is automatically inserted around the function and variable. \begin{definition} \DeclareDerivative{\jdv}{\partial}[fun=true, var=1] \end{definition} \noindent which gives \begin{equation*} \jdv{f,g,h}{x,y,z} \end{equation*} \end{function} \clearpage \section{Differentials}\label{sec:differential} \begin{function}*{\odif}[new = v1.0, updated=v1.1] \begin{syntax} \sarg, \oarg{keyval list}, \marg{variables} \end{syntax} The differential \macro{1} is defined with both mandatory and optional arguments that allow for customizing its typesetting and style. It is defined with an upright lowercase d when \keyval[cat=misc]{upright}{true} is used. Otherwise, it will be defined with an italic lowercase d. \begin{definition} \DeclareDifferential{\odif}{\mathrm{d}}%\marginnote{\keyval[cat=misc]{upright}{true}}% \DeclareDifferential{\odif}{\mathnormal{d}}%\marginnote{\keyval[cat=misc]{italic}{true}}% \end{definition} \begin{argument}*{1} The first argument of \macro{1} is an optional star that determines the notation style of the differential. With the \keyval{switch-*}{false} option, the variables and orders are typeset as subscript and superscript, respectively, when the star is present. When the star is absent, the infinitesimal is placed in front of each variable, as illustrated below: \begin{example} \odif{x,y,z} \\ \odif*{x,y,z} \end{example} The behavior of the star can be reversed by setting \keyval{switch-*}{true}. In other words, the equations in the previous example will be interchanged. \end{argument} \begin{argument}{2}[updated = v1.4] The second argument, enclosed in square brackets, is optional and is used to specify options for the differential using the \keyval[index=false]{key}{value} syntax. Here are some examples: \begin{example} \odif[order={n,3}]{x,y,z} \\ \odif[sep-var-inf=0]{x,y,z} \\ \odif*[sep-var-var=0]{x,y,z} \end{example} To ease the cumbersome order key, implicit orders can now be given: \begin{example} \odif[n+2, \alpha]{x,y,z} \end{example} For a comprehensive list of available options that can be applied to differentials, please refer to \cref{ssec:options_inf} \end{argument} \begin{argument}{3} The mandatory argument is used to typeset the variables in the differential. Here are some examples: \begin{example} \odif{x} \\ \odif{s_1,s_2...,s_n} \end{example} \end{argument} \end{function} \subsection{Other differentials} In addition to the regular differential, the package also provides four other differential commands: \begin{itemize} \item Partial differential: \macro{\pdif} - This command is used to typeset partial differentials. \item Uppercase D: \macro{\mdif} - It is used to typeset differentials with an uppercase "D". \item Lowercase delta: \macro{\fdif} - This command is used to typeset differentials with a lowercase delta symbol. \item Uppercase delta: \macro{\adif} - It is used to typeset differentials with an uppercase Delta symbol. \end{itemize} A unique feature of this package is that it allows you to define your own differentials, as described in \cref{ssec:defvar_inf}. This means you can create custom differential commands tailored to your specific needs. If you require more information on the usage and customization of these differential commands, please refer to the documentation in \cref{ssec:defvar_inf}. %This package offers four other differentials: partial differential \macro{\pdif}, uppercase D \macro{\mdif}, delta \macro{\fdif} and Delta \macro{\adif}. A unique feature of this package, is that you can define your own differential as described in \cref{ssec:defvar_inf}. \begin{function}{\pdif} \begin{syntax} \sarg, \oarg{keyval list}, \marg{variables} \end{syntax} The partial differential \macro{1} is commonly used as a shorthand notation for the partial derivative. In this package, it is defined as follows: \begin{definition} \DeclareDifferential{\pdif}{\partial}[style-notation=single, style-notation-*=mixed] \end{definition} \noindent The non-star and star versions are represented on the left side as: \begin{align*} \pdif[order={i,j,k}]{x,y,z} &\coloneq \pdv[order={i,j,k}]{}{x,y,z} \\ \pdif*[order={i,j,k}]{x,y,z} &\coloneq \pdv[order={i,j,k}]{}{x,y,z} \end{align*} respectively. \end{function} \begin{function}{\mdif}[updated=v1.1] \begin{syntax} \sarg, \oarg{keyval list}, \marg{variables} \end{syntax} Another commonly used shorthand notation for derivatives is the differential with an uppercase D. In this package it is defined with a upright D when \keyval[cat=misc]{upright}{true}. Otherwise, it is defined with an italic D. \begin{definition} \DeclareDifferential{\mdif}{\mathrm{D}}[style-notation=single, style-notation-*=mixed]%\marginnote{\keyval[cat=misc]{upright}{true}}% \DeclareDifferential{\mdif}{\mathnormal{D}}[style-notation=single, style-notation-*=mixed%\marginnote{\keyval[cat=misc]{italic}{true}}% \end{definition} \noindent The non-star and star version gives \begin{align*} \mdif[order={i,j,k}]{x,y,z} \\ \mdif*[order={i,j,k}]{x,y,z} \end{align*} respectively. \end{function} \begin{function}{\fdif} \begin{syntax} \sarg, \oarg{keyval list}, \marg{variables} \end{syntax} When working with functional derivatives, another commonly used differential is one that uses a delta symbol. It is defined as follows: \begin{definition} \DeclareDifferential{\fdif}{\delta} \end{definition} \noindent For example, in expression like: \begin{align*} \fdif{J} = \int_{a}^{b} \pdv{L}{f} \fdif{f(x)} + \pdv{L}{f'} \odv*{ \fdif{f(x)} }{x} \odif{x} \end{align*} this differential is frequently encountered. \end{function} \begin{function}{\adif} \begin{syntax} \sarg, \oarg{keyval list}, \marg{variables} \end{syntax} A differential for differences that uses a uppercase delta is defined as \begin{definition} \DeclareDifferential{\adif}{\Delta} \end{definition} \noindent For example, the difference between two energy levels can be written as: \begin{align*} \adif{E} = E_2 - E_1 \end{align*} \end{function} \clearpage \section{Options} This package accepts its options using the familiar \emph{key=value} syntax. The keys are divided into categories, with each key having its associated category as a prefix. \begin{function}{\derivset}[updated = v1.0] \begin{syntax} \marg{command}, \oarg{keyval list} \end{syntax} The \macro{1} command is used to set default values for derivative and differential options in the preamble. While it can be used within the document, the new \oarg{keyval list} arguments in the derivative and differential commands allow for more flexibility in specifying options on a per-use basis. \begin{argument}{1} The mandatory argument determines which command the \emph{key=value} pairs are assigned to. The allowed \meta{commands} are the derivatives and differentials defined by the package, as well as any additional derivatives and differentials you have defined (see \cref{ssec:defvar_dv,ssec:defvar_inf} for more information). Additionally, the special value \texttt{all} is allowed, which provides access to the options that apply to all derivatives and differentials. \begin{example} \derivset{\odv}[switch-*=true] \odv{y}{x} \\ \derivset{\odif}[switch-*=true] \odif{y}{x} \end{example} \end{argument} \begin{argument}{2} The optional argument accepts input as a comma-separated list of \emph{key=value} pairs. If \arg{2} is omitted, the options will be set to the package's default settings for the chosen \arg{1}. For example, using the \macro{\derivset}[\narg{\macro{\odv}}] command will set the options for the ordinary derivative to the default settings defined by the package. \begin{example} \derivset{\odv}[switch-*=false] \odv{y}{x} \odv*{y}{x} \\ \derivset{\odv}[switch-*=true] \odv{y}{x} \odv*{y}{x} \\ \derivset{\odv} \odv{y}{x} \odv*{y}{x} \end{example} \end{argument} \end{function} \subsection{Categories} This section seeks to give a detailed description of each category. \begin{itemize} \item The \key[index=false]{style-\meta{\dots}} keys allow you to customize the style of derivatives or differentials by specifying options such as the fraction command, infinitesimal notation (e.g., $d$, $\partial$) and its font, and variable treatment. \item The \key[index=false]{delims-\meta{\dots}} keys sets the delimiters used around the \meta{\dots}. The Rule of Two applies: \enquote{Always two there are, no more, no less. A left and a right delimiter}. Only delimiters that can be scaled with commands like \cs{left}, \cs{big}, etc., are allowed. \item The \key[index=false]{scale-\meta{\dots}} keys sets the size of the \meta{\dots}'s delimiters. The values \val{big}, \val{Big}, \val{bigg}, and \val{Bigg} are self-explanatory. The value \val{none} leaves the delimiters unscaled (except for periods, which are removed). The value \val{auto} automatically scales the delimiters using \cs{left} and \cs{right}. \item The \key[index=false]{sep-\meta{\dots}-\meta{\dots}} keys inserts their value between \meta{\dots} and \meta{\dots}. If the value is a comma-separated list of up to three numbers (e.g. \texttt{\{1,2,3\}}) it is converted into the syntax \texttt{\cs{muskip} 1 mu plus 2 mu minus 3 mu} and used accordingly. For other values, they are used as given without any conversion. \item The \key[index=false]{switch-\meta{\dots}} keys allow you to change the behaviour of an argument by swapping the effect of the presence or absence of an optional character argument. \item The \key[index=false]{sort-\meta{\dots}} keys handle the sorting algorithm used for the mixed order. These keys allow you to choose the sorting method that best suits your preferences. \item The miscellaneous keys do not fall into any of the previously mentioned categories and does not have a prefix. \end{itemize} \begin{note} A value with a superscripted \texttt{R} indicates that it requires a specific package to be loaded. Additionally, some keys have multiple versions, denoted by \texttt{-/}, \texttt{-!}, and \texttt{-/!} at the end. These keys are specifically related to the slash and exclamation mark arguments. \end{note} \subsection{Package options} The package options can be used with the following syntax when loading the package in the preamble: \begin{center} \ttfamily\small \cs{usepackage}\oarg{keyval list}\narg{derivative} \end{center} \begin{option}*{italic}[cat=misc, new = v1.1] \begin{values}[default = false] true, false \end{values} Sets the font style of the infinitesimals $d$ and $D$ used in \cs{odv}, \cs{mdv}, \cs{odif} and \cs{mdif} to italic using \cs{mathnormal}. The \key[cat=misc,index=false]{italic} and \key[cat=misc,index=false]{upright} options are mutually exclusive. \end{option} \begin{option}{upright}[cat=misc, new = v1.1] \begin{values}[default = true] true, false \end{values} Sets the font style of the infinitesimals $d$ and $D$ used in \cs{odv}, \cs{mdv}, \cs{odif} and \cs{mdif} to upright using \cs{mathrm}. The \key[cat=misc,index=false]{italic} and \key[cat=misc,index=false]{upright} options are mutually exclusive. \end{option} \subsection{Derivative options} \label{ssec:options_dv} The options in this subsection are available fo customizing the behaviour of derivatives defined by the package and you.% using the commands described in \cref{ssec:defvar_dv}. \subsubsection*{Style} \begin{option}*{style-inf}[updated = {v1.0, v1.3}] \begin{values}[default = ] \meta{math-font-style}\meta{infinitesimal} \end{values} Sets the infinitesimal used in the derivative. This is a meta key, which means it sets the value of both \key{style-inf-num} and \key{style-inf-den} at the same time. \begin{example} \odv[style-inf=\symbf{d}]{f}{x} \end{example} \end{option} \begin{option}{style-inf-num}[new = v1.3] \begin{values}[default = d] \meta{math-font-style}\meta{infinitesimal} \end{values} Sets the infinitesimal used in the numerator of the derivative. This option is also used in the shorthand versions, i.e., when the exclamation mark argument is used. The default infinitesimal is a plain \default. \begin{example} \odv[style-inf-num=\mathbf{d}]{f}{x} \\ \odv[style-inf-num=\mathbf{d}]{f}!{x} \end{example} \end{option} \begin{option}{style-inf-den}[new = v1.3] \begin{values}[default = d] \meta{math-font-style}\meta{infinitesimal} \end{values} Sets the infinitesimal used in the denominator of the derivative. The default infinitesimal is a plain \default. \begin{example} \odv[style-inf-den=\mathbf{d}]{f}{x} \end{example} \end{option} \begin{option}{style-frac} \begin{values}[default = \cs{frac}] \meta{fraction} \end{values} The derivative uses the fraction set by this key when the slash argument is absent. If \keyval{switch-/}{true}, the derivative uses this fraction when the slash argument is present. The key's default value is the usual fraction \cs{frac}. \begin{example} \odv[style-frac=\tfrac]{f}{x} \\ \odv[switch-/=true, style-frac=\tfrac]{f}/{x} \end{example} \end{option} \begin{option}{style-frac-/} \begin{values}[default = \cs{slashfrac}] \meta{fraction} \end{values} The derivative uses the fraction set by this key when the slash argument is present. If \keyval{switch-/}{true}, the derivative uses this fraction when the slash argument is absent. The key's default value is a text-styled fraction \val{\default}\footref{foot:sfrac} on the form $\odv[style-frac-/=\slashfrac, switch-/=false]{f}/{x}$. \begin{example} \odv[style-frac-/=\sfrac]{f}/{x} \end{example} \end{option} \begin{option}{style-var}[new = v1.0] \begin{values}[default = single] single, multiple \end{values} This option determines how the derivative treats its variables and orders when both the slash argument and the exclamation mark are absent assuming \keyval{switch-/}{false} and \keyval{switch-!}{false} \begin{itemize}[widest = {\val{multiple}}, leftmargin =*] \item[\val{single}] The derivative behaves like a ordinary derivative, treating the variable argument and order as single entities. \item[\val{multiple}] The derivative behaves like a partial derivative, treating the variable argument as a list of comma-separated variables. The mixed order is automatically calculated and sorted based on the \keyval[cat=misc]{order}{\meta{cs-orders}} key. See \cref{ssec:overall_order} for limitations on the automatic calculation. \end{itemize} %This option determines how the derivative treats its variables. The variable argument is treated as a single variable and the order is treated as a single order when \val{single} is used. The variable argument is treated as a comma separated list of variables with \val{multiple} similarly to a partial derivative. Moreover the mixed order is automatically calculated from the list of orders given in \keyval[cat=misc]{order}{\meta{order}}. \begin{example} \pdv[style-var=single, order={1,2,3}]{f}{x,y,z} \\ \pdv[style-var=multiple]{f}{x,y,z} \end{example} \end{option} \begin{option}{style-var-/}[new = v1.3] \begin{values}[default = single] single, multiple \end{values} This option behaves identically to \key{style-var}, however it is used when the slash argument is present and the exclamation mark is absent assuming \keyval{switch-/}{false} and \keyval{switch-!}{false}. \begin{example} \pdv[style-var-/=single, order={1,2,3}]{f}/{x,y,z} \\ \pdv[style-var-/=multiple]{f}/{x,y,z} \end{example} \end{option} \begin{option}{style-var-!}[new = v1.3] \begin{values}[default = multiple] single, multiple, mixed \end{values} This options determines the shorthand notation of the derivative when the slash argument is absent and the exclamation mark is present assuming \keyval{switch-/}{false} and \keyval{switch-!}{false}. \begin{itemize}[widest = {\val{multiple}}, leftmargin =*] \item[\val{single}] Creates a single differential with variables as subscripts and orders as superscripts. \item[\val{multiple}] Creates a separate differential for each variable. \item[\val{mixed}] Creates a separate differential for each variable but with variables as subscripts and orders as superscripts. \end{itemize} %When \val{single} is used, a single differential is created with the variables and orders in a subscript and superscript, respectively. The value \val{multiple} creates a differential for each variable. While the value \val{mixed} creates differentials their variable and order in a subscript and superscript, respectively. \begin{example} \pdv[style-var-!=single]{f}!{x,y,z} \\ \pdv[style-var-!=multiple]{f}!{x,y,z} \\ \pdv[style-var-!=mixed]{f}!{x,y,z} \end{example} \end{option} \begin{option}{style-var-/!}[new = v1.3] \begin{values}[default = single] single, multiple, mixed \end{values} This option behaves identical to \key{style-var-!}, however it is used when both the exclamation mark and slash arguments are present assuming \keyval{switch-/}{false} and \keyval{switch-!}{false}. \begin{example} \pdv[style-var-/!=single]{f}/!{x,y,z} \\ \pdv[style-var-/!=multiple]{f}/!{x,y,z} \\ \pdv[style-var-/!=mixed]{f}/!{x,y,z} \end{example} \end{option} \subsubsection*{Scaling} \begin{option}*{scale-eval} \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used for the point of evaluation. It is applied when the slash argument is absent, assuming \keyval{switch-/}{false}. The default behaviour is to automatically scale the delimiters. \begin{example} \pdv[scale-eval=auto]{f}{x,y}_{(x_0,y_0)}\\ \pdv[scale-eval=auto]{f}!{x,y}_{(x_0,y_0)} \end{example} \end{option} \begin{option}{scale-eval-/} \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used for the point of evaluation. It is applied when the slash argument is present, assuming \keyval{switch-/}{false}. The default behaviour is to automatically scale the delimiters. \begin{example} \pdv[scale-eval-/=none]{f}/{x,y}_{(x_0,y_0)} \end{example} \end{option} \begin{option}{scale-eval-!}[new = v1.3] \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used for the point of evaluation. It is applied when the exclamation mark argument is present, assuming \keyval{switch-!}{false}. The default behaviour is to automatically scale the delimiters. This option takes priority over \key{scale-eval-/} when the slash argument is also present. \begin{example} \pdv[scale-eval-!=Big]{f}!{x,y}_{(x_0,y_0)} \end{example} \end{option} \begin{option}{scale-fun} \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used around the function. It is applied when \keyval[cat=misc]{fun}{true}. The default behaviour is to automatically scale the delimiters. \begin{example} \pdv[scale-fun=big, fun]{f}{x,y} \end{example} \end{option} \begin{option}{scale-var} \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the exclamation mark argument is absent assuming \keyval{switch-!}{false}. The default behaviour is to automatically scale the delimiters. \begin{example} \pdv[scale-var=Big, var]{f}{x,y} \end{example} \end{option} \begin{option}{scale-var-!}[new = v1.3] \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the exclamation mark argument is present assuming \keyval{switch-!}{false}. The default behaviour is to automatically scale the delimiters. \begin{example} \pdv[scale-var-!=big, var]{f}!{x,y} \end{example} \end{option} \begin{option}{scale-frac} \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used for around the fraction. It is applied when the slash argument is absent and \keyval[cat=misc]{frac}{true}, assuming \keyval{switch-/}{false}. The default behaviour is to automatically scale the delimiters. \begin{example} \pdv[scale-frac=bigg, frac]{f}{x,y} \end{example} \end{option} \begin{option}{scale-frac-/} \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used for around the fraction. It is applied when the slash argument is present and \keyval[cat=misc]{frac}{true}, assuming \keyval{switch-/}{false}. The default behaviour is to automatically scale the delimiters. \begin{example} \pdv[scale-frac-/=Bigg, frac]{f}/{x,y} \end{example} \end{option} \subsubsection*{Delimiters} \begin{option}*{delims-eval} \begin{values}[default = .~\cs{rvert}] \meta{left delimiter}\meta{right delimiter} \end{values} Sets the delimiters used to indicate the point of evaluation. These delimiters are used when the slash argument is absent, assuming \keyval{switch-/}{false}. The key's default delimiters are a period and a vertical line. \begin{example} \pdv[delims-eval=.|]{f}{x,y}_{(x_0,y_0)} \end{example} \end{option} \begin{option}{delims-eval-/} \begin{values}[default = .~\cs{rvert}] \meta{left delimiter}\meta{right delimiter} \end{values} Sets the delimiters used to indicate the point of evaluation. These delimiters are used when the slash argument is present, assuming \keyval{switch-/}{false}. The key's default delimiters are a period and a vertical line. \begin{example} \pdv[delims-eval-/=[]]{f}/{x,y}_{(x_0,y_0)} \end{example} \end{option} \begin{option}{delims-eval-!}[new = v1.3] \begin{values}[default = .~\cs{rvert}] \meta{left delimiter}\meta{right delimiter} \end{values} Sets the delimiters used to indicate the point of evaluation. These delimiters are used when the slash argument is present, assuming \keyval{switch-!}{false}. The key's default delimiters are a period and a vertical line. This option takes priority over \key{delims-eval-/} when the slash argument is also present. \begin{example} \pdv[delims-eval-!=[]]{f}!{x,y}_{(x_0,y_0)} \end{example} \end{option} \begin{option}{delims-fun} \begin{values}[default = (~)] \meta{left delimiter}\meta{right delimiter} \end{values} Sets the delimiters used around the function. These delimiters are used when \keyval[cat=misc]{fun}{true}. The key's default delimiters are parentheses. \begin{example} \pdv[delims-fun=\langle\rangle, fun]{f}{x,y} \end{example} \end{option} \begin{option}{delims-var} \begin{values}[default = (~)] \meta{left delimiter}\meta{right delimiter} \end{values} Sets the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the exclamation mark argument is absent assuming \keyval{switch-!}{false}. The key's default delimiters are parentheses. \begin{example} \pdv[delims-var=\{\}, var]{f}{x,y} \end{example} \end{option} \begin{option}{delims-var-!}[new = v1.3] \begin{values}[default = (~)] \meta{left delimiter}\meta{right delimiter} \end{values} Sets the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the exclamation mark argument is present assuming \keyval{switch-!}{false}. The key's default delimiters are parentheses. \begin{example} \pdv[delims-var-!=\lceil\rceil, var]{f}!{x,y} \end{example} \end{option} \begin{option}{delims-frac} \begin{values}[default = (~)] \meta{left delimiter}\meta{right delimiter} \end{values} Sets delimiters used around the fraction in the derivative. These delimiters are used when the slash argument is absent and \keyval[cat=misc]{frac}{true}, assuming \keyval{switch-/}{false}. The key's default delimiters are parentheses. \begin{example} \pdv[delims-frac=||, frac]{f}{x,y} \\ \pdv*[delims-frac=||, frac=true]{y}{x} \end{example} \end{option} \begin{option}{delims-frac-/} \begin{values}[default = (~)] \meta{left delimiter}\meta{right delimiter} \end{values} Sets delimiters used around the fraction in the derivative. These delimiters are used when the slash argument is present and \keyval[cat=misc]{frac}{true}, assuming \keyval{switch-/}{false}. The key's default delimiters are parentheses. \begin{example} \pdv[delims-frac-/=\|\|, frac]{f}/{x,y} \\ \pdv*[delims-frac-/=\|\|, frac]{f}/{x,y} \end{example} \end{option} \subsubsection*{Math spacing and separators} %The options in this subsection insert additional horizontal math space or separators in specific positions. The equations below illustrates where the space is inserted for each option:%TODO - math space should probably be seperator instead %\begin{align*} % \begin{gathered} % \frac{ \partial }{ \partial x } \ms{frac-fun} f \\ % \frac{ \partial^{ \ms{inf-ord} 2 } f }{ \partial x^{ \ms{var-ord} 2 } } % \end{gathered} % && % \begin{gathered} % \frac{ \partial \ms{inf-fun} f }{ \partial \ms{inf-var} x } \\ % \frac{ \partial^3 \ms{ord-fun} f }{ \partial x^2 \ms{ord-inf} \partial y } % \end{gathered} % && % \begin{gathered} % \frac{ \partial^2 f }{ \partial x \ms{var-inf} \partial y } \\ % \mleft( \frac{ \partial f}{ \partial x } \mright)_{ \ms{eval-sb} x_1}^{ \ms{eval-sp} x_2} % \end{gathered} %\end{align*} %where it have been split into six to give a better overview. Here $\ms{\dots}$ means the value given to the option \key[index=false]{sep-\meta{\dots}}. Some of the math spaces shown above are only used when \keyval[index=false]{style-var}{multiple}. Additionally, when the option \keyval[index=false]{style-var}{single} is used then the following math space is used in the denominator %%Please note that some of the math spaces shown above are only used when \key[index=false]{style-var} is set to \val{multiple}. Additionally, when \key[index=false]{style-var} is set to \val{single}, the following math space is used in the denominator: %\begin{equation*} % \frac{\partial(f, g)}{\partial(x \ms{var-var} y)} %\end{equation*} %where the Jacobian is used as an example. \begin{option}{sep-inf-ord} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted to the left of the infinitesimal's power when the (mixed) order \emph{is different} from \num{1}. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \pdv[sep-inf-ord=\here]{f}{x,y} \\ \pdv[sep-inf-ord=\here, order=2]{f}!{x,y} \\ \pdv[sep-inf-ord=\here, order=2]{f}/!{x,y} \end{example} \end{option} \begin{option}{sep-inf-fun} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between the infinitesimal and the function when the (mixed) order \emph{is equal} to \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \pdv[sep-inf-fun=\here]{f}{x} \end{example} \end{option} \begin{option}{sep-ord-fun} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between the function and the infinitesimal's order when the order \emph{is different} from \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \pdv[sep-ord-fun=\here]{f}{x,y} \end{example} \end{option} \begin{option}{sep-frac-fun}[new = v1.0] \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between the fractional part of the derivative and the function when a non-blank function is printed \emph{next to the derivative}. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \pdv*[sep-frac-fun=\here]{f}{x,y} \end{example} \end{option} \begin{option}{sep-inf-var} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between the infinitesimal and the following non-blank variable. In shorthand mode, the order must also \emph{be different} from \num{1}. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \pdv[sep-inf-var=\here, order=2]{f}{x,y} \\ \pdv[sep-inf-var=\here, order=2]{f}!{x,y} \\ \pdv[sep-inf-var=\here, order=2]{f}/!{x,y} \end{example} \end{option} \begin{option}{sep-var-ord} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted to the left of the variable's power when its order \emph{is different} from \num{1}. The default value corresponds to \val{\default} \texttt{mu}. %This key sets the separator that is inserted in a variable's power left to the order. The space is only inserted when the order \emph{is different} from \num{1}. The key's default value corresponds to \val{\default} \texttt{mu}. \begin{example} \pdv[sep-var-ord=\here, order=n]{f}{x,y} \end{example} \end{option} \begin{option}{sep-var-inf} \begin{values}[default = \cs{mathop}\{\}\cs{!}] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between a variable and the following infinitesimal when more than one \emph{non-blank} variables are given. In fraction mode, it is also required that the variable's order \emph{is equal} to \num{1}. The default value is \val{\default}. \begin{example} \pdv[sep-var-inf=\here, order=n]{f}{x,y,z}\\ \pdv[sep-var-inf=\here, order=n]{f}!{x,y,z}\\ \pdv[sep-var-inf=\here, order=n]{f}/!{x,y,z} \end{example} \end{option} \begin{option}{sep-ord-inf} \begin{values}[default = \cs{mathop}\{\}\cs{!}] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between an order and the following infinitesimal when more than one \emph{non-blank} variables are given. In fraction mode, it is also required that the variable's order \emph{is different} from \num{1}. The default value is \val{\default}. \begin{example} \pdv[sep-ord-inf=\here, order=n]{f}{x,y,z} \end{example} \end{option} \begin{option}{sep-ord-ord}[new = v1.3] \begin{values}[default = {{,}}] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between two orders when more than one \emph{non-blank} variables are given in shorthand notation when it is set to \val{single}. The default value is a comma. \begin{example} \odv[sep-ord-ord=\here, order={n,2}]{f}/!{x,y} \end{example} \end{option} \begin{option}{sep-ord-var}[new = v1.3] \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between an order and the following variable in shorthand notation when it is set to \val{multiple}. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \odv[sep-ord-var=\here, order=n]{f}!{x,y} \end{example} \end{option} \begin{option}{sep-var-var}[new = v1.0] \begin{values}[default = {{,}}] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between two variables when more than one \emph{non-blank} variables are given in shorthand notation when it is set to \val{single}. The default value is a comma. \begin{example} \odv[sep-var-var=\here]{f}{x,y} \\ \odv[sep-var-var=\here]{f}/!{x,y} \end{example} \end{option} \begin{option}{sep-eval-sb} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted in the evaluation subscript left to the point of evaluation when a \emph{non-blank} subscript is given. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \pdv[sep-eval-sb=\here]{f}{x,y}_{(x_1,y_1)} \end{example} \end{option} \begin{option}{sep-eval-sp} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted in the evaluation superscript left to the point of evaluation when a \emph{non-blank} superscript is given. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \pdv[sep-eval-sp=\here]{f}{x,y}^{(x_2,y_2)} \end{example} \end{option} \subsubsection*{Switches} \begin{option}*{switch-*} \begin{values}[default = false] true, false \end{values} The effect of the star argument can be toggled with the value \val{true}. %That is, the function is typeset next to the fraction when the star is absent and in the numerator when the star is present. For example, compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}. \begin{example} \pdv[switch-*=false]{f}{x,y} \\ \pdv[switch-*=true]{f}{x,y} \end{example} \end{option} \begin{option}{switch-/} \begin{values}[default = false] true, false \end{values} The effect of the slash argument can be toggled with the value \val{true}. %That is, the derivative is typeset with the fraction set by \key{style-frac-/} when the slash is absent and with the fraction set by \key{style-frac} when the slash is present. For example, compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}. \begin{example} \pdv[switch-/=false]{f}{x,y} \\ \pdv[switch-/=true]{f}{x,y} \end{example} \end{option} \begin{option}{switch-!}[new = 1.3] \begin{values}[default = false] true, false \end{values} The effect of the exclamation mark argument can be toggled with the value \val{true}. %That is, the derivative is in shorthand mode the exclamation mark is absent and in fraction mode when the exclamation is present. For example, compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}. \begin{example} \pdv[switch-!=false]{f}{x,y} \\ \pdv[switch-!=true]{f}{x,y} \end{example} \end{option} \begin{option}{switch-sort}[new = 1.2] \begin{values}[default = true] true, false \end{values} This options disables (\val{false}) and enables (\val{true}) the sorting algorithm behind the mixed order. The sorting algorithm is only used/available in fraction mode when it is \val{multiple}. When disabled, the terms in the mixed order are arranged according to their first appearance in \keyval*[cat=misc,index=false]{order}{\dots}. Compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}. %When the value \val{true} is given, the mixed order sorting algorithm is activated, applying the methods specified in \keyval*{sort-method}{\dots}. Conversely, when the value \val{false} is given, the sorting algorithm is deactivated, and the terms in the mixed order are arranged according to their first appearance in \keyval*{order}{\dots}. Here's a comparison example with the option enabled (\val{true}) and disabled (\val{false}). \begin{example} \pdv[switch-sort=false, order={a+b,2kn-d,2-2b}]{f}{x,y,z} \\ \pdv[switch-sort=true, order={a+b,2kn-d,2-2b}]{f}{x,y,z} \end{example} \end{option} \subsubsection*{Sort} The keys mentioned in this subsection will be briefly described here, with a more detailed explanation provided in \cref{ssec:overall_order}. \begin{option}{sort-method}[updated = v1.2] \begin{values}[default = {sign, symbol, abs}] abs, lexical, number, sign, symbol \end{values} Sets the sorting method for the mixed order using build-in algorithms. \begin{itemize}[widest = {\val{lexical}}, leftmargin =*] \item[\val{abs}] Sorts terms in descending order based on their absolute value. \item[\val{lexical}] Sorts terms alphabetically in lexicographical ascending order. \item[\val{number}] Sorts terms in descending order based on their numerical value. \item[\val{sign}] Sorts terms by their sign, placing positive terms before the negative terms. \item[\val{symbol}] Sorts terms in descending order based on their symbolic length. \end{itemize} This option accepts a comma-separated list of values, allowing up to three values. For example: \begin{example} \pdv[sort-method=abs, order={kn-c,2a-3b}]{f}{x,y} \\ \pdv[sort-method=lexical, order={kn-c,2a-3b}]{f}{x,y} \\ \pdv[sort-method=number, order={kn-c,2a-3b}]{f}{x,y} \\ \pdv[sort-method=symbol, order={kn-c,2a-3b}]{f}{x,y} \\ \pdv[sort-method=sign, order={kn-c,2a-3b}]{f}{x,y} \\ \pdv[sort-method={sign,abs}, order={kn-c,2a-3b}]{f}{x,y} \\ \pdv[sort-method={sign,symbol,abs}, order={kn-c,2a-3b}]{f}{x,y} \end{example} Notice the different term ordering achieved with each method. For a more detailed explanation of this key, see \cref{ssec:sort-method} for more information. The default value uses the three algorithms \val{\default}. \end{option} \begin{option}{sort-numerical}[updated = v1.0] \begin{values}[default = auto] auto, first, last, symbolic \end{values} Determines the placement of the numerical term\footnote{The numerical term refers to the sum of all orders that consist solely of numbers and do not include any symbols.\label{foot:numerical-term}} in the mixed order. The placement options are as follows: \begin{itemize}[widest=\val{symbolic}, leftmargin=*] \item[\val{first}] Always places the numerical term as the first term in the mixed order. \item[\val{last}] Always places the numerical term as the last term in the mixed order. \item[\val{auto}] After sorting, the numerical term is automatically positioned based on the sign of the first symbolic term. If positive, the numerical term is placed last. If negative, the numerical term is placed first. \item[\val{symbolic}] Treats the numerical term as a symbolic term with a symbolic length of zero and sorts it alongside all other terms. \end{itemize} Here are some examples to illustrate the different placements of the numerical term: \begin{example} \pdv[sort-numerical=first, order={n,2}]{f}{x,y} \\ \pdv[sort-numerical=last, order={-n,2}]{f}{x,y} \\ \pdv[sort-numerical=auto, order={n,2}]{f}{x,y} \\ \pdv[sort-numerical=auto, order={-n,2}]{f}{x,y} \\ \pdv[sort-numerical=symbolic, order={2+n,-a}]{f}{x,y} \end{example} This key is further described in \cref{ssec:sort-numerical}. The default value is \val{\default}. \end{option} \begin{option}{sort-abs-reverse} \begin{values}[default = false] true, false \end{values} When the value \val{true} is used with this option, the sorting order is reversed to ascending order. See \cref{ssec:sort-reverse} for more information. \begin{example} \pdv[sort-abs-reverse=false, sort-method=abs, order=2a-3b]{f}{x} \\ \pdv[sort-abs-reverse=true, sort-method=abs, order=2a-3b]{f}{x} \end{example} \end{option} \begin{option}{sort-lexical-reverse}[new = v1.2] \begin{values}[default = false] true, false \end{values} When the value \val{true} is used with this option, the sorting order is reversed to lexicographical descending order. See \cref{ssec:sort-reverse} for more information. \begin{example} \pdv[sort-lexical-reverse=false, sort-method=lexical, order=a+b]{f}{x} \\ \pdv[sort-lexical-reverse=true, sort-method=lexical, order=a+b]{f}{x} \end{example} \end{option} \begin{option}{sort-number-reverse}[new = v1.0] \begin{values}[default = false] true, false \end{values} When the value \val{true} is used with this option, the sorting order is reversed to ascending order. See \cref{ssec:sort-reverse} for more information. \begin{example} \pdv[sort-number-reverse=false, sort-method=number, order=2a-3b]{f}{x} \\ \pdv[sort-number-reverse=true, sort-method=number, order=2a-3b]{f}{x} \end{example} \end{option} \begin{option}{sort-sign-reverse} \begin{values}[default = false] true, false \end{values} When the value \val{true} is used with this option, the sorting order is reversed, placing negative terms before the positive terms. See \cref{ssec:sort-reverse} for more information. \begin{example} \pdv[sort-sign-reverse=false, sort-method=sign, order=a-b]{f}{x} \\ \pdv[sort-sign-reverse=true, sort-method=sign, order=a-b]{f}{x} \end{example} \end{option} \begin{option}{sort-symbol-reverse} \begin{values}[default = false] true, false \end{values} When the value \val{true} is used with this option, the sorting order is reversed to ascending order. See \cref{ssec:sort-reverse} for more information. \begin{example} \pdv[sort-symbol-reverse=false, sort-method=symbol, order=ab+c]{f}{x} \\ \pdv[sort-symbol-reverse=true, sort-method=symbol, order=ab+c]{f}{x} \end{example} \end{option} \subsubsection*{Miscellaneous} \begin{option}*{fun}[cat=misc, new = v1.0] \begin{values}[default = false] true, false \end{values} This option allows you to add (\val{true}) or remove (\val{false}) delimiters around the function. Note that if the option is not explicitly set, it is considered equivalent to \keyval[cat=misc,index=false]{fun}{true}. By default, the value is \val{\default}. \begin{example} \pdv[fun=false]{f}{x} \\ \pdv[fun=true]{f}{x} \\ \pdv[fun]{f}{x} \end{example} %Without setting the option to a value is equivalent to setting it to \val{true} as seen above. \end{option} \begin{option}{frac}[cat=misc, new = v1.0] \begin{values}[default = false] true, false \end{values} This option allows you to add (\val{true}) or remove (\val{false}) delimiters around the fractional part of the derivative. Note that if the option is not explicitly set, it is considered equivalent to \keyval[cat=misc,index=false]{frac}{true}. By default, the value is \val{\default}. \begin{example} \pdv[frac=false]{f}{x} \\ \pdv[frac=true]{f}{x} \\ \pdv*[frac=true]{f}{x} \\ \pdv[frac]{f}{x} \end{example} \end{option} \begin{option}{var}[cat=misc, new = v1.0] \begin{values}[default=none] none, all, \meta{cs-numbers} \end{values} This option allows you to add or remove delimiters around the variables. The value \val{all} adds delimiters around all variables and \val{none} removed all delimiters. If only specific variables require delimiters, you can use \meta{cs-numbers}. For example, \keyval*[cat=misc,index=false]{var}{1,3} adds delimiters around the first and third variables. Note that if the option is not explicitly set, it is considered equivalent to \keyval[cat=misc,index=false]{var}{all}. By default, the value is \val{\default}. \begin{example} \pdv[var=none]{f}{x,y,z,t} \\ \pdv[var={1,3}]{f}{x,y,z,t} \\ \pdv[var=all]{f}{x,y,z,t} \\ \pdv[var]{f}{x,y,z,t} \end{example} \end{option} \begin{option}{order, ord}[cat=misc, new = v1.0] \begin{values}[default = 1] \marg{cs-orders} \end{values} Sets the order of differentiation for each variable as a comma separated list of values. \begin{example} \pdv[order={2,3}]{f}{x,y,z} \\ \pdv[order={\beta,a,n+2a}]{f}{x,y,z} \\ \pdv[order={2,n^2,n^2-1}]{f}{x,y,z} \\ \pdv[order={3/2-n/3,n/2,1/3}]{f}{x,y,z} \end{example} \end{option} \begin{option}{mixed-order, mixord}[cat=misc, new = v1.0] \begin{values}[default = 1] \marg{mixed order} \end{values} This option allows you to manually specify the mixed order of differentiation, overriding the automatically calculated value based on the orders set by \keyval[cat=misc]{order}{\marg{orders}}. In cases where the automatic calculation fails or when a different form is preferred, you can use this option to set the desired mixed order. \begin{example} \pdv[order={n+3k, n-k}]{f}{x,y} \\ \pdv[order={n+3k, n-k}, mixed-order={2(n+k)}]{f}{x,y} \end{example} \end{option} \subsection{Differential options} \label{ssec:options_inf} The options in this subsection are available for customizing the behaviour of differentials defined by the package and you. \subsubsection*{Style} \begin{option}*{style-inf} \begin{values}[default = d] \meta{math-font-style}\meta{infinitesimal} \end{values} Sets the infinitesimal used in the differential. The default infinitesimal is a plain \default. \begin{example} \odif[style-inf=\mathbf{d}]{x_1,x_2,x_3} \end{example} \end{option} \begin{option}{style-var}[updated=1.3] \begin{values}[default = multiple] single, multiple, mixed \end{values} This options determines the shorthand notation of the differential when the star argument is absent assuming \keyval{switch-*}{false}. \begin{itemize}[widest = {\val{multiple}}, leftmargin =*] \item[\val{single}] Creates a single differential with variables as subscripts and orders as superscripts. \item[\val{multiple}] Creates a separate differential for each variable. \item[\val{mixed}] Creates a separate differential for each variable but with variables as subscripts and orders as superscripts. \end{itemize} \begin{example} \odif[style-var=multiple, order={n,1,2}]{x,y,z,t} \\ \odif[style-var=single, order={n,1,2}]{x,y,z,t} \\ \odif[style-var=mixed, order={n,1,2}]{x,y,z,t} \end{example} \end{option} \begin{option}{style-var-*}[updated=1.3] \begin{values}[default = single] single, multiple, mixed \end{values} This option behaves identically to \key{style-var}, however it is used when the star argument is present assuming \keyval{switch-*}{false}. \end{option} \subsubsection*{Scaling} \begin{option}{scale-var} \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the star argument is absent assuming \keyval{switch-*}{false}. The default behaviour is to automatically scale the delimiters. \begin{example} \odif[scale-var=none, var]{r,\theta,\varphi}\\ \odif[scale-var=Big, var]{r,\theta,\varphi} \end{example} \end{option} \begin{option}{scale-var-*} \begin{values}[default = auto] auto, none, big, Big, bigg, Bigg \end{values} Sets the size of the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the star argument is present assuming \keyval{switch-*}{false}. The default behaviour is to automatically scale the delimiters. \begin{example} \odif*[scale-var-*=auto, var]{r,\theta,\varphi}\\ \odif*[scale-var-*=big, var]{r,\theta,\varphi} \end{example} \end{option} \subsubsection*{Delimiters} \begin{option}{delims-var} \begin{values}[default = (~)] \meta{left delimiter}\meta{right delimiter} \end{values} Sets the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the star argument is absent assuming \keyval{switch-*}{false}. The default delimiters are parentheses. \begin{example} \odif[delims-var=\{\}, var]{x,y}\\ \odif[delims-var=[], var]{x,y} \end{example} \end{option} \begin{option}{delims-var-*} \begin{values}[default = (~)] \meta{left delimiter}\meta{right delimiter} \end{values} Sets the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the star argument is present assuming \keyval{switch-*}{false}. The default delimiters are parentheses. \begin{example} \odif*[delims-var-*=\|\|, var]{x,y}\\ \odif*[delims-var-*=\langle\rangle, var]{x,y} \end{example} \end{option} \subsubsection*{Math spacing and separators} %The options in this subsection inserts additional horizontal math space in specific positions. The equations below illustrates where the space is inserted for each option:%TODO - math space should probably be seperator instead %\begin{align*} % \begin{gathered} % \partial \ms{inf-var} x \ms{var-inf} \partial y \\ % \partial^{ \ms{inf-ord} 2 } \ms{ord-var} x % \end{gathered} % && % \begin{gathered} % \ms{begin} \partial x \ms{end} \\ % \partial^{ 2\ms{ord-ord} 2 }_{ x \ms{var-var} y } % \end{gathered} %\end{align*} \begin{option}{sep-begin} \begin{values}[default = \cs{mathop}\{\}\cs{!}] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted at the beginning of the expression. The default value is \val{\default}. \begin{example} \odif[sep-begin=\here]{x,y,z} \end{example} \end{option} \begin{option}{sep-inf-ord} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted to the left of the infinitesimal's power when the order \emph{is different} from \num{1}. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \odif[sep-inf-ord=\here, order=2]{x,y} \end{example} \end{option} \begin{option}{sep-inf-var} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between the infinitesimal and the following non-blank variable when the associated order \emph{is equal} to \num{1}. The key's default value corresponds to \val{\default} \texttt{mu}. \begin{example} \odif[sep-inf-var=\here, order=2]{x,y} \end{example} \end{option} \begin{option}{sep-ord-var} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between an order and the following non-blank variable when the order \emph{is different} from \num{1}. This option is only available when the style is set to \val{multiple}. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \odif[sep-ord-var=\here, order=2]{x,y} \end{example} \end{option} \begin{option}{sep-var-inf} \begin{values}[default = \cs{mathop}\{\}\cs{!}] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between a non-blank variable and the following infinitesimal when more than one non-blank variables are given. The default value is \val{\default}. \begin{example} \odif[sep-var-inf=\here]{x,y} \end{example} \end{option} \begin{option}{sep-var-var} \begin{values}[default = {{,}}] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between two variables when more than one non-blank variables are given. This option is only available when the style is set to \val{single}. The default value is a comma. \begin{example} \odif*[sep-var-var=\here]{x,y} \end{example} \end{option} \begin{option}{sep-ord-ord} \begin{values}[default = {{,}}] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted between two orders that are both not equal to \num{1}. This option is only available when the style is set to \val{single}. The default value is a comma. \begin{example} \odif*[sep-ord-ord=\here, order={2,n}]{x,y} \end{example} \end{option} \begin{option}{sep-end} \begin{values}[default = 0] \meta{cs-number}, \marg{mspace}, \marg{delimiter} \end{values} Sets the separator that is inserted at the end of the expression. The default value corresponds to \val{\default} \texttt{mu}. \begin{example} \odif[sep-end=\here]{x,y} \end{example} \end{option} \subsubsection*{Switches} \begin{option}*{switch-*} \begin{values}[default = false] true, false \end{values} The effect of the star argument can be toggled with the value \val{true}. For example, compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}. \begin{example} \odif[switch-*=false]{x,y,z,t} \\ \odif[switch-*=true]{x,y,z,t} \end{example} \end{option} \subsubsection*{Miscellaneous} \begin{option}*{var}[cat=misc] \begin{values}[default=none] none, all, \meta{cs-numbers} \end{values} This option allows you to add or remove delimiters around the variables. The value \val{all} adds delimiters around all variables and \val{none} removed all delimiters. If only specific variables require delimiters, you can use \meta{cs-numbers}. For example, \keyval*[cat=misc,index=false]{var}{1,3} adds delimiters around the first and third variables. Note that if the option is not explicitly set, it is considered equivalent to \val{all}. By default, the value is \val{\default}. \begin{example} \odif[var=none]{x,y,z,t} \\ \odif[var={1,3}]{x,y,z,t} \\ \odif[var=all]{x,y,z,t} \\ \odif[var]{x,y,z,t} \end{example} \end{option} \begin{option}{order, ord}[cat=misc] \begin{values}[default = 1] \marg{cs-orders} \end{values} Sets the order of differentiation for each variable as a comma separated list of values. \begin{example} \odif[order={2,3}]{x,y,z} \\ \odif[order={\beta,a,n+2a}]{x,y,z} \end{example} \end{option} \subsection{All derivatives and differentials} \label{ssec:both_options} The options in this subsection are applied to all derivatives and differentials because they define settings that should be consistent regardless of the specific derivative or differential. These options can be accessed using the command \macro{\derivset}[\narg{all},\oarg{key=value}]. The options in this subsection are applied to all derivatives and differential because some options should be consisting regardless of the derivative and differential. The options are accessed using \macro{\derivset}[\narg{all},\oarg{key=value}]. \begin{example}[result=false] \derivset{all}[key=value] \end{example} \begin{option}{scale-auto}[updated = v1.1] \begin{values}[default = {leftright or mleftmright\req}] leftright, mleftmright\req \end{values} Sets the automatic delimiter scaling commands. The value \val{leftright} sets them as \cs{left} and \cs{right} while \val{mleftmright} sets them as \cs{mleft} and \cs{mright} from the \pkg{mleftrigth} package. The default value is \val{leftright} unless \pkg{mleftright} is loaded, in which case it is \val{mleftmright}. \begin{example} \derivset{all}[scale-auto=leftright] a \pdv[frac]{f}{x} a\\ \derivset{all}[scale-auto=mleftmright] a \pdv[frac]{f}{x} a \end{example} Notice the space difference between the a's and the parentheses in the two equations. \end{option} \clearpage \section{Defining variants} \label{sec:defvar} This section goes into detail on how to define derivative and differential variants based on the package's internal commands. The \mypackage{} package provides a \latex2-based approach to defining derivatives and differentials. \subsection{Derivative variant} \label{ssec:defvar_dv} \begin{function}*{\NewDerivative, \RenewDerivative, \ProvideDerivative, \DeclareDerivative} \begin{syntax} \meta{control-sequence}, \marg{infinitesimal}, \oarg{key=value} \end{syntax} This family of commands is used to define a derivative variant with the macro name \arg{1}. %The new derivative will use the infinitesimal \arg{2} and inherit the package's default settings given in \cref{ssec:options_dv}, which can be overwritten with \arg{3}. The difference between the commands is as follows: \begin{itemize} \item \macro{1} will issue an error if \arg{1} has already been defined. \item \macro{2} will issue an error if \arg{1} has not previously been defined. \item \macro{3} will define \arg{1} if it does not have an existing definition. It will not issue any errors. \item \macro{4} will always define the \arg{1} with the new definition regardless of whether it already exists. \end{itemize} Examples of their use can be found in \cref{sec:derivative}. \begin{argument}{1} The first argument specifies the macro name of the derivative being defined. \end{argument} \begin{argument}{2} The second argument sets the infinitesimal of the derivative \arg{1}. It is equivalent to setting \keyval{style-inf}{\arg{2}}. \end{argument} \begin{argument}{3} The optional argument accepts a comma-separated list of \emph{key=value} pairs, allowing you to override the package's default values for the keys given. If the optional argument is omitted, the derivative will use the package's default settings. \end{argument} \end{function} \subsection{Differential variant} \label{ssec:defvar_inf} \begin{function}*{\NewDifferential, \RenewDifferential, \ProvideDifferential, \DeclareDifferential} \begin{syntax} \meta{control-sequence}, \marg{infinitesimal}, \oarg{key=value} \end{syntax} This family of commands is used to define a differential variant with the macro name \arg{1}. %The new differential will use the infinitesimal \arg{2} and inherit the package's default settings given in \cref{ssec:options_inf}, which can be overwritten with \arg{3}. The difference between the commands is as follows: \begin{itemize} \item \macro{1} will issue an error if \arg{1} has already been defined. \item \macro{2} will issue an error if \arg{1} has not previously been defined. \item \macro{3} will define \arg{1} if it does not have an existing definition. It will not issue any errors. \item \macro{4} will always define the \arg{1} with the new definition regardless of whether it already exists. \end{itemize} Examples of their use can be found in \cref{sec:differential}. \begin{argument}{1} The first argument specifies the macro name of the differential being defined. \end{argument} \begin{argument}{2} The second argument sets the infinitesimal of the differential \arg{1}. It is equivalent to setting \keyval{style-inf}{\arg{2}}. \end{argument} \begin{argument}{3} The optional argument accepts a comma-separated list of \narg{key=value} pairs, allowing you to override the package's default values for the keys given. If the optional argument is omitted, the derivative will use the package's default settings. \end{argument} \end{function} \clearpage \section{The mixed order} \label{ssec:overall_order} The algorithm used to calculate the mixed order is advanced and can handle a wide range of inputs, including numbers, symbols and fractions. It accurately parses the orders to generate the appropriate mixed order. Let's consider some examples to illustrate its capabilities: \begin{example} \pdv[order={n+1,2}]{f}{x,y}\\ \pdv[order={n+1,2n}]{f}{x,y}\\ \pdv[order={n^2,n^2}]{f}{x,y}\\ \pdv[order={2/n-1/2, 3/n+m/3}]{f}{x,y,z} \end{example} The algorithm handles these cases and calculates the mixed order correctly. However, there are certain limitations when dealing with parentheses, except for a specific case where there is a single term in the denominator. \begin{example} \pdv[order={2/n-1/2, 3/(2n)+m/3}]{f}{x,y}\\ \pdv[order={(2n+m)/3, 3n+m/3}]{f}{x,y}\\ \pdv[order={2/(2n+m), 1/(2(2n+m))}]{f}{x,y} \end{example} In the third equation, the mixed order doesn't make sense because the algorithm splits up the orders at $+$ and $-$ within parentheses without evaluating them correctly. For example, $2/(2n+m), 1/(2(2n+m))$ is incorrectly split into $2/(2n, m), 1/(2(2n, m))$. The same happens in the second equation. To address this limitation, the package provides the \key[cat=misc]{mixed-order} option, which overrides the incorrect output. You can specify the desired mixed order manually. \begin{example} \pdv[order={(2n+m)/3, 3n+m/3}, mixord=8n/3+2m/3]{f}{x,y}\\ \pdv[order={2/(2n+m), 1/(2(2n+m))}, mixord=5/(2(2n+m))]{f}{x,y} \end{example} By using the \key[cat=misc]{mixed-order} option, you can ensure that the mixed order is displayed correctly, even when the algorithm's output may be incorrect or when a different form is preferred. \subsection{Sorting algorithms} \label{ssec:sort-method} A unique feature of this package is that the sorting method behind the mixed order may be changed using built-in algorithms. These algorithms are designed to offer variety of ways to sort the mixed order according to ones preferences. \begin{itemize}[widest = {\val{lexical}}, leftmargin =*] \item[\val{abs}] Sorts terms based on their absolute value in descending order. By setting \keyval{sort-abs-reverse}{true}, terms are sorted in ascending order instead. \item[\val{lexical}] Sorts the terms alphabetically in lexicographical order. By setting \keyval{sort-lexical-reverse}{true}, terms are sorted in reverse lexicographical order. \item[\val{number}] Sorts terms based on their numerical value in descending order. By setting \keyval{sort-number-reverse}{true}, terms are sorted in ascending order instead. \item[\val{sign}] Sorts terms by their sign, placing positive terms before negative terms. By setting, \keyval{sort-sign-reverse}{true}, places negative terms before positive terms. \item[\val{symbol}] Sorts terms in descending order based on their symbolic length. By setting \keyval{sort-symbol-reverse}{true}, terms are sorted in ascending order instead. \end{itemize} The sorting method allows up to three algorithms given by \keyval*{sort-method}{algorithm1, algorithm2, algorithm3}. The list of orders is primarily sorted based on algorithm 1's condition. In case of ties, algorithm 2 is used for further sorting, and so on. Consider the list \texttt{\{a,-c,-b,d\}} and the sorting method \keyval*{sort-method}{sign,lexical}. Initially, the \val{sign} algorithm sorts the list as \texttt{\{a,d,-c,-b\}}. However, due to ties, other valid orderings exist like \texttt{\{d,a,-c,-b\}}, \texttt{\{a,d,-b,-c\}} and \texttt{\{d,a,-b,-c\}}. Subsequently, the \val{lexical} algorithm sorts the tied values alphabetically as \texttt{\{a,d,-b,-c\}}. \subsubsection{Examples} The examples below use partial derivatives with \keyval*[cat=misc]{order}{3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}, along with a close-up view of the mixed order. Square brackets indicate how the terms was sorted by the applied algorithm. `Positive' and `negative', `long' and `short', and `big' and `low' refer to the \val{sign}, \val{symbol}, and \val{abs} algorithms, respectively. The default sorting method is \keyval*{sort-method}{sign,symbol,abs} which is used below. The \val{sign} algorithm separate the positive and negative terms. Within each group, the \val{symbol} algorithm sorts the terms based on symbolic length. Finally, In the resulting four groups, the \val{abs} algorithm sorts the terms based on absolute value. \begin{gather*} \pdv[sort-method = {sign,symbol,abs}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z} \\ \low{ \low{ \low{4gg}{big} + \low[2,2]{2ff}{low} }{long} + \low{ \low[1,2]{4c}{big} + \low[1,1]{3a}{low} }{short} }{positive} - \low{ \low{ \low[3,3]{5ee}{big} - \low[2,2]{3hh}{low} }{long} - \low{ \low[1,1]{5d}{big} - \low[2,2]{2b}{low} }{short} }{negative} \end{gather*} By interchanging the \val{sign} and \val{symbol} algorithm in the previous example, then the \val{symbol} algorithm will be applied first and the \val{sign} algorithm handles the symbolic ties. \begin{gather*} \pdv[sort-method = {symbol,sign,abs}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z} \\ \low{ \low{ \low{4gg}{big} + \low[2,2]{2ff}{low} }{positive} - \low{ \low[3,3]{5ee}{big} - \low[2,2]{3hh}{low} }{negative} }{long} + \low{ \low{ \low[1,2]{4c}{big} + \low[1,1]{3a}{low} }{positive} - \low{ \low[1,1]{5d}{big} - \low[2,2]{2b}{low} }{negative} }{short} \end{gather*} In contrast to the previous two examples with three algorithms, this example uses a sorting method with two algorithms: \keyval*{sort-method}{sign,symbol}. The terms are first sorted by sign and then by symbolic length. \begin{gather*} \pdv[sort-method = {sign,symbol}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z} \\ \low{ \low{ 4gg + 2ff }{long} + \low{ 3a + 4c }{short} }{positive} - \low{ \low{ 3hh - 5ee }{long} - \low{ 2b - 5d }{short} }{negative} \end{gather*} In the last example, a sorting method with a single algorithm, \keyval{sort-method}{symbol}, is used. \begin{gather*} \pdv[sort-method = symbol, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z} \\ \low{ - 3hh + 4gg + 2ff - 5ee }{long} + \low{ 3a - 2b + 4c - 5d }{short} \end{gather*} \subsection{Treating the numerical term} \label{ssec:sort-numerical} After handling the symbolic part of the mixed order, we now turn our attention to the numerical term\footref{foot:numerical-term}, which has a symbolic length of zero. For this reason it is treated differently than the symbolic terms. It can be placed either at the beginning or at the end of the mixed order by \val{first} and \val{last}, respectively. Alternatively, it is automatically positioned in the mixed order using \val{auto}. Setting \keyval{sort-numerical}{symbolic}, treats the numerical term as a symbolic term. Its behaviour is determined by the chosen algorithms in \keyval*{sort-method}{\dots}. In this example the sort method is the default value of the package. \begin{align*} \text{\inlinecode{sort-numerical=auto:}} && \pdv[order={\beta, 2}, sort-numerical=auto]{f}{x,y} && \pdv[order={\beta, -2}, sort-numerical=auto]{f}{x,y} && \pdv[order={-\beta, 2}, sort-numerical=auto]{f}{x,y} && \pdv[order={-\beta, -2}, sort-numerical=auto]{f}{x,y} \\ \text{\inlinecode{sort-numerical=first:}} && \pdv[order={\beta, 2}, sort-numerical=first]{f}{x,y} && \pdv[order={\beta, -2}, sort-numerical=first]{f}{x,y} && \pdv[order={-\beta, 2}, sort-numerical=first]{f}{x,y} && \pdv[order={-\beta, -2}, sort-numerical=first]{f}{x,y} \\ \text{\inlinecode{sort-numerical=last:}} && \pdv[order={\beta, 2}, sort-numerical=last]{f}{x,y} && \pdv[order={\beta, -2}, sort-numerical=last]{f}{x,y} && \pdv[order={-\beta, 2}, sort-numerical=last]{f}{x,y} && \pdv[order={-\beta, -2}, sort-numerical=last]{f}{x,y} \\ \text{\inlinecode{sort-numerical=symbolic:}} && \pdv[order={\beta, 2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={\beta, -2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={-\beta, 2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={-\beta, -2}, sort-numerical=symbolic]{f}{x,y} \end{align*} \subsection{Reversing the sort algorithm} \label{ssec:sort-reverse} The reverse keys serves to reverse the sorting algorithms' ordering, providing more flexibility over the sorting method. If the default ordering of an algorithm is not preferred it may be reversed with the corresponding reverse key. The examples below showcase the reverse functionality. Note that \keyval*[index=false]{sort-method}{1 algorithm only} is also used to better demonstrate the reverse feature, where the algorithm is the one used in the reverse key. \begin{align*} \text{\inlinecode{sort-abs-reverse=false:}} && \pdv[sort-method={abs}, sort-abs-reverse=false, order={2a, -3b}]{f}{x,y} && \text{\inlinecode{sort-abs-reverse=true:}} && \pdv[sort-method={abs}, sort-abs-reverse=true, order={2a, -3b}]{f}{x,y} \\ \text{\inlinecode{sort-number-reverse=false:}} && \pdv[sort-method={number}, sort-number-reverse=false, order={2a, -3b}]{f}{x,y} && \text{\inlinecode{sort-number-reverse=true:}} && \pdv[sort-method={number}, sort-number-reverse=true, order={2a, -3b}]{f}{x,y} \\ \text{\inlinecode{sort-sign-reverse=false:}} && \pdv[sort-method={sign}, sort-sign-reverse=false, order={a, -b}]{f}{x,y} && \text{\inlinecode{sort-sign-reverse=true:}} && \pdv[sort-method={sign}, sort-sign-reverse=true, order={a, -b}]{f}{x,y} \\ \text{\inlinecode{sort-symbol-reverse=false:}} && \pdv[sort-method={symbol}, sort-symbol-reverse=false, order={ab, c}]{f}{x,y} && \text{\inlinecode{sort-symbol-reverse=true:}} && \pdv[sort-method={symbol}, sort-symbol-reverse=true, order={ab, c}]{f}{x,y} \\ \text{\inlinecode{sort-lexical-reverse=false:}} && \pdv[sort-method={lexical}, sort-lexical-reverse=false, order={a, c, b}]{f}{x,y,z} && \text{\inlinecode{sort-lexical-reverse=true:}} && \pdv[sort-method={lexical}, sort-lexical-reverse=true, order={a, c, b}]{f}{x,y,z} \\ \end{align*} %\subsection{Mixed order override} %In cases where the mixed order fails to be calculated or another form is preferred, then the mixed order override can be used %\begin{example} % \pdv[order={n+3k, n-k}]{f}{x,y} \\ % \pdv[order={n+3k, n-k}, mixed-order={2(n+k)}]{f}{x,y} %\end{example} \clearpage \section{Miscellaneous} \subsection{Slashfrac}\label{ssec:slashfrac} \begin{function}*{\slashfrac} \begin{syntax} \oarg{scale}, \marg{numerator}, \marg{denominator} \end{syntax} The text-styled fraction, $\slashfrac{a}{b}$, is commonly used in text-mode. While \macro{\slashfrac}[\narg{a},\narg{b}] requires more keystrokes to write than \texttt{a/b}, a macro is needed for implementing text-styled derivatives. \begin{argument}{1} The optional argument serves as the scaling parameter for the solidus and accepts the following inputs: \begin{example} \slashfrac{y_f}{x} \\ \slashfrac[auto]{y_f}{x} \\ \slashfrac[none]{y_f}{x} \\ \slashfrac[big]{y_f}{x} \\ \slashfrac[Big]{y_f}{x} \\ \slashfrac[bigg]{y_f}{x} \\ \slashfrac[Bigg]{y_f}{x} \end{example} Omitting \arg{1} sets the scaling parameter to \val{auto}. %This argument is subject to change, see \cref{consid:slashfrac_opt} for more information. \end{argument} \begin{argument}{2} Typesets the fraction's numerator. \end{argument} \begin{argument}{3} Typesets the fraction's denominator. \end{argument} \end{function} \clearpage \addsec{Index} Numbers in bold refer to the page where the entry is defined. \printindex[option] \clearpage \printindex[macro] \clearpage \addsec{Change history} \setlength{\marginparwidth}{75pt} \begin{changelog} \begin{change}[version=0.9, date=2019-07-21, beta=true] \item First release of the package. The package is currently in a beta version. \end{change} \bigskip \begin{change}[version=0.95, date=2019-09-18, beta=true] \item \emph{Please ignore this version, since it contained the wrong \pkg{.sty} and \pkg{.pdf} files} \texttt{:(}. %\item Second beta release of the package. \item Removed the single token restriction on the infinitesimal since it was unnecessary. \item Fixed documentation errors and typos. \item Made minor fixes to the code. \end{change} \begin{change}[version=0.95b, date=2019-09-21, beta=true] \item Contains the correct \pkg{.sty} and \pkg{.pdf} files \texttt{:)}. \item Made one minor code fix. \end{change} \smallskip \begin{change}[version=0.96, date=2019-12-22, beta=true] \item Fixed the issue with double superscript for higher-order derivatives when the variable contained a superscript. \end{change} \smallskip \begin{change}[version=0.97, date=2020-02-03, beta=true] \item Fixed the argument specifier of \csverb{\__deriv_scale_big:nnnn} when it was used (it was used with \texttt{:nnnm}). \end{change} \smallskip \begin{change}[version=0.98, date=2020-07-20, beta=true] \item Fixed a bug related to the subscript argument caused by recent changes to the \pkg{xparse} package dated 2020-05-14 (the fix also works with earlier versions of \pkg{xparse}). \end{change} \smallskip \begin{change}[version=1.0, date=2021-05-25, beta=false] \item Added new options for derivatives. \item Added new values for existing options. \item Added new commands for writing differentials. \item Changed the usage of \key[index=false]{style-inf}. \item Changed the order argument to an option argument. \item Adjusted default values for certain options. \item Expanded math space keys to accept more general inputs. \item Changed \cs{derivset} to define default options. \item Merged the codes for ordinary and partial derivatives. \item Removed the mixed order argument. \item Removed the options \key[index=false]{misc-add-delims} and \key[index=false]{misc-remove-delims}. \item Replaced the commands in \cref{sec:defvar} with new ones, as the old ones are deprecated. \item Code clean-up and optimization. \item Fixed code errors. \item Fixed documentation errors. \item Improved support for preventing options affecting nested derivatives/differentials. \end{change} \begin{change}[version=1.01, date=2021-05-28, beta=false] \item Changed the default value of the option \key[index=false]{sep-end} due to issues. \item Fixed code errors due to changes introduced in version 1.0 to the option \key[index=false]{style-inf}. \item Fixed documentation errors. \end{change} \begin{change}[version=1.1, date=2021-06-03, beta=false] \item Added package options to be used with \cs{usepackage}\oarg{options}\narg{derivative}. \item Removed the hidden dependency on \pkg{unicode-math} when using \xetex{} or \luatex. \item Replaced \cs{symup} with \cs{mathrm} for simplicity. \item If \pkg{mleftright} is loaded, the default value of \key[index=false]{scale-auto} is set to \val{mleftmright}. \end{change} \begin{change}[version=1.2, date=2022-07-09, beta=false] \item Code clean-up and optimisation that significantly speeds up usage of the package. \item Added new a sorting algorithm \keyval[index=false]{sort-method}{lexical}, which sorts terms alphabetically. \item Added the option \key[index=false]{sort-lexical-reverse} to reverse the alphabetical sorting order. \item Added the option \key[index=false]{switch-sort} to enable/disable the sorting algorithm for the mixed order. \item Fixed a bug related to \keyval[index=false]{scale-\meta{\dots}}{none} when the corresponding delimiter option contained a period. \item Fixed documentation errors. \end{change} \begin{change}[version=1.3, date=2023-07-26, beta=false] \item Code clean-up and minor optimisation. \item Fixed documentation errors. \item Updated documentation to include more examples. \item Enhanced the algorithm that automatically calculates the mixed order to support fractional calculus. \item Introduced a new argument, \targ{!}, for derivatives to enable shorthand notation. \item Added new options \key[index=false]{style-inf-den}. and \key[index=false]{style-inf-num} to set the infinitesimals in the denominator and numerator, respectively. \item Added new options \key{style-var-/}, \key{style-var-!} and \key{style-var-/!} to set the style of the derivatives. \item Added new options \key{scale-var-!} and \key{delims-var-!} for variable delimiters in shorthand mode. \item Added new options \key{scale-eval-!} and \key{delims-eval-!} for evaluation delimiters in shorthand mode. \end{change} \begin{change}[version=1.31, date=2023-11-04, beta=false] \item Fixed issue relating to the order when nesting derivatives (issues \#14). \end{change} \bigskip \begin{change}[version=1.4, date=2024-02-08, beta=false] \item Introduced implicit order parameter to simplify specifying the order of differentiation, for example: \cs{pdv}\oarg*{n,2}\narg{f}\narg{x,y} (issues \#2 and \#10). \end{change} \end{changelog} \end{document}