View Source Chi2fit.Math (Chi-SquaredFit v2.0.2)
Link to this section Summary
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.
Richardson extrapolation.
Link to this section Types
@type method() :: :gauss | :gauss2 | :gauss3 | :romberg | :romberg2 | :romberg3
Supported numerical integration methods
Link to this section Functions
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
@spec integrate( method(), (float() -> float()), a :: float(), b :: float(), options :: Keyword.t() ) :: float()
Numerical integration providing Gauss and Romberg types.
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]
@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]
@spec richardson( func :: (term() -> {float(), term()}), init :: term(), factor :: float(), results :: [float()], options :: Keyword.t() ) :: float()
Richardson extrapolation.