]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/math/dual/dual-docs.factor
factor: trim using lists
[factor.git] / extra / math / dual / dual-docs.factor
index de3b0749a511381f8278cd14a0c9a9eb06a9b7c2..261e99e9dd6f9b803ffa5480cfca006886dcdce9 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2009 Jason W. Merrill.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel words math math.functions math.derivatives.syntax ;
+USING: help.markup help.syntax kernel math
+math.derivatives.syntax words ;
 IN: math.dual
 
 HELP: <dual>
@@ -10,50 +11,14 @@ HELP: <dual>
 }
 { $description "Creates a dual number from its ordinary and epsilon parts." } ;
 
-HELP: d*
-{ $values
-    { "x" dual } { "y" dual }
-    { "x*y" dual }
-}
-{ $description "Multiply dual numbers." } ;
-
-HELP: d+
-{ $values
-    { "x" dual } { "y" dual }
-    { "x+y" dual }
-}
-{ $description "Add dual numbers." } ;
-
-HELP: d-
-{ $values
-    { "x" dual } { "y" dual }
-    { "x-y" dual }
-}
-{ $description "Subtract dual numbers." } ;
-
-HELP: d/
-{ $values
-    { "x" dual } { "y" dual }
-    { "x/y" dual }
-}
-{ $description "Divide dual numbers." } 
-{ $errors "Throws an error if the ordinary part of " { $snippet "x" } " is zero." } ;
-
-HELP: d^
-{ $values
-    { "x" dual } { "y" dual }
-    { "x^y" dual }
-}
-{ $description "Raise a dual number to a (possibly dual) power" } ;
-
-HELP: define-dual-method
+HELP: define-dual
 { $values
     { "word" word }
 }
-{ $description "Defines a method on the dual numbers for generic word." }
-{ $notes "Uses the derivative word-prop, which holds a list of quotations giving the partial derivatives of the word with respect to each of its arguments.  This can be set using " { $link POSTPONE: DERIVATIVE: } "." } ;
+{ $description "Defines a word " { $snippet "d[word]" } " in the " { $vocab-link "math.dual" } " vocabulary that operates on dual numbers." }
+{ $notes "Uses the derivative word-prop, which holds a list of quotations giving the partial derivatives of the word with respect to each of its arguments. This can be set using " { $link POSTPONE: DERIVATIVE: } "." } ;
 
-{ define-dual-method dual-op POSTPONE: DERIVATIVE: } related-words
+{ define-dual dual-op POSTPONE: DERIVATIVE: } related-words
 
 HELP: dual
 { $class-description "The class of dual numbers with non-zero epsilon part." } ;
@@ -63,12 +28,12 @@ HELP: dual-op
     { "word" word }
 }
 { $description "Similar to " { $link execute } ", but promotes word to operate on duals." }
-{ $notes "Uses the derivative word-prop, which holds a list of quotations giving the partial derivatives of the word with respect to each of its arguments. This can be set using " { $link POSTPONE: DERIVATIVE: } ". Once a derivative has been defined for a word, dual-op makes it easy to extend the definition to dual numbers." } 
-{ $examples 
-    { $unchecked-example "USING: math math.dual math.derivatives.syntax math.functions ;" 
-    "DERIVATIVE: sin [ cos * ]" 
+{ $notes "Uses the derivative word-prop, which holds a list of quotations giving the partial derivatives of the word with respect to each of its arguments. This can be set using " { $link POSTPONE: DERIVATIVE: } ". Once a derivative has been defined for a word, dual-op makes it easy to extend the definition to dual numbers." }
+{ $examples
+    { $unchecked-example "USING: math math.dual math.derivatives.syntax math.functions ;"
+    "DERIVATIVE: sin [ cos * ]"
     "M: dual sin \\sin dual-op ;" "" }
-    { $unchecked-example "USING: math math.dual math.derivatives.syntax ;" 
+    { $unchecked-example "USING: math math.dual math.derivatives.syntax ;"
     "DERIVATIVE: * [ drop ] [ nip ]"
     ": d* ( x y -- x*y ) \ * dual-op ;" "" }
 } ;
@@ -83,8 +48,7 @@ HELP: unpack-dual
 ARTICLE: "math.dual" "Dual Numbers"
 "The " { $vocab-link "math.dual" } " vocabulary implements dual numbers, along with arithmetic methods for working with them. Many of the functions in " { $vocab-link "math.functions" } " are extended to work with dual numbers."
 $nl
-"Dual numbers are ordered pairs " { $snippet "<o,e>"} "--an ordinary part and an epsilon part--with component-wise addition and multiplication defined by "{ $snippet "<o1,e1>*<o2,e2> = <o1*o2,e1*o2 + e2*o1>" } ". They are analagous to complex numbers with " { $snippet "i^2 = 0" } "instead of " { $snippet "i^2 = -1" } ". For well-behaved functions " { $snippet "f" } ", " { $snippet "f(<o1,e1>) = f(o1) + e1*f'(o1)" } ", where " { $snippet "f'"} " is the derivative of " { $snippet "f" } "."
+"Dual numbers are ordered pairs " { $snippet "<o,e>" } "--an ordinary part and an epsilon part--with component-wise addition and multiplication defined by " { $snippet "<o1,e1>*<o2,e2> = <o1*o2,e1*o2 + e2*o1>" } ". They are analagous to complex numbers with " { $snippet "i^2 = 0" } "instead of " { $snippet "i^2 = -1" } ". For well-behaved functions " { $snippet "f" } ", " { $snippet "f(<o1,e1>) = f(o1) + e1*f'(o1)" } ", where " { $snippet "f'" } " is the derivative of " { $snippet "f" } "."
 ;
 
-
 ABOUT: "math.dual"