learn-physics-0.4.2: Haskell code for learning physics

Stabilityexperimental
MaintainerScott N. Walck <walck@lvc.edu>
Safe HaskellSafe

Physics.Learn.RootFinding

Description

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

Documentation

findRootsSource

Arguments

:: (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. There are no guarantees that all roots will be found. Uses findRootsN with 1000 intervals.

findRootsNSource

Arguments

:: 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.

findRootSource

Arguments

:: (Double -> Double)

function

-> (Double, Double)

initial bracket

-> Double

approximate root

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.

bracketRootSource

Arguments

:: (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 of arbitrary smallness.

bracketRootStepSource

Arguments

:: (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.