diff options
author | Karl Berry <karl@freefriends.org> | 2021-05-25 20:47:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-05-25 20:47:33 +0000 |
commit | 4bf5956529386575d89874638bfd567040b9475c (patch) | |
tree | 544efabb03840ff9c4ad9b419236fb96524829dd /Master/texmf-dist/tex/latex | |
parent | d1507916f400b950db2725667d3c96fa05fffbd5 (diff) |
derivative (25may21)
git-svn-id: svn://tug.org/texlive/trunk@59344 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/derivative/derivative.sty | 1580 |
1 files changed, 843 insertions, 737 deletions
diff --git a/Master/texmf-dist/tex/latex/derivative/derivative.sty b/Master/texmf-dist/tex/latex/derivative/derivative.sty index a30dad465fe..6994b23a958 100644 --- a/Master/texmf-dist/tex/latex/derivative/derivative.sty +++ b/Master/texmf-dist/tex/latex/derivative/derivative.sty @@ -1,5 +1,5 @@ % derivative.sty -% Copyright 2019-2020 Simon Jensen +% Copyright 2019-2021 Simon Jensen % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -16,7 +16,7 @@ \NeedsTeXFormat{LaTeX2e} \RequirePackage{xparse}[2018/05/09] -\ProvidesExplPackage{derivative}{2020/07/20}{0.98}{Nice and easy derivatives} +\ProvidesExplPackage{derivative}{2021/05/25}{1.0}{Nice and easy derivatives and differentials for LaTeX} %%%%% Useful conditionals %%%%% @@ -44,76 +44,72 @@ \prg_new_conditional:Npnn \__deriv_show_order:N #1 { T, TF } { - \quark_if_no_value:NTF #1 + \str_if_eq:NNTF #1 1 { \prg_return_false: } - { - \str_if_eq:NNTF #1 1 - { \prg_return_false: } - { - \exp_args:NV \tl_if_novalue:nTF #1 - { \prg_return_false: } - { - \tl_if_blank:VTF #1 - { \prg_return_false: } - { \prg_return_true: } - } - } - } + { \prg_return_true: } } \cs_new:Npn \__deriv_case:n #1 -{ \exp:w \__deriv_case_begin:nTF {#1} { } { } } +{ \exp:w \__deriv_case_begin:nTF {#1} { } { } } \cs_new:Npn \__deriv_case:nT #1#2 -{ \exp:w \__deriv_case_begin:nTF {#1} {#2} { } } +{ \exp:w \__deriv_case_begin:nTF {#1} {#2} { } } \cs_new:Npn \__deriv_case:nF #1#2 -{ \exp:w \__deriv_case_begin:nTF {#1} { } {#2} } +{ \exp:w \__deriv_case_begin:nTF {#1} { } {#2} } \cs_new:Npn \__deriv_case:nTF #1 -{ \exp:w \__deriv_case_begin:nTF {#1} } +{ \exp:w \__deriv_case_begin:nTF {#1} } \cs_new:Npn \__deriv_case_begin:nTF #1#2#3 -{ \__deriv_case:w #1 \c_true_bool { } \q_mark {#2} \q_mark {#3} \q_stop } +{ \__deriv_case:w #1 \c_true_bool { } \q_mark {#2} \q_mark {#3} \q_stop } \cs_new:Npn \__deriv_case:w #1#2 { \bool_if:nTF {#1} - { \__deriv_case_end:nw {#2} } - { \__deriv_case:w } + { \__deriv_case_end:nw {#2} } + { \__deriv_case:w } } \cs_new:Npn \__deriv_case_end:nw #1#2#3 \q_mark #4#5 \q_stop -{ \exp_end: #1 #4 } - -%%%%% Variables for settings of odv, pdv and variants %%%%% +{ \exp_end: #1 #4 } -\cs_new_protected:Npn \__deriv_auto_left:n #1 { \left #1 } -\cs_new_protected:Npn \__deriv_auto_right:n #1 { \right #1 } +%%%%% Variables: derivatives %%%%% -\tl_new:N \l__deriv_dv_tmp_tl +\tl_new:N \l__deriv_cs_name_tl \tl_new:N \l__deriv_derivset_tl -\seq_new:N \l__deriv_var_seq +\seq_new:N \l__deriv_new_var_seq \seq_new:N \l__deriv_rubber_seq -%%%%% Variables for odv %%%%% +\prop_new:N \l__deriv_tmp_keys_prop +\seq_new:N \l__deriv_tmp_keys_seq +\tl_new:N \l__deriv_tmp_keys_tl -\seq_new:N \l__deriv_d_variant_seq +%%%%% Variables: infinisimal %%%%% -\tl_new:N \l__deriv_d_order_tl +\seq_new:N \l__deriv_i_var_seq +\seq_new:N \l__deriv_i_orders_seq +\tl_new:N \l__deriv_i_tmpa_tl +\tl_new:N \l__deriv_i_denom_tl -%%%%% Variables for pdv and mixed order (mo) %%%%% +\seq_new:N \l__deriv_i_variant_seq -\seq_new:N \l__deriv_p_variant_seq +%%%%% Variables: other %%%%% -\tl_new:N \l__deriv_p_tmpa_tl -\tl_new:N \l__deriv_p_mo_tl -\tl_new:N \l__deriv_p_denom_tl +\seq_new:N \l__deriv_dv_variant_seq +\seq_new:N \l__deriv_add_var_bool_seq -\seq_new:N \l__deriv_p_var_seq -\seq_new:N \l__deriv_p_order_seq -\seq_new:N \l__deriv_p_mo_seq +\tl_new:N \l__deriv_tmpa_tl +\tl_new:N \l__deriv_tmpb_tl +\tl_new:N \l__deriv_tmpc_tl +\seq_new:N \l__deriv_tmpa_seq + +\tl_new:N \l__deriv_dv_denom_tl + +\seq_new:N \l__deriv_dv_var_seq +\seq_new:N \l__deriv_dv_order_seq +\seq_new:N \l__deriv_dv_mo_seq \int_new:N \l__deriv_vmo_int @@ -133,6 +129,7 @@ \seq_new:N \l__deriv_rebuild_seq \int_new:N \l__deriv_tmpa_int +\int_new:N \l__deriv_tmpb_int \int_new:N \l__deriv_numerical_int \int_new:N \l__deriv_sort_counter_int @@ -141,11 +138,91 @@ \int_new:N \l__deriv_position_int \int_new:N \l__deriv_rebuild_int +\bool_new:N \l__deriv_tmpa_bool + \regex_const:Nn \c__deriv_pattern_regex { \A([\+\-]?\d*)(.*) } +\regex_const:Nn \c__deriv_cs_numbers_regex { \A\-?\d+(?:,\d+){0,2}\Z } + +%%%%% default values %%%%% + +\prop_const_from_keyval:Nn \c__deriv_dv_pkg_keys_prop +{ + style-frac = \frac, + style-frac-/ = \slashfrac, + style-var = single, + scale-eval = auto, + scale-eval-/ = auto, + scale-fun = auto, + scale-var = auto, + scale-frac = auto, + scale-frac-/ = auto, + delims-eval = .\rvert, + delims-eval-/ = .\rvert, + delims-fun = (), + delims-var = (), + delims-frac = (), + delims-frac-/ = (), + sep-inf-ord = 0, + sep-inf-fun = 0, + sep-ord-fun = 0, + sep-frac-fun = 0, + sep-inf-var = 0, + sep-var-ord = 0, + sep-var-inf = \mathop{}\!, + sep-ord-inf = \mathop{}\!, + sep-var-var = {,}, + sep-eval-sb = 0, + sep-eval-sp = 0, + switch-* = false, + switch-/ = false, + sort-method = {sign, symbol, abs}, + sort-numerical = auto, + sort-abs-reverse = false, + sort-number-reverse = false, + sort-sign-reverse = false, + sort-symbol-reverse = false, + fun = false, + frac = false, + var = none, + order = 1, + mixed-order = 1 +} + +\bool_lazy_or:nnTF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: } +{ \prop_gput:Nnn \c__deriv_dv_pkg_keys_prop { style-inf } { \symnormal } } +{ \prop_gput:Nnn \c__deriv_dv_pkg_keys_prop { style-inf } { \mathnormal } } + +\prop_const_from_keyval:Nn \c__deriv_i_pkg_keys_prop +{ + style-notation = multiple, + style-notation-* = single, + scale-var = auto, + scale-var-* = auto, + delims-var = (), + delims-var-* = (), + sep-begin = \mathop{}\!, + sep-inf-ord = 0, + sep-inf-var = 0, + sep-ord-var = 0, + sep-var-inf = \mathop{}\!, + sep-var-var = {,}, + sep-ord-ord = {,}, + sep-end = \mathop{}\!, + switch-* = false, + var = none, + order = 1 +} + +\bool_lazy_or:nnTF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: } +{ \prop_gput:Nnn \c__deriv_i_pkg_keys_prop { style-inf } { \symnormal } } +{ \prop_gput:Nnn \c__deriv_i_pkg_keys_prop { style-inf } { \mathnormal } } %%%%%% Key-val for all %%%%%% -\keys_define:nn { deriv-all-settings } +\prop_const_from_keyval:Nn \c__deriv_all_pkg_keys_prop +{ scale-auto = leftright } + +\keys_define:nn { deriv/all/all } { scale-auto .choice:, scale-auto / leftright .code:n = @@ -155,816 +232,800 @@ }, scale-auto / mleftmright .code:n = { - \cs_set_eq:NN \__deriv_auto_left:n \mleft - \cs_set_eq:NN \__deriv_auto_right:n \mright + \cs_set_nopar:Npn \__deriv_auto_left:n { \mleft } + \cs_set_nopar:Npn \__deriv_auto_right:n { \mright } }, scale-auto .default:n = { leftright } } -%%%%% Key-val for odv and variants %%%%% -\cs_new:Npn \__deriv_d_define_keys:n #1 +%%%%%% Key-val: derivatives %%%%%% + +\cs_new:Npn \__deriv_dv_define_keys:n #1 { - \keys_define:nn { deriv/d/#1 } + \keys_define:nn { deriv/dv/#1 } { - style-inf .code:n = { \cs_set_eq:cN { __deriv_#1_style_inf:n } ##1 }, - - style-frac .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac:n } ##1 }, - style-frac .default:n = { \frac }, - - style-frac-/ .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac_slash:n } ##1 }, - style-frac-/ .default:n = { \slashfrac }, + style-inf .tl_set:c = { l__deriv_dv_#1_style_inf_tl }, + style-var .tl_set:c = { l__deriv_dv_#1_style_var_tl }, + style-frac .cs_set:cp = { __deriv_dv_#1_style_frac:nn } {##1}, + style-frac-/ .cs_set:cp = { __deriv_dv_#1_style_frac_slash:nn } {##1}, - scale-eval .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_eval_tl } \l_keys_choice_tl }, - scale-eval .default:n = { auto }, + scale-eval .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_eval_tl } {##1} }, + scale-eval-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_eval_slash_tl } {##1} }, + scale-fun .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_fun_tl } {##1} }, + scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_var_tl } {##1} }, + scale-frac .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_frac_tl } {##1} }, + scale-frac-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_frac_slash_tl } {##1} }, - scale-eval-/ .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_eval_slash_tl } \l_keys_choice_tl }, - scale-eval-/ .default:n = { auto }, + delims-eval .tl_set:c = { l__deriv_dv_#1_delims_eval_tl }, + delims-eval-/ .tl_set:c = { l__deriv_dv_#1_delims_eval_slash_tl }, + delims-fun .tl_set:c = { l__deriv_dv_#1_delims_fun_tl }, + delims-var .tl_set:c = { l__deriv_dv_#1_delims_var_tl }, + delims-frac .tl_set:c = { l__deriv_dv_#1_delims_frac_tl }, + delims-frac-/ .tl_set:c = { l__deriv_dv_#1_delims_frac_slash_tl }, - scale-fun .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_fun_tl } \l_keys_choice_tl }, - scale-fun .default:n = { auto }, + sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_inf_ord_tl } {##1} }, + sep-inf-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_inf_fun_tl } {##1} }, + sep-ord-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_ord_fun_tl } {##1} }, + sep-frac-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_frac_fun_tl } {##1} }, + sep-inf-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_inf_var_tl } {##1} }, + sep-var-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_var_ord_tl } {##1} }, + sep-var-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_var_inf_tl } {##1} }, + sep-ord-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_ord_inf_tl } {##1} }, + sep-var-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_var_var_tl } {##1} }, + sep-eval-sb .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_eval_sb_tl } {##1} }, + sep-eval-sp .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_eval_sp_tl } {##1} }, - scale-var .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_var_tl } \l_keys_choice_tl }, - scale-var .default:n = { auto }, + switch-* .bool_set:c = { l__deriv_dv_#1_switch_star_bool }, + switch-/ .bool_set:c = { l__deriv_dv_#1_switch_slash_bool }, - scale-frac .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_frac_tl } \l_keys_choice_tl }, - scale-frac .default:n = { auto }, + fun .bool_set:c = { l__deriv_dv_#1_misc_fun_bool }, + frac .bool_set:c = { l__deriv_dv_#1_misc_frac_bool }, + var .clist_set:c = { l__deriv_dv_#1_misc_var_clist }, + %fun .default:n = {true}, + %frac .default:n = {true}, + var .default:n = {all}, - scale-frac-/ .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_frac_slash_tl } \l_keys_choice_tl }, - scale-frac-/ .default:n = { auto }, + order .clist_set:c = { l__deriv_dv_#1_misc_order_clist }, + ord .clist_set:c = { l__deriv_dv_#1_misc_order_clist }, + mixed-order .tl_set:c = { l__deriv_dv_#1_misc_mixed_order_tl }, + mixord .tl_set:c = { l__deriv_dv_#1_misc_mixed_order_tl }, - delims-eval .code:n = { \tl_set:cn { l__deriv_#1_delims_eval_tl } { ##1 } }, - delims-eval .default:n = { .\rvert }, - delims-eval-/ .code:n = { \tl_set:cn { l__deriv_#1_delims_eval_slash_tl } { ##1 } }, - delims-eval-/ .default:n = { .\rvert }, - delims-fun .code:n = { \tl_set:cn { l__deriv_#1_delims_fun_tl } { ##1 } }, - delims-fun .default:n = { () }, - delims-var .code:n = { \tl_set:cn { l__deriv_#1_delims_var_tl } { ##1 } }, - delims-var .default:n = { () }, - delims-frac .code:n = { \tl_set:cn { l__deriv_#1_delims_frac_tl } { ##1 } }, - delims-frac .default:n = { () }, - delims-frac-/ .code:n = { \tl_set:cn { l__deriv_#1_delims_frac_slash_tl } { ##1 } }, - delims-frac-/ .default:n = { () }, - - sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_ord_muskip } {##1} }, - sep-inf-ord .default:n = { 0 }, - sep-inf-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_fun_muskip } {##1} }, - sep-inf-fun .default:n = { 0 }, - sep-ord-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_ord_fun_muskip } {##1} }, - sep-ord-fun .default:n = { 0 }, - sep-var-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_var_ord_muskip } {##1} }, - sep-var-ord .default:n = { 0 }, - sep-inf-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_var_muskip } {##1} }, - sep-inf-var .default:n = { 0 }, - sep-eval-sb .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_eval_sb_muskip } {##1} }, - sep-eval-sb .default:n = { 0 }, - sep-eval-sp .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_eval_sp_muskip } {##1} }, - sep-eval-sp .default:n = { 0 }, - - switch-* .bool_set:c = { l__deriv_#1_switch_star_bool }, - switch-* .default:n = { false }, - switch-/ .bool_set:c = { l__deriv_#1_switch_slash_bool }, - switch-/ .default:n = { false }, - - misc-add-delims .multichoices:nn = - { fun, var, frac } - { \bool_set_true:c { l__deriv_#1_mics_##1_bool } }, - - misc-remove-delims .multichoices:nn = - { fun, var, frac } - { \bool_set_false:c { l__deriv_#1_mics_##1_bool } }, - misc-remove-delims .default:n = { fun, var, frac } + sort-method .clist_set:c = { l__deriv_dv_#1_sort_method_clist }, + sort-numerical .choices:nn = { auto, first, last, symbolic } { \tl_set:cn { l__deriv_dv_#1_sort_numerical_tl } {##1} }, + sort-abs-reverse .bool_set:c = { l__deriv_dv_#1_sort_abs_reverse_bool }, + sort-number-reverse .bool_set:c = { l__deriv_dv_#1_sort_number_reverse_bool }, + sort-sign-reverse .bool_set:c = { l__deriv_dv_#1_sort_sign_reverse_bool }, + sort-symbol-reverse .bool_set:c = { l__deriv_dv_#1_sort_symbol_reverse_bool } } - \bool_lazy_or:nnT { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: } - { \keys_define:nn { deriv/d/#1 } { style-inf .default:n = { \symnormal } } } - \sys_if_engine_pdftex:T - { \keys_define:nn { deriv/d/#1 } { style-inf .default:n = { \mathnormal } } } } -%%%%%% Key-val for pdv and variants %%%%%% -\cs_new:Npn \__deriv_p_define_keys:n #1 + +%%%%%% Key-val: derivatives %%%%%% + +\cs_new:Npn \__deriv_i_define_keys:n #1 { - \keys_define:nn { deriv/p/#1 } + \keys_define:nn { deriv/i/#1 } { - style-inf .code:n = { \cs_set_eq:cN { __deriv_#1_style_inf:n } ##1 }, - - style-frac .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac:n } ##1 }, - style-frac .default:n = { \frac }, - - style-frac-/ .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac_slash:n } ##1 }, - style-frac-/ .default:n = { \slashfrac }, - - scale-eval .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_eval_tl } \l_keys_choice_tl }, - scale-eval .default:n = { auto }, - - scale-eval-/ .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_eval_slash_tl } \l_keys_choice_tl }, - scale-eval-/ .default:n = { auto }, - - scale-fun .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_fun_tl } \l_keys_choice_tl }, - scale-fun .default:n = { auto }, - - scale-var .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_var_tl } \l_keys_choice_tl }, - scale-var .default:n = { auto }, - - scale-frac .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_frac_tl } \l_keys_choice_tl }, - scale-frac .default:n = { auto }, - - scale-frac-/ .choices:nn = - { auto, none, big, Big, bigg, Bigg } - { \tl_set_eq:cN { l__deriv_#1_scale_frac_slash_tl } \l_keys_choice_tl }, - scale-frac-/ .default:n = { auto }, - - delims-eval .code:n = { \tl_set:cn { l__deriv_#1_delims_eval_tl } {##1} }, - delims-eval .default:n = { () }, - delims-eval-/ .code:n = { \tl_set:cn { l__deriv_#1_delims_eval_slash_tl } {##1} }, - delims-eval-/ .default:n = { () }, - delims-fun .code:n = { \tl_set:cn { l__deriv_#1_delims_fun_tl } {##1} }, - delims-fun .default:n = { () }, - delims-var .code:n = { \tl_set:cn { l__deriv_#1_delims_var_tl } {##1} }, - delims-var .default:n = { () }, - delims-frac .code:n = { \tl_set:cn { l__deriv_#1_delims_frac_tl } {##1} }, - delims-frac .default:n = { () }, - delims-frac-/ .code:n = { \tl_set:cn { l__deriv_#1_delims_frac_slash_tl } {##1} }, - delims-frac-/ .default:n = { () }, + style-inf .tl_set:c = { l__deriv_i_#1_style_inf_tl }, + style-notation .tl_set:c = { l__deriv_i_#1_style_notation_tl }, + style-notation-* .tl_set:c = { l__deriv_i_#1_style_notation_star_tl }, - sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_ord_muskip } {##1} }, - sep-inf-ord .default:n = { 0 }, - sep-inf-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_fun_muskip } {##1} }, - sep-inf-fun .default:n = { 0 }, - sep-ord-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_ord_fun_muskip } {##1} }, - sep-ord-fun .default:n = { 0 }, - sep-inf-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_ord_muskip } {##1} }, - sep-inf-var .default:n = { 0 }, - sep-var-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_var_ord_muskip } {##1} }, - sep-var-ord .default:n = { 0 }, - sep-var-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_var_inf_muskip } {##1} }, - sep-var-inf .default:n = { 3 }, - sep-ord-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_ord_inf_muskip } {##1} }, - sep-ord-inf .default:n = { 3 }, - sep-eval-sb .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_eval_sb_muskip } {##1} }, - sep-eval-sb .default:n = { -4 }, - sep-eval-sp .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_eval_sp_muskip } {##1} }, - sep-eval-sp .default:n = { -4 }, + scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_i_#1_scale_var_tl } {##1} }, + scale-var-* .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_i_#1_scale_var_star_tl } {##1} }, - switch-* .bool_set:c = { l__deriv_#1_switch_star_bool }, - switch-* .default:n = { false }, - switch-/ .bool_set:c = { l__deriv_#1_switch_slash_bool }, - switch-/ .default:n = { false }, + delims-var .tl_set:c = { l__deriv_i_#1_delims_var_tl }, + delims-var-* .tl_set:c = { l__deriv_i_#1_delims_var_star_tl }, - misc-add-delims .multichoices:nn = - { fun, var, frac } - { \bool_set_true:c { l__deriv_#1_mics_##1_bool } }, + sep-begin .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_begin_tl } {##1} }, + sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_inf_ord_tl } {##1} }, + sep-inf-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_inf_var_tl } {##1} }, + sep-ord-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_ord_var_tl } {##1} }, + sep-var-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_var_inf_tl } {##1} }, + sep-var-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_var_var_tl } {##1} }, + sep-ord-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_ord_ord_tl } {##1} }, + sep-end .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_end_tl } {##1} }, - misc-remove-delims .multichoices:nn = - { fun, var, frac } - { \bool_set_false:c { l__deriv_#1_mics_##1_bool } }, - misc-remove-delims .default:n = { fun, var, frac }, + switch-* .bool_set:c = { l__deriv_i_#1_switch_star_bool }, - sort-method .clist_set:c = { l__deriv_#1_sort_method_clist }, % måske seq - sort-method .default:n = { abs, sign, symbol }, + var .clist_set:c = { l__deriv_i_#1_misc_var_clist }, + var .default:n = {all}, - sort-numerical .choices:nn = - { auto, first, last } - { \tl_set_eq:cN { l__deriv_#1_sort_numerical_tl } \l_keys_choice_tl }, - sort-numerical .default:n = { auto }, - - sort-sign-reverse .bool_set:c = { l__deriv_#1_sort_sign_reverse_bool }, - sort-sign-reverse .default:n = { false }, - sort-symbol-reverse .bool_set:c = { l__deriv_#1_sort_symbol_reverse_bool }, - sort-symbol-reverse .default:n = { false }, - sort-abs-reverse .bool_set:c = { l__deriv_#1_sort_abs_reverse_bool }, - sort-abs-reverse .default:n = { false } + order .clist_set:c = { l__deriv_i_#1_misc_order_clist }, + ord .clist_set:c = { l__deriv_i_#1_misc_order_clist }, } - \bool_lazy_or:nnT { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: } - { \keys_define:nn { deriv/p/#1 } { style-inf .default:n = { \symnormal } } } - \sys_if_engine_pdftex:T - { \keys_define:nn { deriv/p/#1 } { style-inf .default:n = { \mathnormal } } } } %%%%% Setting keys %%%%% \DeclareDocumentCommand{\derivset}{ m o } { - \token_if_macro:NTF {#1} - { \tl_set:Nx \l__deriv_derivset_tl { \cs_to_str:N #1 } } - { \tl_set:Nx \l__deriv_derivset_tl { \tl_to_str:n {#1} } } - - \__deriv_derivset:Vn \l__deriv_derivset_tl {#2} -} - -\cs_new_protected:Npn \__deriv_derivset:nn #1 #2 -{ - \seq_if_in:NnTF \l__deriv_d_variant_seq {#1} - { \__deriv_d_set_keys:nn {#1} {#2} } + \str_if_eq:nnTF {#1} { all } { - \seq_if_in:NnTF \l__deriv_p_variant_seq {#1} - { \__deriv_p_set_keys:nn {#1} {#2} } - { - \str_if_eq:nnTF {#1} { all } - { \__deriv_all_set_keys:n {#2} } - { - \msg_error:nnxx { deriv } { derivative-not-defined } - { \token_to_str:N #1 } - { \token_to_str:N \derivset } - } - } + \__deriv_set_default:nnn { all } {#2} { all } + \keys_set:nn { deriv/all/all } { default } + } + { + \tl_set:Nx \l__deriv_derivset_tl { \cs_to_str:N #1 } + \deriv_set_keys:Vn \l__deriv_derivset_tl {#2} } } -% dv , key=val clist -\cs_new_protected:Npn \__deriv_d_set_keys:nn #1 #2 +% dv, keyval +\cs_new_protected:Npn \deriv_set_keys:nn #1 #2 { - \tl_if_novalue:nTF {#2} + \seq_if_in:NnTF \l__deriv_dv_variant_seq {#1} + { \__deriv_set_default:nnn {#1} {#2} { dv } } { - \keys_set:nn { deriv/d/#1 } + \seq_if_in:NnTF \l__deriv_i_variant_seq {#1} + { \__deriv_set_default:nnn {#1} {#2} { i } } { - style-inf , style-frac , style-frac-/ , - scale-eval , scale-eval-/ , scale-fun , scale-var , scale-frac , scale-frac-/ , - delims-eval , delims-eval-/ , delims-fun , delims-var , delims-frac , delims-frac-/ , - sep-inf-ord , sep-inf-fun , sep-ord-fun , sep-var-ord , sep-inf-var , sep-eval-sb , sep-eval-sp , - switch-* , switch-/ , - misc-remove-delims + \msg_error:nnxx { deriv } { derivative-not-defined } + { \token_to_str:N #1 } + { \token_to_str:N \derivset } } } - { \keys_set:nn { deriv/d/#1 } {#2} } } -% key=val clist -\cs_new_protected:Npn \__deriv_p_set_keys:nn #1 #2 +% keyval, dv/i, variant +\cs_new_protected:Npn \deriv_local_keys:nnn #1 #2 #3 { - \tl_if_novalue:nTF {#2} + \tl_if_novalue:nTF {#1} { - \keys_set:nn { deriv/p/#1 } + \bool_if:cT { l__deriv_#2_#3_local_keys_bool } { - style-inf , style-frac , style-frac-/ , - scale-eval , scale-eval-/ , scale-fun , scale-var , scale-frac , scale-frac-/ , - delims-eval , delims-eval-/ , delims-fun , delims-var , delims-frac , delims-frac-/ , - sep-inf-ord , sep-inf-fun , sep-ord-fun , sep-inf-var , sep-var-ord , sep-var-inf , sep-ord-inf , sep-eval-sb , sep-eval-sp , - switch-* , switch-/ , - sort-method , sort-numerical , sort-sign-reverse , sort-symbol-reverse , sort-abs-reverse , - misc-remove-delims + \keys_set:nn { deriv/#2/#3 } { default } + \bool_set_false:c { l__deriv_#2_#3_local_keys_bool } } } - { \keys_set:nn { deriv/p/#1 } {#2} } -} -% key=val clist -\cs_new_protected:Npn \__deriv_all_set_keys:n #1 -{ - \tl_if_novalue:nTF {#1} - { \keys_set:nn { deriv-all-settings } { scale-auto } } - { \keys_set:nn { deriv-all-settings } {#1} } + { + \bool_if:cTF { l__deriv_#2_#3_local_keys_bool } + { \keys_set:nn { deriv/#2/#3 } { default, #1 } } + { \keys_set:nn { deriv/#2/#3 } {#1} } + \bool_set_true:c { l__deriv_#2_#3_local_keys_bool } + } } - %%%%% Declaring variants %%%%% -% tl-dv , macro , key-value -\cs_new_protected:Npn \deriv_d_preamble:Nnn #1 #2 #3 +% tl-dv, macro, inf, keyval, dv/i +\cs_new_protected:Npn \deriv_preamble:NNnnn #1 #2 #3 #4 #5 { \tl_set:Nx #1 { \cs_to_str:N #2 } - \seq_if_in:NVF \l__deriv_d_variant_seq #1 - { - \seq_put_left:NV \l__deriv_d_variant_seq #1 - \__deriv_d_variables:V #1 - \__deriv_d_define_keys:V #1 - } - \__deriv_derivset:VV #1 \c_novalue_tl - \tl_if_novalue:nF {#3} { \__deriv_derivset:Vn #1 {#3} } + \__deriv_preamble_aux:Vnn #1 {#4} {#5} + \exp_args:NV \deriv_set_style_inf:nnn {#1} {#3} {#5} } -% dv , new/delare/renew/provide , macro , inf -\cs_new_protected:Npn \deriv_d_define:nnnn #1 #2 #3 #4 +% dv/i, variant, inf +\cs_new_protected:Npn \deriv_set_style_inf:nnn #1 #2 #3 +{ \keys_set:nn { deriv/#3/#1 } { style-inf = {#2} } } +% variant, key-value, dv/i +\cs_new_protected:Npn \__deriv_preamble_aux:nnn #1 #2 #3 { - \exp_args:Nnnx - \use:c { #2 DocumentCommand }{#3}{ s o m t/ m !e{\char_generate:nn {`_}{8}^} } + \seq_if_in:cnF { l__deriv_#3_variant_seq } {#1} { - \group_begin: - \exp_args:Nnc \bool_xor:nnTF {##4} { l__deriv_#1_switch_slash_bool } - { - \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_#1_switch_star_bool } - { \__deriv_odv_both:nnnnnnn {#4} {#1} {##2} {##3} {##5} {##6} {##7} } - { \__deriv_odv_slash:nnnnnnn {#4} {#1} {##2} {##3} {##5} {##6} {##7} } - } - { - \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_#1_switch_star_bool } - { \__deriv_odv_star:nnnnnnn {#4} {#1} {##2} {##3} {##5} {##6} {##7} } - { \__deriv_odv_none:nnnnnnn {#4} {#1} {##2} {##3} {##5} {##6} {##7} } - } - \group_end: + \seq_put_left:cn { l__deriv_#3_variant_seq } {#1} + \use:c { __deriv_#3_variables:n } {#1} + \use:c { __deriv_#3_define_keys:n } {#1} } + \prop_set_eq:cc { l__deriv_#3_#1_user_keys_prop } { c__deriv_#3_pkg_keys_prop } + \__deriv_set_default:nnn {#1} {#2} {#3} } -% tl-dv , macro , key-value -\cs_new_protected:Npn \deriv_p_preamble:Nnn #1 #2 #3 +% data-type, variant, category, cs-var-list +\cs_new:Npn \__deriv_new:nnnn #1 #2 #3 #4 { - \tl_set:Nx #1 { \cs_to_str:N #2 } - \seq_if_in:NVF \l__deriv_p_variant_seq #1 - { - \seq_put_left:NV \l__deriv_p_variant_seq #1 - \__deriv_p_variables:V #1 - \__deriv_p_define_keys:V #1 - } - \__deriv_derivset:VV #1 \c_novalue_tl - \tl_if_novalue:nF {#3} { \__deriv_derivset:Vn #1 {#3} } + \seq_set_from_clist:Nn \l__deriv_new_var_seq {#4} + \seq_map_inline:Nn \l__deriv_new_var_seq + { \cs:w #1_new:c \cs_end: { l__deriv_#2_#3_##1_#1 } } +} +% variant +\cs_new_protected:Npn \__deriv_dv_variables:n #1 +{ + \__deriv_new:nnnn { tl } {dv_#1} { style } { inf, var, frac, frac_slash } + \__deriv_new:nnnn { tl } {dv_#1} { scale } { eval, eval_slash, fun, var, frac, frac_slash } + \__deriv_new:nnnn { tl } {dv_#1} { delims } { eval, eval_slash, fun, var, frac, frac_slash } + \__deriv_new:nnnn { tl } {dv_#1} { sep } { inf_ord, inf_fun, ord_fun, frac_fun, inf_var, var_ord, var_inf, ord_inf, eval_sb, eval_sp } + \__deriv_new:nnnn { bool } {dv_#1} { switch } { star, slash } + \__deriv_new:nnnn { clist } {dv_#1} { sort } { method } + \__deriv_new:nnnn { tl } {dv_#1} { sort } { numerical } + \__deriv_new:nnnn { bool } {dv_#1} { sort } { abs_reverse, sign_reverse, symbol_reverse, number_reverse } + \__deriv_new:nnnn { bool } {dv_#1} { misc } { fun, frac } + \__deriv_new:nnnn { clist } {dv_#1} { misc } { var } + + \__deriv_new:nnnn { clist } {dv_#1} { misc } { order } + \__deriv_new:nnnn { tl } {dv_#1} { misc } { mixed_order } + \__deriv_new:nnnn { prop } {dv_#1} { user } { keys } + \__deriv_new:nnnn { bool } {dv_#1} { local } { keys } +} +% variant +\cs_new_protected:Npn \__deriv_i_variables:n #1 +{ + \__deriv_new:nnnn { tl } {i_#1} { style } { inf, notation, notation_star } + \__deriv_new:nnnn { tl } {i_#1} { scale } { var, var_star } + \__deriv_new:nnnn { tl } {i_#1} { delims } { var, var_star } + \__deriv_new:nnnn { tl } {i_#1} { sep } { begin, inf_ord, inf_var, ord_var, var_inf, var_var, ord_ord, end } + \__deriv_new:nnnn { bool } {i_#1} { switch } { star } + \__deriv_new:nnnn { bool } {i_#1} { mics } { fun, var, frac } + \__deriv_new:nnnn { clist } {i_#1} { misc } { order } + \__deriv_new:nnnn { prop } {i_#1} { user } { keys } + \__deriv_new:nnnn { bool } {i_#1} { local } { keys } +} +% variant, keyval, dv/i +\cs_new_protected:Npn \__deriv_set_default:nnn #1 #2 #3 +{ + \tl_if_novalue:nTF {#2} + { \prop_set_eq:cc { l__deriv_#3_#1_user_keys_prop } { c__deriv_#3_pkg_keys_prop } } + { \__deriv_update_prop:cn { l__deriv_#3_#1_user_keys_prop } {#2} } + + \__deriv_set_default_from_prop:Nc \l__deriv_tmp_keys_tl { l__deriv_#3_#1_user_keys_prop } + \__deriv_set_default_aux:Vnn \l__deriv_tmp_keys_tl {#1} {#3} } -% dv , new/delare/renew/provide , macro , inf -\cs_new_protected:Npn \deriv_p_define:nnnn #1 #2 #3 #4 +% user-prop, key-val +\cs_new_protected:Npn \__deriv_update_prop:Nn #1 #2 { - \exp_args:Nnnx - \use:c { #2 DocumentCommand }{#3}{ s o o m t/ m !e{\char_generate:nn {`_}{8}^} } + \prop_set_from_keyval:Nn \l__deriv_tmp_keys_prop {#2} + \prop_map_inline:Nn \l__deriv_tmp_keys_prop { \prop_put:Nnn #1 {##1} {##2} } +} +% user-prop +\cs_new_protected:Npn \__deriv_set_default_from_prop:NN #1 #2 +{ + \seq_clear:N \l__deriv_tmp_keys_seq + \prop_map_inline:Nn #2 { \seq_put_right:Nn \l__deriv_tmp_keys_seq { ##1 = {##2} } } + \tl_set:Nx #1 { \seq_use:Nn \l__deriv_tmp_keys_seq { , } } +} +% key-val, variant, dv/i +\cs_new_protected:Npn \__deriv_set_default_aux:nnn #1 #2 #3 +{ + \keys_define:nn { deriv/#3/#2 } { default .meta:n = {#1} } + \keys_set:nn { deriv/#3/#2 } { default } +} +% new/delare/renew/provide, variant, macro +\cs_new_protected:Npn \deriv_dv_define:Nnn #1 #2 #3 +{ + \exp_args:Nne #1 {#3}{ s o m t/ m !e{\char_generate:nn {`_}{8}^} } { \group_begin: - \exp_args:Nnc \bool_xor:nnTF {##5} { l__deriv_#1_switch_slash_bool } + \deriv_local_keys:nnn {##2} { dv } {#2} + + \exp_args:Nnc \bool_xor:nnTF {##4} { l__deriv_dv_#2_switch_slash_bool } { - \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_#1_switch_star_bool } - { \__deriv_pdv_both:nnnnnnnn {#4} {#1} {##2} {##3} {##4} {##6} {##7} {##8} } - { \__deriv_pdv_slash:nnnnnnnn {#4} {#1} {##2} {##3} {##4} {##6} {##7} {##8} } + \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_dv_#2_switch_star_bool } + { \__deriv_dv_both:nnnnn {dv_#2} {##3} {##5} {##6} {##7} } + { \__deriv_dv_slash:nnnnn {dv_#2} {##3} {##5} {##6} {##7} } } { - \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_#1_switch_star_bool } - { \__deriv_pdv_star:nnnnnnnn {#4} {#1} {##2} {##3} {##4} {##6} {##7} {##8} } - { \__deriv_pdv_none:nnnnnnnn {#4} {#1} {##2} {##3} {##4} {##6} {##7} {##8} } + \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_dv_#2_switch_star_bool } + { \__deriv_dv_star:nnnnn {dv_#2} {##3} {##5} {##6} {##7} } + { \__deriv_dv_none:nnnnn {dv_#2} {##3} {##5} {##6} {##7} } } \group_end: } } -% dv -\cs_new_protected:Npn \__deriv_d_variables:n #1 -{ - \__deriv_new:nnnn { tl } {#1} { style } { inf, frac, frac_slash } - \__deriv_new:nnnn { tl } {#1} { scale } { eval, eval_slash, fun, var, frac, frac_slash } - \__deriv_new:nnnn { tl } {#1} { delims } { eval, eval_slash, fun, var, frac, frac_slash } - \__deriv_new:nnnn { muskip } {#1} { sep } { inf_ord, inf_fun, ord_fun, var_ord, inf_var, eval_sb, eval_sp } - \__deriv_new:nnnn { bool } {#1} { switch } { star, slash } - \__deriv_new:nnnn { bool } {#1} { mics } { fun, var, frac } -} -% dv -\cs_new_protected:Npn \__deriv_p_variables:n #1 -{ - \__deriv_new:nnnn { tl } {#1} { style } { inf, frac, frac_slash } - \__deriv_new:nnnn { tl } {#1} { scale } { eval, eval_slash, fun, var, frac, frac_slash } - \__deriv_new:nnnn { tl } {#1} { delims } { eval, eval_slash, fun, var, frac, frac_slash } - \__deriv_new:nnnn { muskip } {#1} { sep } { inf_ord, inf_fun, ord_fun, inf_var, var_ord, var_inf, ord_inf, eval_sb, eval_sp } - \__deriv_new:nnnn { bool } {#1} { switch } { star, slash } - \__deriv_new:nnnn { clist } {#1} { sort } { method } - \__deriv_new:nnnn { tl } {#1} { sort } { numerical } - \__deriv_new:nnnn { bool } {#1} { sort } { sign_reverse, symbol_reverse, abs_reverse } - \__deriv_new:nnnn { bool } {#1} { mics } { fun, var, frac } -} -% data-type , dv , category , cs-var-list -\cs_new:Npn \__deriv_new:nnnn #1 #2 #3 #4 +% new/delare/renew/provide, variant, macro +\cs_new_protected:Npn \deriv_i_define:Nnn #1 #2 #3 { - \seq_set_from_clist:Nn \l__deriv_var_seq {#4} - \seq_map_inline:Nn \l__deriv_var_seq - { \cs:w #1_new:c \cs_end: { l__deriv_#2_#3_##1_#1 } } + #1 {#3}{ s o m } + { + \group_begin: + \deriv_local_keys:nnn {##2} { i } {#2} + + \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_i_#2_switch_star_bool } + { \__deriv_inf_star:nn {i_#2} {##3} } + { \__deriv_inf_none:nn {i_#2} {##3} } + \group_end: + } } -%%%%% Ordinary derivative definition %%%%% - -% inf , dv , order , function , variable , sb-point , sp-point -\cs_new_protected:Npn \__deriv_odv_both:nnnnnnn #1 #2 #3 #4 #5 #6 #7 +%%%%% derivative definition %%%%% +% variant, function, variable, sb-point, sp-point +\cs_new_protected:Npn \__deriv_dv_both:nnnnn #1 #2 #3 #4 #5 { - \__deriv_set_order:Nn \l__deriv_d_order_tl {#3} - \__deriv_evaluation_slash:nnnn {#2} {#6} {#7} + \__deriv_dv_preparation:Nnn \l__deriv_dv_denom_tl {#1} {#3} + \__deriv_evaluation_slash:nnnn {#1} {#4} {#5} { - \__deriv_fraction_slash:nn {#2} + \__deriv_fraction_slash:nn {#1} { - \use:c { __deriv_#2_style_frac_slash:n } - { \__deriv_d_numerator_nofun:nn {#1} {#2} } - { \__deriv_d_denominator:nnn {#1} {#2} {#5} } + \use:c { __deriv_#1_style_frac_slash:nn } + { \__deriv_dv_numerator_nofun:n {#1} } + { \__deriv_dv_denominator:n {#1} } } - \__deriv_function:nn {#2} {#4} + \__deriv_insert_fun:nnn {#1} {#2} { frac_fun } } } -% inf , dv , order , function , variable , sb-point , sp-point -\cs_new_protected:Npn \__deriv_odv_star:nnnnnnn #1 #2 #3 #4 #5 #6 #7 +% variant, function, variable, sb-point, sp-point +\cs_new_protected:Npn \__deriv_dv_star:nnnnn #1 #2 #3 #4 #5 { - \__deriv_set_order:Nn \l__deriv_d_order_tl {#3} - \__deriv_evaluation:nnnn {#2} {#6} {#7} + \__deriv_dv_preparation:Nnn \l__deriv_dv_denom_tl {#1} {#3} + \__deriv_evaluation:nnnn {#1} {#4} {#5} { - \__deriv_fraction:nn {#2} + \__deriv_fraction:nn {#1} { - \use:c { __deriv_#2_style_frac:n } - { \__deriv_d_numerator_nofun:nn {#1} {#2} } - { \__deriv_d_denominator:nnn {#1} {#2} {#5} } + \use:c { __deriv_#1_style_frac:nn } + { \__deriv_dv_numerator_nofun:n {#1} } + { \__deriv_dv_denominator:n {#1} } } - \__deriv_function:nn {#2} {#4} + \__deriv_insert_fun:nnn {#1} {#2} { frac_fun } } } -% inf , dv , order , function , variable , sb-point , sp-point -\cs_new_protected:Npn \__deriv_odv_slash:nnnnnnn #1 #2 #3 #4 #5 #6 #7 +% variant, function, variable, sb-point, sp-point +\cs_new_protected:Npn \__deriv_dv_slash:nnnnn #1 #2 #3 #4 #5 { - \__deriv_set_order:Nn \l__deriv_d_order_tl {#3} - \__deriv_evaluation_slash:nnnn {#2} {#6} {#7} + \__deriv_dv_preparation:Nnn \l__deriv_dv_denom_tl {#1} {#3} + \__deriv_evaluation_slash:nnnn {#1} {#4} {#5} { - \__deriv_fraction_slash:nn {#2} + \__deriv_fraction_slash:nn {#1} { - \use:c { __deriv_#2_style_frac_slash:n } - { \__deriv_d_numerator_fun:nnn {#1} {#2} {#4} } - { \__deriv_d_denominator:nnn {#1} {#2} {#5} } + \use:c { __deriv_#1_style_frac_slash:nn } + { \__deriv_dv_numerator_fun:nn {#1} {#2} } + { \__deriv_dv_denominator:n {#1} } } } } -% inf , dv , order , function , variable , sb-point , sp-point -\cs_new_protected:Npn \__deriv_odv_none:nnnnnnn #1 #2 #3 #4 #5 #6 #7 +% variant, function, variable, sb-point, sp-point +\cs_new_protected:Npn \__deriv_dv_none:nnnnn #1 #2 #3 #4 #5 { - \__deriv_set_order:Nn \l__deriv_d_order_tl {#3} - \__deriv_evaluation:nnnn {#2} {#6} {#7} + \__deriv_dv_preparation:Nnn \l__deriv_dv_denom_tl {#1} {#3} + \__deriv_evaluation:nnnn {#1} {#4} {#5} { - \__deriv_fraction:nn {#2} + \__deriv_fraction:nn {#1} { - \use:c { __deriv_#2_style_frac:n } - { \__deriv_d_numerator_fun:nnn {#1} {#2} {#4} } - { \__deriv_d_denominator:nnn {#1} {#2} {#5} } + \use:c { __deriv_#1_style_frac:nn } + { \__deriv_dv_numerator_fun:nn {#1} {#2} } + { \__deriv_dv_denominator:n {#1} } } } -} -% inf , dv , function -\cs_new_protected:Npn \__deriv_d_numerator_fun:nnn #1 #2 #3 +}% variant, function +\cs_new_protected:Npn \__deriv_dv_numerator_fun:nn #1 #2 { - \__deriv_insert_inf:nn {#1} {#2} - \__deriv_insert_ord:Nnn \l__deriv_d_order_tl {#2} { inf_ord } - \__deriv_insert_fun:Nnn \l__deriv_d_order_tl {#2} {#3} + \__deriv_insert_inf:n {#1} + \__deriv_show_order:cTF { l__deriv_#1_misc_mixed_order_tl } + { + \__deriv_insert_ord:cnn { l__deriv_#1_misc_mixed_order_tl } {#1} { inf_ord } + \__deriv_insert_fun:nnn {#1} {#2} { ord_fun } + } + { \__deriv_insert_fun:nnn {#1} {#2} { inf_fun } } } -% inf , dv -\cs_new_protected:Npn \__deriv_d_numerator_nofun:nn #1 #2 +% variant +\cs_new_protected:Npn \__deriv_dv_numerator_nofun:n #1 { - \__deriv_insert_inf:nn {#1} {#2} - \__deriv_insert_ord:Nnn \l__deriv_d_order_tl {#2} { inf_ord } + \__deriv_insert_inf:n {#1} + \__deriv_show_order:cT { l__deriv_#1_misc_mixed_order_tl } + { \__deriv_insert_ord:cnn { l__deriv_#1_misc_mixed_order_tl } {#1} { inf_ord } } } -% inf , dv , variable -\cs_new_protected:Npn \__deriv_d_denominator:nnn #1 #2 #3 +% dv +\cs_new_protected:Npn \__deriv_dv_denominator:n #1 +{ \tl_use:N \l__deriv_dv_denom_tl } +% denom-tl, variant, variable +\cs_new_protected:Npn \__deriv_dv_preparation:Nnn #1 #2 #3 +{ + \tl_clear:N #1 + \seq_set_from_clist:Nn \l__deriv_dv_var_seq {#3} + \seq_set_from_clist:Nc \l__deriv_dv_order_seq { l__deriv_#2_misc_order_clist } + + \__deriv_dv_choose_var:NNNn \l__deriv_dv_var_seq \l__deriv_dv_order_seq #1 {#2} +} +% var-seq, order-seq, denom-tl, variant +\cs_new_protected:Npn \__deriv_dv_choose_var:NNNn #1 #2 #3 #4 { - \__deriv_insert_inf:nn {#1} {#2} - \__deriv_insert_var_ord:Nnn \l__deriv_d_order_tl {#2} {#3} + \exp_args:Nv + \str_case:nn { l__deriv_#4_style_var_tl } + { + { single } { \__deriv_dv_build_single:NNNn #1 #2 #3 {#4} } + { multiple } { \__deriv_dv_build_multiple:NNNn #1 #2 #3 {#4} } + } } - -%%%%% Partial derivative definition %%%%% -% inf , dv , order , mixed order , function , variable , sb-point , sp-point -\cs_new_protected:Npn \__deriv_pdv_both:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8 +% var_seq, order_seq, denom-tl, variant +\cs_new_protected:Npn \__deriv_dv_build_multiple:NNNn #1 #2 #3 #4 { - \__deriv_preparation:NNnnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl {#1} {#2} {#3} {#4} {#6} - \__deriv_evaluation_slash:nnnn {#2} {#7} {#8} + \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 } + \__deriv_adjust_ord_seq:NN #1 #2 + + \str_if_eq:cNT { l__deriv_#4_misc_mixed_order_tl } 1 + { \__deriv_mixed_order:cNn { l__deriv_#4_misc_mixed_order_tl } #2 {#4} } + + \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_tmpa_seq \l__deriv_tmpa_int + + \seq_map_indexed_inline:Nn #1 { - \__deriv_fraction_slash:nn {#2} + \seq_pop_left:NN #2 \l__deriv_tmpa_tl + \seq_pop_left:NN \l__deriv_tmpa_seq \l__deriv_tmpb_tl + \tl_put_right:Nx #3 { - \use:c { __deriv_#2_style_frac_slash:n } - { \__deriv_p_numerator_nofun:nn {#1} {#2} } - { \__deriv_p_denominator:n {#2} } + \__deriv_insert_inf:n {#4} + \__deriv_insert_mskip:nn {#4} { inf_var } + \__deriv_insert_var:Nnn \l__deriv_tmpb_tl {##2} {#4} + \__deriv_show_order:NTF \l__deriv_tmpa_tl + { + \__deriv_insert_ord:Nnn \l__deriv_tmpa_tl {#4} { var_ord } + \int_compare:nNnF {##1} = { \l__deriv_tmpa_int } + { \__deriv_insert_mskip:nn {#4} { ord_inf } } + } + { + \int_compare:nNnF {##1} = { \l__deriv_tmpa_int } + { \__deriv_insert_mskip:nn {#4} { var_inf } } + } } - \__deriv_function:nn {#2} {#5} } } -% inf , dv , order , mixed order , function , variable , sb-point , sp-point -\cs_new_protected:Npn \__deriv_pdv_star:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8 +% var_seq, order_seq, denom-tl, variant +\cs_new_protected:Npn \__deriv_dv_build_single:NNNn #1 #2 #3 #4 +{ + \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 } + \tl_set:Nx \l__deriv_tmpa_tl { \seq_use:Nn #1 { \__deriv_insert_mskip:nn {#4} { var_var } } } + + \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_tmpa_seq \l__deriv_tmpa_int + + \seq_pop_left:NN #2 \l__deriv_tmpb_tl + \seq_pop_left:NN \l__deriv_tmpa_seq \l__deriv_tmpc_tl + \tl_put_right:Nx #3 + { + \__deriv_insert_inf:n {#4} + \__deriv_insert_mskip:nn {#4} { inf_var } + \__deriv_insert_var:NVn \l__deriv_tmpc_tl \l__deriv_tmpa_tl {#4} + \__deriv_show_order:NT \l__deriv_tmpb_tl + { \__deriv_insert_ord:Nnn \l__deriv_tmpb_tl {#4} { var_ord } } + } + \str_if_eq:cNT { l__deriv_#4_misc_mixed_order_tl } 1 + { \tl_set_eq:cN { l__deriv_#4_misc_mixed_order_tl } \l__deriv_tmpb_tl } +} +% var_seq, order_seq +\cs_new_protected:Npn \__deriv_adjust_ord_seq:NN #1 #2 { - \__deriv_preparation:NNnnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl {#1} {#2} {#3} {#4} {#6} - \__deriv_evaluation:nnnn {#2} {#7} {#8} + \int_set:Nn \l__deriv_vmo_int { \seq_count:N #1 - \seq_count:N #2 } + + \int_compare:nNnF { \l__deriv_vmo_int } = { 0 } { - \__deriv_fraction:nn {#2} + \int_compare:nNnTF { \l__deriv_vmo_int } < { 0 } + { + \int_step_inline:nn { -1 * \l__deriv_vmo_int } + { \seq_pop_right:NN #2 \l__deriv_tmpa_tl } + } { - \use:c { __deriv_#2_style_frac:n } - { \__deriv_p_numerator_nofun:nn {#1} {#2} } - { \__deriv_p_denominator:n {#2} } + \int_step_inline:nn { \l__deriv_vmo_int } + { \seq_put_right:Nn #2 { 1 } } } - \__deriv_function:nn {#2} {#5} } } -% inf , dv , order , mixed order , function , variable , sb-point , sp-point -\cs_new_protected:Npn \__deriv_pdv_slash:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8 +% avd-clist, bool-seq, count +\cs_new_protected:Npn \__deriv_var_bool_seq:NNN #1 #2 #3 { - \__deriv_preparation:NNnnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl {#1} {#2} {#3} {#4} {#6} - \__deriv_evaluation_slash:nnnn {#2} {#7} {#8} + \seq_clear:N #2 + \clist_if_in:NnTF #1 { all } { - \__deriv_fraction_slash:nn {#2} + \exp_args:NNx + \seq_set_from_clist:Nn #2 { \prg_replicate:nn {#3} { \c_true_bool , } } + } + { + \clist_if_in:NnTF #1 { none } { - \use:c { __deriv_#2_style_frac_slash:n } - { \__deriv_p_numerator_fun:nnn {#1} {#2} {#5} } - { \__deriv_p_denominator:n {#2} } + \exp_args:NNx + \seq_set_from_clist:Nn #2 { \prg_replicate:nn {#3} { \c_false_bool , } } + } + { + \int_step_inline:nn {#3} + { + \clist_if_in:NnTF #1 {##1} + { \seq_put_right:Nn #2 { \c_true_bool } } + { \seq_put_right:Nn #2 { \c_false_bool } } + } } } } -% inf , dv , order , mixed order , function , variable , sb-point , sp-point -\cs_new_protected:Npn \__deriv_pdv_none:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8 +% ord-seq, var-seq +\cs_new_protected:Npn \__deriv_adjust_trailing_ord:NN #1 #2 { - \__deriv_preparation:NNnnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl {#1} {#2} {#3} {#4} {#6} - \__deriv_evaluation:nnnn {#2} {#7} {#8} + \seq_clear:N \l__deriv_tmpa_seq + \bool_set_false:N \l__deriv_tmpa_bool + \int_set:Nn \l__deriv_vmo_int { \seq_count:N #2 - \seq_count:N #1 } + + \int_compare:nNnT { \l__deriv_vmo_int } < { 0 } { - \__deriv_fraction:nn {#2} + \int_step_inline:nn { -1*\l__deriv_vmo_int } + { \seq_pop_right:NN #1 \l__deriv_tmpa_tl } + } + + \seq_reverse:N #1 + \seq_map_inline:Nn #1 + { + \bool_if:NTF \l__deriv_tmpa_bool + { \seq_put_right:Nn \l__deriv_tmpa_seq {##1} } { - \use:c { __deriv_#2_style_frac:n } - { \__deriv_p_numerator_fun:nnn {#1} {#2} {#5} } - { \__deriv_p_denominator:n {#2} } + \str_if_eq:nnF {##1} { 1 } + { + \seq_put_right:Nn \l__deriv_tmpa_seq {##1} + \bool_set_true:N \l__deriv_tmpa_bool + } } } -}% inf , dv , function -\cs_new_protected:Npn \__deriv_p_numerator_fun:nnn #1 #2 #3 + \seq_set_eq:NN #1 \l__deriv_tmpa_seq + \seq_reverse:N #1 +} + +%%%%% infinisimal definition %%%%% +% variant, variable +\cs_new:Npn \__deriv_inf_none:nn #1 #2 { - \__deriv_insert_inf:nn {#1} {#2} - \__deriv_insert_ord:Nnn \l__deriv_p_mo_tl {#2} { inf_ord } - \__deriv_insert_fun:Nnn \l__deriv_p_mo_tl {#2} {#3} + \__deriv_i_preparation:Nnnn \l__deriv_i_denom_tl {#1} {#2} { } + \__deriv_i_print:Nn \l__deriv_i_denom_tl {#1} } -% inf , dv -\cs_new_protected:Npn \__deriv_p_numerator_nofun:nn #1 #2 + +% variant, variable +\cs_new:Npn \__deriv_inf_star:nn #1 #2 { - \__deriv_insert_inf:nn {#1} {#2} - \__deriv_insert_ord:Nnn \l__deriv_p_mo_tl {#2} { inf_ord } + \__deriv_i_preparation:Nnnn \l__deriv_i_denom_tl {#1} {#2} { _star } + \__deriv_i_print:Nn \l__deriv_i_denom_tl {#1} } -% dv -\cs_new_protected:Npn \__deriv_p_denominator:n #1 +% print-tl, variant +\cs_new:Npn \__deriv_i_print:Nn #1 #2 { - \tl_use:N \l__deriv_p_denom_tl %{ \__deriv_insert_mskip:nn {#1} { var_inf } } + \__deriv_insert_mskip:nn {#2} { begin } + \tl_use:N #1 + \__deriv_insert_mskip:nn {#2} { end } } -% mixed-order-tl , denom-seq , inf , dv , order , mixed order , variable -\cs_new_protected:Npn \__deriv_preparation:NNnnnnn #1 #2 #3 #4 #5 #6 #7 +% print-tl, variant, variable, if star +\cs_new_protected:Npn \__deriv_i_preparation:Nnnn #1 #2 #3 #4 { - \seq_clear:N #2 - \seq_set_from_clist:Nn \l__deriv_p_var_seq {#7} - \tl_if_novalue:nTF {#5} { \seq_clear:N \l__deriv_p_order_seq } { \seq_set_from_clist:Nn \l__deriv_p_order_seq {#5} } + \tl_clear:N #1 + \seq_set_from_clist:Nn \l__deriv_i_var_seq {#3} + \seq_set_from_clist:Nc \l__deriv_i_order_seq { l__deriv_#2_misc_order_clist } - \tl_if_novalue:nTF {#6} + \__deriv_i_choose_build:NNNnn \l__deriv_i_var_seq \l__deriv_i_order_seq #1 {#2} {#4} +} +% var-seq, order-seq, print-tl, variant, if star +\cs_new_protected:Npn \__deriv_i_choose_build:NNNnn #1 #2 #3 #4 #5 +{ + \exp_args:Nv + \str_case:nn { l__deriv_#4_style_notation#5_tl } { - \seq_set_eq:NN \l__deriv_p_mo_seq \l__deriv_p_order_seq - \__deriv_adjust_mo_seq:NNN \l__deriv_p_mo_seq \l__deriv_p_var_seq \l__deriv_p_order_seq - \__deriv_mixed_order:NNn #1 \l__deriv_p_mo_seq {#4} + { single } { \__deriv_i_build_single:NNNnn #1 #2 #3 {#4} {#5} } + { multiple } { \__deriv_i_build_multiple:NNNnn #1 #2 #3 {#4} {#5} } + { mixed } { \__deriv_i_build_mixed:NNNnn #1 #2 #3 {#4} {#5} } } - { \tl_set:Nn #1 {#6} } - - \__deriv_p_build_denom:NNNnn \l__deriv_p_var_seq \l__deriv_p_order_seq #2 {#3} {#4} } - -\cs_new_protected:Npn \__deriv_adjust_mo_seq:NNN #1 #2 #3 +% var-seq, order-seq, print-tl, variant, if star +\cs_new_protected:Npn \__deriv_i_build_single:NNNnn #1 #2 #3 #4 #5 { - \int_set:Nn \l__deriv_vmo_int { \seq_count:N #2 - \seq_count:N #3 } - \__deriv_case:nF + \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 } + \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int + \__deriv_adjust_trailing_ord:NN #2 #1 + + \int_set:Nn \l__deriv_tmpb_int { \seq_count:N #2 } + + \seq_map_indexed_inline:Nn #1 { - { \int_compare_p:nNn { \l__deriv_vmo_int } > { 0 } } { \seq_put_left:NV #1 \l__deriv_vmo_int } - { \int_compare_p:nNn { \l__deriv_vmo_int } = { 0 } } { \prg_do_nothing: } + \seq_pop_left:NN \l__deriv_add_var_bool_seq \l__deriv_tmpa_tl + \tl_put_right:Nx \l__deriv_tmpb_tl + { + \__deriv_insert_var:Nnnn \l__deriv_tmpa_tl {##2} {#4} {#5} + \int_compare:nNnF {##1} = { \l__deriv_tmpa_int } + { \__deriv_insert_mskip:nn {#4} { var_var } } + } } + \seq_map_indexed_inline:Nn #2 { - \int_step_inline:nn { -1 * \l__deriv_vmo_int } - { \seq_pop_right:NN #1 \l__deriv_p_tmpa_tl } + \tl_put_right:Nx \l__deriv_tmpc_tl + { + \exp_not:n {##2} + \int_compare:nNnF {##1} = { \l__deriv_tmpb_int } + { \__deriv_insert_mskip:nn {#4} { ord_ord } } + } } -} -% \l__deriv_p_var_seq \l__deriv_p_order_seq, denom-tl , inf , dv -\cs_new_protected:Npn \__deriv_p_build_denom:NNNnn #1 #2 #3 #4 #5 -{ - \int_zero:N \l__deriv_tmpa_int - \seq_map_inline:Nn #1 + \tl_put_right:Nx #3 { - \int_incr:N \l__deriv_tmpa_int - \seq_pop_left:NN #2 \l__deriv_p_tmpa_tl - \tl_if_blank:nF {##1} + \__deriv_insert_inf:n {#4} + \sb + { + \__deriv_insert_mskip:nn {#4} { inf_var } + \exp_not:V \l__deriv_tmpb_tl + } + \tl_if_blank:VF \l__deriv_tmpc_tl { - \tl_put_right:Nx #3 + \sp { - \__deriv_insert_inf:nn {#4} {#5} - \int_compare:nNnTF { \l__deriv_tmpa_int } = { \seq_count:N #1 } - { \__deriv_insert_var_ord:Nnn \l__deriv_p_tmpa_tl {#5} {##1} } - { \__deriv_insert_var_ord_sep:Nnn \l__deriv_p_tmpa_tl {#5} {##1} } + \__deriv_insert_mskip:nn {#4} { inf_ord } + \exp_not:V \l__deriv_tmpc_tl } } } } -%%%%% And the rest of the code %%%%% -% inf , dv -\cs_new:Npn \__deriv_insert_inf:nn #1 #2 +% var-seq, order-seq, print-tl, variant +\cs_new_protected:Npn \__deriv_i_build_multiple:NNNnn #1 #2 #3 #4 #5 { - \exp_not:n + \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 } + \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int + \__deriv_adjust_ord_seq:NN #1 #2 + + \seq_map_indexed_inline:Nn #1 { - \use:c { __deriv_#2_style_inf:n } {#1} + \seq_pop_left:NN #2 \l__deriv_tmpa_tl + \seq_pop_left:NN \l__deriv_add_var_bool_seq \l__deriv_tmpb_tl + \tl_put_right:Nx #3 + { + \__deriv_insert_inf:n {#4} + \__deriv_show_order:NTF \l__deriv_tmpa_tl + { + \__deriv_insert_ord:Nnn \l__deriv_tmpa_tl {#4} { inf_ord } + \__deriv_insert_mskip:nn {#4} { ord_var } + } + { \__deriv_insert_mskip:nn {#4} { inf_var } } + + \__deriv_insert_var:Nnnn \l__deriv_tmpb_tl {##2} {#4} {#5} + \int_compare:nNnF {##1} = { \l__deriv_tmpa_int } + { \__deriv_insert_mskip:nn {#4} { var_inf } } + } } } -% dv , function -\cs_new:Npn \__deriv_insert_fun:Nnn #1 #2 #3 +% var-seq, order-seq, print-tl, variant +\cs_new_protected:Npn \__deriv_i_build_mixed:NNNnn #1 #2 #3 #4 #5 { - \tl_if_blank:nF {#3} + \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 } + \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int + \__deriv_adjust_ord_seq:NN #1 #2 + + \seq_map_indexed_inline:Nn #1 { - \str_if_eq:NNTF #1 1 - { \__deriv_insert_mskip:nn {#2} { inf_fun } } - { \__deriv_insert_mskip:nn {#2} { ord_fun } } - \__deriv_function:nn {#2} {#3} + \seq_pop_left:NN #2 \l__deriv_tmpa_tl + \seq_pop_left:NN \l__deriv_add_var_bool_seq \l__deriv_tmpb_tl + \tl_put_right:Nx #3 + { + \__deriv_insert_inf:n {#4} + \__deriv_show_order:NT \l__deriv_tmpa_tl + { \__deriv_insert_ord:Nnn \l__deriv_tmpa_tl {#4} { inf_ord } } + \sb + { + \__deriv_insert_mskip:nn {#4} { inf_var } + \__deriv_insert_var:Nnnn \l__deriv_tmpb_tl {##2} {#4} {#5} + } + \int_compare:nNnF {##1} = { \l__deriv_tmpa_int } + { \__deriv_insert_mskip:nn {#4} { var_inf } } + } } } -% order, dv , variable -\cs_new:Npn \__deriv_insert_var_ord:Nnn #1 #2 #3 +%%%%% And the rest of the code %%%%% +% variant +\cs_new:Npn \__deriv_insert_inf:n #1 +{ \exp_not:v { l__deriv_#1_style_inf_tl } } +% dv, function, muskip +\cs_new:Npn \__deriv_insert_fun:nnn #1 #2 #3 { - \tl_if_blank:nF {#3} + \tl_if_blank:nF {#2} { - \__deriv_insert_mskip:nn {#2} { inf_var } - \exp_not:n { \__deriv_variable:nn {#2} {#3} } - \__deriv_insert_ord:Nnn #1 {#2} { var_ord } + \__deriv_insert_mskip:nn {#1} {#3} + \bool_if:cTF { l__deriv_#1_misc_fun_bool } + { \__deriv_add_delims:nnn {#1} { fun } {#2} } + {#2} } } -\cs_new:Npn \__deriv_insert_var_ord_sep:Nnn #1 #2 #3 +% if delim, variable, variant +\cs_new:Npn \__deriv_insert_var:Nnn #1 #2 #3 { - \tl_if_blank:nF {#3} - { - \__deriv_insert_mskip:nn {#2} { inf_var } - \exp_not:n { \__deriv_variable:nn {#2} {#3} } - \__deriv_insert_ord:Nn #1 {#2} - } + \bool_if:NTF #1 + { \__deriv_add_delims:nnn {#3} { var } {#2} } + { \__deriv_handle_double_sp:n {#2} } } -% dv , name -\cs_new:Npn \__deriv_insert_mskip:nn #1 #2 +% if delim, variable, variant, star +\cs_new:Npn \__deriv_insert_var:Nnnn #1 #2 #3 #4 { - \str_if_eq:vnF { l__deriv_#1_sep_#2_muskip } { 0.0mu } - { \exp_args:Nc \mskip { l__deriv_#1_sep_#2_muskip } } + \bool_if:NTF #1 + { \__deriv_add_delims:nnn {#3} { var#4 } {#2} } + { \__deriv_handle_double_sp:n {#2} } } -% order , dv , name +% order, variant, name \cs_new:Npn \__deriv_insert_ord:Nnn #1 #2 #3 { - \__deriv_show_order:NT #1 + \sp { - \sp - { - \__deriv_insert_mskip:nn {#2} {#3} - \tl_use:N #1 - } + \__deriv_insert_mskip:nn {#2} {#3} + \exp_not:V #1 } } -% order , dv , name -\cs_new:Npn \__deriv_insert_ord:Nn #1 #2 +% dv, name +\cs_new:Npn \__deriv_insert_mskip:nn #1 #2 +{ + %[#2] + \tl_if_empty:cF { l__deriv_#1_sep_#2_tl } + { \exp_not:v { l__deriv_#1_sep_#2_tl } } + %\exp_not:v { l__deriv_#1_sep_#2_tl } +} +% muskip, length +\cs_new:Npn \__deriv_set_rubber_length:Nn #1 #2 { - \__deriv_show_order:NTF #1 + \regex_match:NnTF \c__deriv_cs_numbers_regex {#2} { - \sp + \str_case_e:nnF {#2} + { + { 0 } { \tl_clear:N #1 } + { 0,0 } { \tl_clear:N #1 } + { 0,0,0 } { \tl_clear:N #1 } + } { - \__deriv_insert_mskip:nn {#2} { var_ord } - \tl_use:N #1 + \seq_set_split:Nnn \l__deriv_rubber_seq { , } {#2} + \tl_set:Nf #1 { \seq_use:Nnnn \l__deriv_rubber_seq { mu plus } { mu plus } { mu minus } mu } + \tl_put_left:Nn #1 { \mskip } } - \__deriv_insert_mskip:nn {#2} { ord_inf } } - { \__deriv_insert_mskip:nn {#2} { var_inf } } -} -% order , order-list -\cs_new:Npn \__deriv_set_order:Nn #1 #2 -{ - \tl_if_novalue:nTF {#2} - { \tl_set:Nn #1 { 1 } } - { \tl_set:Nn #1 {#2} } -} -% muskip , length -\cs_new:Npn \__deriv_set_rubber_length:Nn #1 #2 -{ - \seq_set_split:Nnn \l__deriv_rubber_seq { , } { #2 } - \exp_args:NNf - \muskip_set:Nn #1 { \seq_use:Nnnn \l__deriv_rubber_seq { mu plus } { mu plus } { mu minus } mu } + { \tl_set:Nn #1 {#2} } } %%%%% Scale, delimiters, evaluation %%%%% -% dv , function -\cs_new:Npn \__deriv_function:nn #1 #2 -{ - \bool_set_false:c { l__deriv_#1_mics_var_bool } - \bool_if:cTF { l__deriv_#1_mics_fun_bool } - { - \bool_set_false:c { l__deriv_#1_mics_fun_bool } - \__deriv_add_delims:nnn {#1} { fun } {#2} - } - { #2 } -} -% dv , variable -\cs_new:Npn \__deriv_variable:nn #1 #2 -{ - \bool_if:cTF { l__deriv_#1_mics_var_bool } - { - \bool_set_false:c { l__deriv_#1_mics_var_bool } - \__deriv_add_delims:nnn {#1} { var } {#2} - } - { \__deriv_handle_double_sp:n {#2} } -} % variable \cs_new:Npn \__deriv_handle_double_sp:n #1 { - \tl_set:Nn \l_tmpa_tl {#1} - \str_set:Nn \l_tmpa_str {#1} - - \str_if_in:NnTF \l_tmpa_str { ^ } + \str_case_e:nnF { ^ } { - \exp_args:Nf - \str_if_eq:nnTF { \tl_item:Nn \l_tmpa_tl {-2} } { ^ } - { {#1} } - { - \exp_args:Nf - \str_if_eq:nnTF { \tl_item:Nn \l_tmpa_tl {-4} } { ^ } - { {#1} } - { #1 } - } + { \tl_item:nn {#1} { -2 } } { \exp_not:n { {#1} } } + { \tl_item:nn {#1} { -4 } } { \exp_not:n { {#1} } } } - {#1} + { \exp_not:n {#1} } } -% dv , code-for-fraction +% dv, code-for-fraction \cs_new:Npn \__deriv_fraction:nn #1 #2 { - \bool_if:cTF { l__deriv_#1_mics_frac_bool } - { - \bool_set_false:c { l__deriv_#1_mics_frac_bool } - \__deriv_add_delims:nnn {#1} { frac } {#2} - } - { #2 } + \bool_if:cTF { l__deriv_#1_misc_frac_bool } + { \__deriv_add_delims:nnn {#1} { frac } {#2} } + {#2} } -% dv , code-for-fraction +% dv, code-for-fraction \cs_new:Npn \__deriv_fraction_slash:nn #1 #2 { - \bool_if:cTF { l__deriv_#1_mics_frac_bool } - { - \bool_set_false:c { l__deriv_#1_mics_frac_bool } - \__deriv_add_delims:nnn {#1} { frac_slash } {#2} - } - { #2 } + \bool_if:cTF { l__deriv_#1_misc_frac_bool } + { \__deriv_add_delims:nnn {#1} { frac_slash } {#2} } + {#2} } -% dv , sub , sup , code-for-fraction +% dv, sub, sup, code-for-fraction \cs_new:Npn \__deriv_evaluation:nnnn #1 #2 #3 #4 { \__deriv_if_novalue_and:nnTF {#2} {#3} - { #4 } + {#4} { \__deriv_add_delims:nnn {#1} { eval } {#4} \__deriv_if_novalue:nF {#2} { \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 } } \__deriv_if_novalue:nF {#3} { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } } } } -% dv , sub , sup , code-for-fraction +% dv, sub, sup, code-for-fraction \cs_new:Npn \__deriv_evaluation_slash:nnnn #1 #2 #3 #4 { \__deriv_if_novalue_and:nnTF {#2} {#3} - { #4 } + {#4} { \__deriv_add_delims:nnn {#1} { eval_slash } {#4} \__deriv_if_novalue:nF {#2} { \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 } } \__deriv_if_novalue:nF {#3} { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } } } } -% dv , name , value +% dv, name, value \cs_new:Npn \__deriv_add_delims:nnn #1 #2 #3 { - \__deriv_scale_left:nn {#1} {#2} - {#3} - \__deriv_scale_right:nn {#1} {#2} -} -% dv , name -\cs_new:Npn \__deriv_scale_left:nn #1 #2 -{ - \exp_args:Nv \str_case:nnF { l__deriv_#1_scale_#2_tl } - { - { auto } { \__deriv_scale_auto:Nnnn \__deriv_auto_left:n {#1} {#2} { 1 } } - { none } { \__deriv_scale_none:nnn {#1} {#2} { 1 } } - } - { \__deriv_scale_big:nnnn {#1} {#2} { 1 } { l } } + \__deriv_scale:Nnnnn \__deriv_auto_left:n {#1} {#2} { 1 } { l } + #3 + \__deriv_scale:Nnnnn \__deriv_auto_right:n {#1} {#2} { 2 } { r } } -% dv , name -\cs_new:Npn \__deriv_scale_right:nn #1 #2 +% dv, name +\cs_new:Npn \__deriv_scale:Nnnnn #1 #2 #3 #4 #5 { - \exp_args:Nv \str_case:nnF { l__deriv_#1_scale_#2_tl } + \exp_args:Nv \str_case:nnF { l__deriv_#2_scale_#3_tl } { - { auto } { \__deriv_scale_auto:Nnnn \__deriv_auto_right:n {#1} {#2} { 2 } } - { none } { \__deriv_scale_none:nnn {#1} {#2} { 2 } } + { auto } { \__deriv_scale_auto:Nnnn #1 {#2} {#3} {#4} } + { none } { \__deriv_scale_none:nnn {#2} {#3} {#4} } } - { \__deriv_scale_big:nnnn {#1} {#2} { 2 } { r } } + { \__deriv_scale_big:nnnn {#2} {#3} {#4} {#5} } } -% left/right , dv , name, number +% left/right, variant, name, number \cs_new:Npn \__deriv_scale_auto:Nnnn #1 #2 #3 #4 -{ - #1 \tl_item:cn { l__deriv_#2_delims_#3_tl } { #4 } -} -% dv , name , number +{ #1 \tl_item:cn { l__deriv_#2_delims_#3_tl } {#4} } +% dv, name, number \cs_new:Npn \__deriv_scale_none:nnn #1 #2 #3 -{ - \str_if_eq:cNF { l__deriv_#1_delims_#2_tl } . { \tl_item:cn { l__deriv_#1_delims_#2_tl } { #3 } } -} -% dv , name , number , l/r +{ \str_if_eq:cNF { l__deriv_#1_delims_#2_tl } . { \tl_item:cn { l__deriv_#1_delims_#2_tl } {#3} } } +% dv, name, number, l/r \cs_new:Npn \__deriv_scale_big:nnnn #1 #2 #3 #4 -{ - \tl_use:c { \tl_use:c { l__deriv_#1_scale_#2_tl } #4 } { \tl_item:cn { l__deriv_#1_delims_#2_tl } { #3 } } -} +{ \tl_use:c { \tl_use:c { l__deriv_#1_scale_#2_tl } #4 } { \tl_item:cn { l__deriv_#1_delims_#2_tl } {#3} } } %%%%% Calculation of mixed order %%%%% -% mixed-order-tl , mixed-order-seq , dv +% mixed-order-tl, mixed-order-seq, variant \cs_new:Npn \__deriv_mixed_order:NNn #1 #2 #3 { \__deriv_replace:NN \l__deriv_input_seq #2 \__deriv_seq_counting:N \l__deriv_input_seq - \__deriv_combine_seq:N \l__deriv_unsorted_seq + \__deriv_combine_seq:Nn \l__deriv_unsorted_seq {#3} \__deriv_sort:NNn \l__deriv_sorted_seq \l__deriv_unsorted_seq {#3} \__deriv_output:NNNn #1 \l__deriv_sorted_seq \l__deriv_numerical_int {#3} } -% input-seq , mixed-order-seq +% input-seq, mixed-order-seq \cs_new_protected:Npn \__deriv_replace:NN #1 #2 { \tl_set:Nf \l__deriv_input_tl { \seq_use:Nn #2 { , } } @@ -990,7 +1051,7 @@ { \__deriv_add_to_seq:NN \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl } } } -% sym-tl , num-tl , seq-item +% sym-tl, num-tl, seq-item \cs_new_protected:Npn \__deriv_extract:NNn #1 #2 #3 { \regex_extract_once:NnN \c__deriv_pattern_regex {#3} \l__deriv_extract_seq @@ -1003,41 +1064,49 @@ { - } { \tl_set:Nn #2 { -1 } } } } -% unsorted-seq -\cs_new:Npn \__deriv_combine_seq:N #1 +% unsorted-seq, variant +\cs_new:Npn \__deriv_combine_seq:Nn #1 #2 { \seq_clear:N #1 + \int_zero:N \l__deriv_numerical_int \seq_map_inline:Nn \l__deriv_symbol_seq { \seq_pop_left:NN \l__deriv_number_seq \l__deriv_num_tmpa_tl - \__deriv_eval_term:NNn #1 \l__deriv_num_tmpa_tl {##1} + \__deriv_eval_term:NVnn #1 \l__deriv_num_tmpa_tl {##1} {#2} } } -% unsorted-seq , num-tl, seq-item -\cs_new_protected:Npn \__deriv_eval_term:NNn #1 #2 #3 +% unsorted-seq, num-tl, seq-item (sym), variant +\cs_new_protected:Npn \__deriv_eval_term:Nnnn #1 #2 #3 #4 { \__deriv_case:nF { - { \tl_if_empty_p:n {#3} } { \int_set:Nn \l__deriv_numerical_int {#2} } - { \int_compare_p:nNn {#2} = { 1 } } { \seq_put_left:Nn #1 {#3} } - { \int_compare_p:nNn {#2} = { 0 } } { \prg_do_nothing: } - { \int_compare_p:nNn {#2} = { -1 } } { \seq_put_left:Nn #1 { -#3 } } + { \tl_if_empty_p:n {#3} } { \__deriv_numerical_term:Nnn #1 {#2} {#4} } + { \int_compare_p:nNn {#2} = { 1 } } { \seq_put_left:Nn #1 {#3} } + { \int_compare_p:nNn {#2} = { 0 } } { \prg_do_nothing: } + { \int_compare_p:nNn {#2} = { -1 } } { \seq_put_left:Nn #1 { -#3 } } } - { \seq_put_left:No #1 { #2 #3 } } + { \seq_put_left:Nn #1 {#2#3} } } -% sym-tl , num-tl +% unsorted-seq, num-tl, variant +\cs_new_protected:Npn \__deriv_numerical_term:Nnn #1 #2 #3 +{ + \str_if_eq:vnTF { l__deriv_#3_sort_numerical_tl } { symbolic } + { \seq_put_left:Nn #1 {#2} } + { \int_set:Nn \l__deriv_numerical_int {#2} } +} +% sym-tl, num-tl \cs_new_protected:Npn \__deriv_add_to_seq:NN #1 #2 { \seq_put_left:NV \l__deriv_symbol_seq #1 \seq_put_left:NV \l__deriv_number_seq #2 } -% sym-tl , num-tl +% sym-tl, num-tl \cs_new_protected:Npn \__deriv_update_seq:NN #1 #2 { \__deriv_get_position:NN \l__deriv_position_int #1 \__deriv_rebuild_seq:NNN \l__deriv_number_seq \l__deriv_position_int #2 } -% position-int , sym-tl +% position-int, sym-tl \cs_new:Npn \__deriv_get_position:NN #1 #2 { \int_zero:N #1 @@ -1047,10 +1116,10 @@ \exp_args:NV \tl_if_eq:nnT #2 {##1} { \seq_map_break: } } } -% num-seq , position-int , num-tl +% num-seq, position-int, num-tl \cs_new_protected:Npn \__deriv_rebuild_seq:NNN #1 #2 #3 { - \int_zero:N \l__deriv_rebuild_int + \int_zero:N \l__deriv_rebuild_int \seq_clear:N \l__deriv_rebuild_seq \seq_map_inline:Nn #1 @@ -1065,10 +1134,10 @@ } \seq_set_eq:NN #1 \l__deriv_rebuild_seq } -% sorted-seq , unsorted-seq , dv +% sorted-seq, unsorted-seq, variant \cs_new_protected:Npn \__deriv_sort:NNn #1 #2 #3 { - \int_set:Nn \l__deriv_sort_max_int { \clist_count:c { l__deriv_#3_sort_method_clist } } + \int_set:Nn \l__deriv_sort_max_int { \int_min:nn { 3 } { \clist_count:c { l__deriv_#3_sort_method_clist } } } \seq_sort:Nn #2 { @@ -1087,9 +1156,10 @@ \exp_args:Nf \str_case:nn { \clist_item:cn { l__deriv_#1_sort_method_clist } { \l__deriv_sort_counter_int } } { - { sign } { \__deriv_sort_sign:n {#1} } - { symbol } { \__deriv_sort_symbol:n {#1} } - { abs } { \__deriv_sort_abs:n {#1} } + { sign } { \__deriv_sort_sign:n {#1} } + { symbol } { \__deriv_sort_symbol:n {#1} } + { abs } { \__deriv_sort_abs:n {#1} } + { number } { \__deriv_sort_number:n {#1} } } } % dv @@ -1097,8 +1167,8 @@ { \__deriv_case:nF { - { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { same } } - { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { swapped } } + { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { same } } + { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { swapped } } } { \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int } @@ -1111,8 +1181,8 @@ { \__deriv_case:nF { - { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } > { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { same } } - { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } < { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { swapped } } + { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } > { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { same } } + { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } < { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { swapped } } } { \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int } @@ -1125,8 +1195,22 @@ { \__deriv_case:nF { - { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } > { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { same } } - { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } < { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { swapped } } + { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } > { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { same } } + { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } < { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { swapped } } + } + { + \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int } + { \sort_return_same: } + { \__deriv_sort_method:n {#1} } + } +} +% dv +\cs_new_protected:Npn \__deriv_sort_number:n #1 +{ + \__deriv_case:nF + { + { \int_compare_p:nNn { \l__deriv_num_tmpa_tl } > { \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { number } { same } } + { \int_compare_p:nNn { \l__deriv_num_tmpa_tl } < { \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { number } { swapped } } } { \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int } @@ -1134,7 +1218,7 @@ { \__deriv_sort_method:n {#1} } } } -% dv , sort-method , same/swapped +% dv, sort-method, same/swapped \cs_new_protected:Npn \__deriv_sort_reverse:nnn #1 #2 #3 { \exp_args:Nc @@ -1142,7 +1226,7 @@ { \sort_return_same: } { \sort_return_swapped: } } -% mixed-order-tl , sorted-seq , numerical-term, dv +% mixed-order-tl, sorted-seq, numerical-term, variant \cs_new_protected:Npn \__deriv_output:NNNn #1 #2 #3 #4 { \tl_set:Nf #1 { \seq_use:Nn #2 { + } } @@ -1150,17 +1234,17 @@ \int_compare:nNnF {#3} = { 0 } { \tl_if_empty:NTF #1 - { \tl_put_left:NV #1 #3 } + { \tl_put_left:NV #1 #3 } { \exp_args:Nv \str_case:nnF { l__deriv_#4_sort_numerical_tl } { - { last } { \tl_put_right:Nx #1 { + \int_use:N #3 } } - { first } { \tl_put_left:Nx #1 { \int_use:N #3 + } } + { last } { \tl_put_right:Nx #1 { + \int_use:N #3 } } + { first } { \tl_put_left:Nx #1 { \int_use:N #3 + } } } { \bool_if:nTF { \tl_if_head_eq_charcode_p:VN #1 - } - { \tl_put_left:NV #1 #3 } - { \tl_put_right:Nx #1 { + \int_use:N #3 } } + { \tl_put_left:NV #1 #3 } + { \tl_put_right:Nx #1 { + \int_use:N #3 } } } } } @@ -1170,96 +1254,97 @@ %%%%% Declaring Variant %%%%% -\DeclareDocumentCommand{\NewOdvVariant}{ m m o } +\DeclareDocumentCommand{\NewDerivative}{ m m o } { \cs_if_exist:NTF #1 { \msg_error:nnxx { deriv } { command-already-defined } { \token_to_str:N #1 } - { \token_to_str:N \NewOdvVariant } + { \token_to_str:N \NewDerivative } } { - \deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3} - \deriv_d_define:Vnnn \l__deriv_dv_tmp_tl { New } {#1} {#2} + \deriv_preamble:NNnnn \l__deriv_cs_name_tl #1 {#2} {#3} { dv } + \deriv_dv_define:NVn \NewDocumentCommand \l__deriv_cs_name_tl {#1} } } -\DeclareDocumentCommand{\RenewOdvVariant}{ m m o } +\DeclareDocumentCommand{\RenewDerivative}{ m m o } { \cs_if_exist:NTF #1 { - \deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3} - \deriv_d_define:Vnnn \l__deriv_dv_tmp_tl { Renew } {#1} {#2} + \deriv_preamble:NNnnn \l__deriv_cs_name_tl #1 {#2} {#3} { dv } + \deriv_dv_define:NVn \RenewDocumentCommand \l__deriv_cs_name_tl {#1} } { - \msg_error:nnxx { deriv } { command-not-defined } + \msg_error:nnxx { deriv } { command-already-defined } { \token_to_str:N #1 } - { \token_to_str:N \RenewOdvVariant } + { \token_to_str:N \RenewDerivative } } } -\DeclareDocumentCommand{\ProvideOdvVariant}{ m m o } +\DeclareDocumentCommand{\ProvideDerivative}{ m m o } { \cs_if_exist:NF #1 { - \deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3} - \deriv_d_define:Vnnn \l__deriv_dv_tmp_tl { Provide } {#1} {#2} + \deriv_preamble:NNnnn \l__deriv_cs_name_tl #1 {#2} {#3} { dv } + \deriv_dv_define:NVn \ProvideDocumentCommand \l__deriv_cs_name_tl {#1} } } -\DeclareDocumentCommand{\DeclareOdvVariant}{ m m o } +\DeclareDocumentCommand{\DeclareDerivative}{ m m o } { - \deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3} - \deriv_d_define:Vnnn \l__deriv_dv_tmp_tl { Declare } {#1} {#2} + \deriv_preamble:NNnnn \l__deriv_cs_name_tl #1 {#2} {#3} { dv } + \deriv_dv_define:NVn \DeclareDocumentCommand \l__deriv_cs_name_tl {#1} } -\DeclareDocumentCommand{\NewPdvVariant}{ m m o } +\DeclareDocumentCommand{\NewDifferential}{ m m o } { \cs_if_exist:NTF #1 { \msg_error:nnxx { deriv } { command-already-defined } { \token_to_str:N #1 } - { \token_to_str:N \NewPdvVariant } + { \token_to_str:N \NewOdvVariant } } { - \deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3} - \deriv_p_define:Vnnn \l__deriv_dv_tmp_tl { New } {#1} {#2} + \deriv_preamble:NNnnn \l__deriv_dv_tmp_tl #1 {#2} {#3} { i } + \deriv_i_define:NVn \NewDocumentCommand \l__deriv_dv_tmp_tl {#1} } } -\DeclareDocumentCommand{\RenewPdvVariant}{ m m o } +\DeclareDocumentCommand{\RenewDifferential}{ m m o } { \cs_if_exist:NTF #1 { - \deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3} - \deriv_p_define:Vnnn \l__deriv_dv_tmp_tl { Renew } {#1} {#2} + \deriv_preamble:NNnnn \l__deriv_dv_tmp_tl #1 {#2} {#3} { i } + \deriv_i_define:NVn \RenewDocumentCommand \l__deriv_dv_tmp_tl {#1} } { - \msg_error:nnxx { deriv } { command-already-defined } + \msg_error:nnxx { deriv } { command-not-defined } { \token_to_str:N #1 } - { \token_to_str:N \RenewPdvVariant } + { \token_to_str:N \RenewOdvVariant } } } -\DeclareDocumentCommand{\ProvidePdvVariant}{ m m o } +\DeclareDocumentCommand{\ProvideDifferential}{ m m o } { \cs_if_exist:NF #1 { - \deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3} - \deriv_p_define:Vnnn \l__deriv_dv_tmp_tl { Provide } {#1} {#2} + \deriv_preamble:NNnnn \l__deriv_dv_tmp_tl #1 {#2} {#3} { i } + \deriv_i_define:NVn \ProvideDocumentCommand \l__deriv_dv_tmp_tl {#1} } } -\DeclareDocumentCommand{\DeclarePdvVariant}{ m m o } +\DeclareDocumentCommand{\DeclareDifferential}{ m m o } { - \deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3} - \deriv_p_define:Vnnn \l__deriv_dv_tmp_tl { Declare } {#1} {#2} + \deriv_preamble:NNnnn \l__deriv_dv_tmp_tl #1 {#2} {#3} { i } + \deriv_i_define:NVn \DeclareDocumentCommand \l__deriv_dv_tmp_tl {#1} } %%%%% slash frac %%%%% \DeclareDocumentCommand{\slashfrac}{ o m m } { + \group_begin: \tl_if_novalue:nTF {#1} { \__deriv_slashfrac_auto:nn {#2} {#3} } { @@ -1270,40 +1355,55 @@ } { \__deriv_slashfrac_scale:nnn {#1} {#2} {#3} } } + \group_end: } -% numerator , denominator +% numerator, denominator \cs_new_protected:Npn \__deriv_slashfrac_auto:nn #1 #2 { - \__deriv_auto_left:n . \kern-\nulldelimiterspace + \__deriv_auto_left:n . {#1} \middle/ {#2} - \__deriv_auto_right:n . \kern-\nulldelimiterspace + \__deriv_auto_right:n . } -% numerator , denominator +% numerator, denominator \cs_new_protected:Npn \__deriv_slashfrac_none:nn #1 #2 -{ - {#1} / {#2} -} -% scale , numerator , denominator +{ {#1} / {#2} } +% scale, numerator, denominator \cs_new_protected:Npn \__deriv_slashfrac_scale:nnn #1 #2 #3 { - \cs:w #1 l \cs_end: . + \use:c { #1 l } . {#2} - \cs:w #1 \cs_end: / + \use:c {#1} / {#3} - \cs:w #1 r \cs_end: . + \use:c { #1 r } . } %%%%% Generate variants %%%%% +\prg_generate_conditional_variant:Nnn \__deriv_show_order:N { c } { T, TF } + \cs_generate_variant:Nn \tl_if_head_eq_charcode_p:nN { V } \cs_generate_variant:Nn \__deriv_set_rubber_length:Nn { c } -\cs_generate_variant:Nn \__deriv_p_variables:n { V } -\cs_generate_variant:Nn \__deriv_d_variables:n { V } -\cs_generate_variant:Nn \deriv_p_define:nnnn { V } -\cs_generate_variant:Nn \deriv_d_define:nnnn { V } -\cs_generate_variant:Nn \__deriv_derivset:nn { V, VV } -\cs_generate_variant:Nn \__deriv_p_define_keys:n { V } -\cs_generate_variant:Nn \__deriv_d_define_keys:n { V } +\cs_generate_variant:Nn \__deriv_dv_variables:n { V } +\cs_generate_variant:Nn \__deriv_dv_define_keys:n { V } +\cs_generate_variant:Nn \deriv_dv_define:Nnn { NV } +\cs_generate_variant:Nn \__deriv_i_variables:n { V } +\cs_generate_variant:Nn \__deriv_i_define_keys:n { V } +\cs_generate_variant:Nn \deriv_i_define:Nnn { NV } +\cs_generate_variant:Nn \deriv_set_keys:nn { V } + +\cs_generate_variant:Nn \__deriv_insert_ord:Nnn { c } +\cs_generate_variant:Nn \__deriv_insert_var:Nnn { NV } + +\prg_generate_conditional_variant:Nnn \__deriv_if_novalue:n { f } { T } +\prg_generate_conditional_variant:Nnn \__deriv_if_novalue:n { V } { TF } +\cs_generate_variant:Nn \__deriv_mixed_order:NNn { c } +\cs_generate_variant:Nn \__deriv_eval_term:Nnnn { NV } + +\cs_generate_variant:Nn \__deriv_set_default_aux:nnn { V } +\cs_generate_variant:Nn \__deriv_set_default_from_prop:NN { Nc } +\cs_generate_variant:Nn \__deriv_update_prop:Nn { c } +\cs_generate_variant:Nn \__deriv_preamble_aux:nnn { V } +\cs_generate_variant:Nn \__deriv_var_bool_seq:NNN { c } %%%%% Messages %%%%% @@ -1316,38 +1416,44 @@ \msg_new:nnnn { deriv } { derivative-not-defined } { Derivative~'#1'~is~not~defined! } -{ - You~have~used~#2~with~a~derivative~that~was~never~defined. -} +{ You~have~used~#2~with~a~derivative~that~was~never~defined. } + \msg_new:nnnn { deriv } { command-not-defined } { Command~'#1'~not~yet~defined! } -{ - You~have~used~#2~with~a~derivative~that~was~never~defined. -} +{ You~have~used~#2~with~a~derivative~that~was~never~defined. } %%%%% Declaring derivatives %%%%% -\bool_lazy_or:nnT { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: } -{ - \DeclareOdvVariant{\odv}{d}[style-inf = \symup] - \DeclareOdvVariant{\mdv}{D}[style-inf = \symup] - \DeclareOdvVariant{\fdv}{\delta} - \DeclareOdvVariant{\adv}{\Delta} - \DeclareOdvVariant{\jdv}{\partial}[misc-add-delims = {fun, var}] - \DeclarePdvVariant{\pdv}{\partial}[sep-inf-ord=1, sep-ord-fun=-2] +\derivset{all} +\bool_lazy_or:nnTF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: } +{ + \DeclareDerivative{\odv}{\symup{d}} + \DeclareDerivative{\mdv}{\symup{D}} + \DeclareDerivative{\fdv}{\delta} + \DeclareDerivative{\adv}{\Delta} + \DeclareDerivative{\jdv}{\partial}[fun=true, var=1] + \DeclareDerivative{\pdv}{\partial}[style-var=multiple, sep-inf-ord=1, delims-eval=(), delims-eval-/=()] + \DeclareDifferential{\odif}{\symup{d}} + \DeclareDifferential{\mdif}{\symup{D}}[style-notation=single, style-notation-*=mixed] + \DeclareDifferential{\fdif}{\delta} + \DeclareDifferential{\adif}{\Delta} + \DeclareDifferential{\pdif}{\partial}[style-notation=single, style-notation-*=mixed] +} +{ + \DeclareDerivative{\odv}{\mathrm{d}} + \DeclareDerivative{\mdv}{\mathrm{D}} + \DeclareDerivative{\fdv}{\delta} + \DeclareDerivative{\adv}{\Delta} + \DeclareDerivative{\jdv}{\partial}[fun=true, var=1] + \DeclareDerivative{\pdv}{\partial}[style-var=multiple, sep-inf-ord=1, delims-eval=(), delims-eval-/=()] + + \DeclareDifferential{\odif}{\mathrm{d}} + \DeclareDifferential{\mdif}{\mathrm{D}}[style-notation=single, style-notation-*=mixed] + \DeclareDifferential{\fdif}{\delta} + \DeclareDifferential{\adif}{\Delta} + \DeclareDifferential{\pdif}{\partial}[style-notation=single, style-notation-*=mixed] } -\sys_if_engine_pdftex:T -{ - \DeclareOdvVariant{\odv}{d}[style-inf = \mathrm] - \DeclareOdvVariant{\mdv}{D}[style-inf = \mathrm] - \DeclareOdvVariant{\fdv}{\delta} - \DeclareOdvVariant{\adv}{\Delta}[style-inf = \mathrm] - \DeclareOdvVariant{\jdv}{\partial}[misc-add-delims = {fun, var}] - \DeclarePdvVariant{\pdv}{\partial}[sep-inf-ord=1, sep-ord-fun=-2] -} -\derivset{all} - \endinput |