View Source Chi2fit.Math (Chi-SquaredFit v2.0.2)

Link to this section Summary

Types

Supported numerical integration methods

Functions

Calculates the partial derivative of a function and returns the value.

Numerical integration providing Gauss and Romberg types.

Calculates the jacobian of the function at the point x.

Newton-Fourier method for locating roots and returning the interval where the root is located.

Link to this section Types

@type method() :: :gauss | :gauss2 | :gauss3 | :romberg | :romberg2 | :romberg3

Supported numerical integration methods

Link to this section Functions

Link to this function

der(parameters, fun, options \\ [])

View Source
@spec der([float() | {float(), integer()}], ([float()] -> float()), Keyword.t()) ::
  float()

Calculates the partial derivative of a function and returns the value.

examples

Examples

The function value at a point:
iex> der([3.0], fn [x]-> x*x end) |> Float.round(3)
9.0

The first derivative of a function at a point:
iex> der([{3.0,1}], fn [x]-> x*x end) |> Float.round(3)
6.0

The second derivative of a function at a point:
iex> der([{3.0,2}], fn [x]-> x*x end) |> Float.round(3)
2.0

Partial derivatives with respect to two variables:
iex> der([{2.0,1},{3.0,1}], fn [x,y] -> 3*x*x*y end) |> Float.round(3)
12.0
Link to this function

integrate(method, func, a, b, options \\ [])

View Source
@spec integrate(
  method(),
  (float() -> float()),
  a :: float(),
  b :: float(),
  options :: Keyword.t()
) ::
  float()

Numerical integration providing Gauss and Romberg types.

Link to this function

jacobian(x, fun, options \\ [])

View Source

Calculates the jacobian of the function at the point x.

examples

Examples

iex> jacobian([2.0,3.0], fn [x,y] -> x*y end) |> Enum.map(&Float.round(&1))
[3.0, 2.0]
Link to this function

newton(a, b, func, maxiter \\ 10, options)

View Source
@spec newton(
  a :: float(),
  b :: float(),
  func :: (x :: float() -> float()),
  maxiter :: non_neg_integer(),
  options :: Keyword.t()
) :: {float(), {float(), float()}, {float(), float()}}

Newton-Fourier method for locating roots and returning the interval where the root is located.

See [https://en.wikipedia.org/wiki/Newton%27s_method#Newton.E2.80.93Fourier_method]

Link to this function

richardson(func, init, factor, results \\ [], options)

View Source
@spec richardson(
  func :: (term() -> {float(), term()}),
  init :: term(),
  factor :: float(),
  results :: [float()],
  options :: Keyword.t()
) :: float()

Richardson extrapolation.