Module: ChebyRuby::Differentiation
- Included in:
- FiniteDifferencing
- Defined in:
- lib/chebyruby/differentiation.rb
Overview
Module/Mixin for numeric differentiation methods. As of right now it is only mixed-in to @see [FiniteDifferencing] but will likely be mixed into more in the future.
Instance Method Summary collapse
-
#slope(func, a, b) ⇒ Float
A crude method to calculate the “slope” of a function over the span of two points.
Instance Method Details
#slope(func, a, b) ⇒ Float
A crude method to calculate the “slope” of a function over the span of two points. The formula used is: <pre>(f(b) - f(a))/(b - a)</pre>
15 16 17 |
# File 'lib/chebyruby/differentiation.rb', line 15 def slope(func, a, b) (func.value(b) - func.value(a))/(b-a).to_f end |