HMath.API.Convergence¶
Module index · Numerical conventions
Description
Uniform iteration reports retain the best current estimate on an exhausted budget. Input/domain failures use Either; successful execution need not mean numerical convergence. Residuals are finite nonnegative absolute measures.
On this page¶
| API | Purpose |
|---|---|
| StopReason | Stagnation is opt-in and uses an exact-equality caller predicate; it does not reinterpret a small update as proof of a small residual. |
| ResidualSatisfied | Declaration and type contract below. |
| IterationLimit | Declaration and type contract below. |
| Stagnation | Declaration and type contract below. |
| Convergence | Iteration report retaining the estimate and residual even on a budget/stagnation stop. |
| Convergence | Declaration and type contract below. |
| estimate | Best current estimate, retained even when the iteration budget is exhausted. |
| iterationCount | Number of completed updates; the initial estimate is iteration zero. |
| finalResidual | Finite nonnegative absolute residual at the returned estimate. |
| stopReason | ResidualSatisfied,IterationLimit,or Stagnation; successful execution does not itself imply convergence. |
| IterationOptions | Caller-controlled iteration count and absolute/relative stopping tolerances, validated by iterateUntil. |
| IterationOptions | Declaration and type contract below. |
| maximumIterations | Nonnegative maximum number of updates permitted by iterateUntil. |
| absoluteTolerance | Finite nonnegative absolute stopping threshold. |
| relativeTolerance | Finite nonnegative tolerance scaled by the initial residual. |
| defaultIterationOptions | Default iteration budget 1000, absolute tolerance 1e-12, relative tolerance 1e-10. |
| iterateUntil | Stop at residual <= atol + rtol * initialResidual. |
| requireConvergence | Given operation name then convergence report, return its estimate only for ResidualSatisfied. |
| resultMaybe | Explicitly discard error details for callers retaining a Maybe interface. |
| fromMaybeError | Given error value then Maybe result, convert Nothing to Left error and Just x to Right x. |
| Converged | Read-only successful view. |
Documentation
StopReason
data StopReason Source #
Stagnation is opt-in and uses an exact-equality caller predicate; it does not reinterpret a small update as proof of a small residual.
Constructors
| ResidualSatisfied | |
| IterationLimit | |
| Stagnation |
Instances
| Show StopReason Source # | |
Defined in HMath.API.Convergence Methods showsPrec :: Int -> StopReason -> ShowS # show :: StopReason -> String # showList :: [StopReason] -> ShowS # | |
| Eq StopReason Source # | |
Defined in HMath.API.Convergence | |
Convergence
data Convergence a Source #
Iteration report retaining the estimate and residual even on a budget/stagnation stop. Inspect stopReason before assuming convergence.
Constructors
| Convergence | |
Fields
| |
Instances
IterationOptions
data IterationOptions Source #
Caller-controlled iteration count and absolute/relative stopping tolerances, validated by iterateUntil.
Constructors
| IterationOptions | |
Fields
| |
Instances
| Show IterationOptions Source # | |
Defined in HMath.API.Convergence Methods showsPrec :: Int -> IterationOptions -> ShowS # show :: IterationOptions -> String # showList :: [IterationOptions] -> ShowS # | |
| Eq IterationOptions Source # | |
Defined in HMath.API.Convergence Methods (==) :: IterationOptions -> IterationOptions -> Bool # (/=) :: IterationOptions -> IterationOptions -> Bool # | |
defaultIterationOptions
defaultIterationOptions :: IterationOptions Source #
Default iteration budget 1000, absolute tolerance 1e-12, relative tolerance 1e-10. Use record updates to configure a solver; iterateUntil validates nonnegative finite tolerances.
iterateUntil
iterateUntil :: IterationOptions -> (a -> Either MathError a) -> (a -> Either MathError Double) -> (a -> a -> Bool) -> a -> Either MathError (Convergence a) Source #
Stop at residual <= atol + rtol * initialResidual. Comparisons are scaled to avoid overflow in that sum. The initial value is tested at iteration zero.
requireConvergence
requireConvergence :: String -> Convergence a -> Either MathError a Source #
Given operation name then convergence report, return its estimate only for ResidualSatisfied. IterationLimit or Stagnation becomes Left (NonConvergence name iterationCount), preserving the distinction between execution and convergence.
resultMaybe
resultMaybe :: Either e a -> Maybe a Source #
Explicitly discard error details for callers retaining a Maybe interface.
fromMaybeError
fromMaybeError :: e -> Maybe a -> Either e a Source #
Given error value then Maybe result, convert Nothing to Left error and Just x to Right x. Example: fromMaybeError "missing" (Just 3) == Right 3.
Converged
pattern Converged :: a -> Convergence a Source #
Read-only successful view. The report still retains its residual and count.