diff options
Diffstat (limited to 'doc/user/mat_defs')
-rw-r--r-- | doc/user/mat_defs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/doc/user/mat_defs b/doc/user/mat_defs new file mode 100644 index 0000000..15d4e05 --- /dev/null +++ b/doc/user/mat_defs @@ -0,0 +1,55 @@ +@Section + @Title { Defining new mathematical symbols } +@Begin +@PP +Whenever you type a particular piece of mathematics repeatedly, you +can save time by using definitions. Definitions are the subject of +Section {@NumberOf definitions}, so here we will just give a few examples +mathematics.definitions @SubIndex { definitions, use with } +definitions. @RawIndex { definitions } +definitions.use.with.mathematics @SubIndex { use with mathematics } +of their use in formatting mathematics. +@PP +Suppose for example that @OneCol @Math { p sub i ` log sub 2 ` p sub i } +occurs frequently in your document. Then +@ID @Code "def epi { p sub i ` log sub 2 ` p sub i }" +makes the symbol @Code "epi" stand for the object between the braces: +@ID { +@Code @Verbatim { sum from { i=1 } to { n } ` epi } +|7ct +@Math { sum from { i=1 } to { n } ` epi } +} +Parameters are very useful when parts of the symbol vary: +@ID @OneRow @Code @Verbatim { +def ep right x +{ + p sub x ` log sub 2 ` p sub x +} +} +The parameter @Code x will be replaced by the object just to the right +of {@Code "ep"}: +@ID { +@Code { +"sum from { i=1 } to { k } ` ep i +" +"sum from { j=k+1 } to { n } ep j" +} +||7ct +@Math { +sum from { i=1 } to { k } ` ep i + +sum from { j=k+1 } to { n } ep j +} +} +The precedence of the symbols you define will be 100 by default. +To make the symbols of @Code "@Math" available within such definitions, +each must be preceded by {@Code "import @Math"}. As explained in Section +{@NumberOf definitions}, the definitions go into a file called +{@Code "mydefs"}, which might look like this: +@ID @OneRow @Code @Verbatim { +import @Math +def epi { p sub i ` log sub 2 ` p sub i } + +import @Math +def ep right x { p sub x ` log sub 2 ` p sub x } +} +Use of @Code "epi" and @Code "ep" outside @Code "@Math" will cause an error. +@End @Section |