math.derivatives: Add a ; to the syntax for derivatives so the parsing word doesn't have to introspect its input arity.
parent
91bda9066d
commit
35d81c742d
|
@ -10,14 +10,14 @@ M: undefined-derivative summary
|
||||||
" is undefined at " % point>> # "." % ]
|
" is undefined at " % point>> # "." % ]
|
||||||
"" make ;
|
"" make ;
|
||||||
|
|
||||||
DERIVATIVE: + [ 2drop ] [ 2drop ]
|
DERIVATIVE: + [ 2drop ] [ 2drop ] ;
|
||||||
DERIVATIVE: - [ 2drop ] [ 2drop neg ]
|
DERIVATIVE: - [ 2drop ] [ 2drop neg ] ;
|
||||||
DERIVATIVE: * [ nip * ] [ drop * ]
|
DERIVATIVE: * [ nip * ] [ drop * ] ;
|
||||||
DERIVATIVE: / [ nip / ] [ sq / neg * ]
|
DERIVATIVE: / [ nip / ] [ sq / neg * ] ;
|
||||||
! Conditional checks if the epsilon-part of the exponent is
|
! Conditional checks if the epsilon-part of the exponent is
|
||||||
! 0 to avoid getting float answers for integer powers.
|
! 0 to avoid getting float answers for integer powers.
|
||||||
DERIVATIVE: ^ [ [ 1 - ^ ] keep * * ]
|
DERIVATIVE: ^ [ [ 1 - ^ ] keep * * ]
|
||||||
[ [ dup zero? ] 2dip [ 3drop 0 ] [ [ ^ ] keep log * * ] if ]
|
[ [ dup zero? ] 2dip [ 3drop 0 ] [ [ ^ ] keep log * * ] if ] ;
|
||||||
|
|
||||||
DERIVATIVE: abs
|
DERIVATIVE: abs
|
||||||
[ 0 <=>
|
[ 0 <=>
|
||||||
|
@ -26,28 +26,28 @@ DERIVATIVE: abs
|
||||||
{ +eq+ [ 0 \ abs undefined-derivative ] }
|
{ +eq+ [ 0 \ abs undefined-derivative ] }
|
||||||
{ +gt+ [ ] }
|
{ +gt+ [ ] }
|
||||||
} case
|
} case
|
||||||
]
|
] ;
|
||||||
|
|
||||||
DERIVATIVE: sqrt [ sqrt 2 * / ]
|
DERIVATIVE: sqrt [ sqrt 2 * / ] ;
|
||||||
|
|
||||||
DERIVATIVE: e^ [ e^ * ]
|
DERIVATIVE: e^ [ e^ * ] ;
|
||||||
DERIVATIVE: log [ / ]
|
DERIVATIVE: log [ / ] ;
|
||||||
|
|
||||||
DERIVATIVE: sin [ cos * ]
|
DERIVATIVE: sin [ cos * ] ;
|
||||||
DERIVATIVE: cos [ sin neg * ]
|
DERIVATIVE: cos [ sin neg * ] ;
|
||||||
DERIVATIVE: tan [ sec sq * ]
|
DERIVATIVE: tan [ sec sq * ] ;
|
||||||
|
|
||||||
DERIVATIVE: sinh [ cosh * ]
|
DERIVATIVE: sinh [ cosh * ] ;
|
||||||
DERIVATIVE: cosh [ sinh * ]
|
DERIVATIVE: cosh [ sinh * ] ;
|
||||||
DERIVATIVE: tanh [ sech sq * ]
|
DERIVATIVE: tanh [ sech sq * ] ;
|
||||||
|
|
||||||
DERIVATIVE: asin [ sq neg 1 + sqrt / ]
|
DERIVATIVE: asin [ sq neg 1 + sqrt / ] ;
|
||||||
DERIVATIVE: acos [ sq neg 1 + sqrt neg / ]
|
DERIVATIVE: acos [ sq neg 1 + sqrt neg / ] ;
|
||||||
DERIVATIVE: atan [ sq 1 + / ]
|
DERIVATIVE: atan [ sq 1 + / ] ;
|
||||||
|
|
||||||
DERIVATIVE: asinh [ sq 1 + sqrt / ]
|
DERIVATIVE: asinh [ sq 1 + sqrt / ] ;
|
||||||
DERIVATIVE: acosh [ [ 1 + sqrt ] [ 1 - sqrt ] bi * / ]
|
DERIVATIVE: acosh [ [ 1 + sqrt ] [ 1 - sqrt ] bi * / ] ;
|
||||||
DERIVATIVE: atanh [ sq neg 1 + / ]
|
DERIVATIVE: atanh [ sq neg 1 + / ] ;
|
||||||
|
|
||||||
DERIVATIVE: neg [ drop neg ]
|
DERIVATIVE: neg [ drop neg ] ;
|
||||||
DERIVATIVE: recip [ sq recip neg * ]
|
DERIVATIVE: recip [ sq recip neg * ] ;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
! Copyright (C) 2009 Jason W. Merrill.
|
! Copyright (C) 2009 Jason W. Merrill.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel parser words effects accessors sequences
|
USING: accessors effects kernel lexer math.ranges parser
|
||||||
math.ranges ;
|
sequences words ;
|
||||||
|
|
||||||
IN: math.derivatives.syntax
|
IN: math.derivatives.syntax
|
||||||
|
|
||||||
SYNTAX: DERIVATIVE: scan-object dup stack-effect in>> length [1,b]
|
SYNTAX: DERIVATIVE: scan-object dup stack-effect in>> length [1,b]
|
||||||
[ drop scan-object ] map
|
[ drop scan-object ] map ";" expect
|
||||||
"derivative" set-word-prop ;
|
"derivative" set-word-prop ;
|
||||||
|
|
Loading…
Reference in New Issue