learn-physics-0.6.5: Haskell code for learning physics

Copyright(c) Scott N. Walck 2012-2017
LicenseBSD3 (see LICENSE)
MaintainerScott N. Walck <walck@lvc.edu>
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell98

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

findRoots Source #

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.

findRootsN Source #

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.

findRoot Source #

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.

bracketRoot Source #

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 (c,d) for which |c-d| < desired accuracy.

bracketRootStep Source #

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.