1 USING: help.markup help.syntax math math.functions ;
4 HELP: derivative ( x function -- m )
5 { $values { "x" "a position on the function" } { "function" "a differentiable function" } { "m" number } }
7 "Approximates the slope of the tangent line by using Ridders' "
8 "method of computing derivatives, from the chapter \"Accurate computation "
9 "of F'(x) and F'(x)F''(x)\", from \"Advances in Engineering Software, Vol. 4, pp. 75-76 ."
13 "USING: math math.derivatives prettyprint ;"
14 "4 [ sq ] derivative >integer ."
18 "For applied scientists, you may play with the settings "
19 "in the source file to achieve arbitrary accuracy. "
25 { "x" "a position on the function" }
26 { "func" "a differentiable function" }
28 "h" "distance between the points of the first secant line used for "
29 "approximation of the tangent. This distance will be divided "
30 "constantly, by " { $link con } ". See " { $link init-hh }
31 " for the code which enforces this. H should be .001 to .5 -- too "
32 "small can cause bad convergence. Also, h should be small enough "
33 "to give the correct sgn(f'(x)). In other words, if you're expecting "
34 "a positive derivative, make h small enough to give the same "
35 "when plugged into the academic limit definition of a derivative. "
36 "See " { $link update-hh } " for the code which performs this task."
39 "err" "maximum tolerance of increase in error. For example, if this "
40 "is set to 2.0, the program will terminate with its nearest answer "
41 "when the error multiplies by 2. See " { $link check-safe } " for "
48 "Approximates the slope of the tangent line by using Ridders' "
49 "method of computing derivatives, from the chapter \"Accurate computation "
50 "of F'(x) and F'(x)F''(x)\", from \"Advances in Engineering Software, "
55 "USING: math math.derivatives prettyprint ;"
56 "4 [ sq ] derivative >integer ."
60 "For applied scientists, you may play with the settings "
61 "in the source file to achieve arbitrary accuracy. "
66 { $values { "func" "a differentiable function" } { "der" "the derivative" } }
68 "Provides the derivative of the function. The implementation simply "
69 "attaches the " { $link derivative } " word to the end of the function."
73 "USING: kernel math.derivatives math.functions math.trig prettyprint ;"
74 "60 deg>rad [ sin ] derivative-func call 0.5 .001 ~ ."
78 "Without a heavy algebraic system, derivatives must be "
79 "approximated. With the current settings, there is a fair trade of "
80 "speed and accuracy; the first 12 digits "
81 "will always be correct with " { $link sin } " and " { $link cos }
82 ". The following code performs a minumum and maximum error test."
84 "USING: kernel math math.functions math.trig sequences sequences.lib ;"
88 " [ [ sin ] derivative-func call ]"
89 " ! Note: the derivative of sin is cos"
97 ARTICLE: "derivatives" "The Derivative Toolkit"
98 "A toolkit for computing the derivative of functions."
99 { $subsection derivative }
100 { $subsection derivative-func }
101 { $subsection (derivative) } ;