Copyright | (c) Scott N. Walck 2012-2017 |
---|---|
License | BSD3 (see LICENSE) |
Maintainer | Scott N. Walck <walck@lvc.edu> |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell98 |
Functions for approximately solving equations like f(x) = 0. These functions proceed by assuming that f is continuous, and that a root is bracketed. A bracket around a root consists of numbers a, b such that f(a) f(b) <= 0. Since the product changes sign, there must be an x with a < x < b such that f(x) = 0.
Synopsis
- findRoots :: (Double -> Double) -> (Double, Double) -> [Double]
- findRootsN :: Int -> (Double -> Double) -> (Double, Double) -> [Double]
- findRoot :: (Double -> Double) -> (Double, Double) -> Double
- bracketRoot :: (Ord a, Fractional a) => a -> (a -> a) -> (a, a) -> (a, a)
- bracketRootStep :: (Ord a, Fractional a) => (a -> a) -> ((a, a), (a, a)) -> ((a, a), (a, a))
Documentation
Find a list of roots for a function over a given range.
There are no guarantees that all roots will be found.
Uses findRootsN
with 1000 intervals.
:: Int | initial number of intervals to use |
-> (Double -> Double) | function |
-> (Double, Double) | range over which to search |
-> [Double] | list of roots |
Find a list of roots for a function over a given range. First parameter is the initial number of intervals to use to find the roots. If roots are closely spaced, this number of intervals may need to be large.
Find a single root in a bracketed region.
The algorithm continues until it exhausts the
precision of a Double
. This could cause the function to hang.
:: (Ord a, Fractional a) | |
=> a | desired accuracy |
-> (a -> a) | function |
-> (a, a) | initial bracket |
-> (a, a) | final bracket |
Given an initial bracketing of a root (an interval (a,b) for which f(a) f(b) <= 0), produce a bracket (c,d) for which |c-d| < desired accuracy.
:: (Ord a, Fractional a) | |
=> (a -> a) | function |
-> ((a, a), (a, a)) | original bracket |
-> ((a, a), (a, a)) | new bracket |
Given a bracketed root, return a half-width bracket.