fluxion v0.2.0 Fluxion.NewtonSolver View Source
A nonlinear equation solver which uses Newton’s Method to find the zeros of an arbitrary function.
Link to this section Summary
Functions
Find a zero of the provided function starting from an initial guess
Link to this section Functions
Link to this function
find_zero(function, guess, max_iterations \\ 100)
View Source
find_zero(Fluxion.Function.t(), number(), number()) :: number()
Find a zero of the provided function starting from an initial guess.
Example
iex> defmodule XSq do
...> @behaviour Fluxion.Function
...> def f(x), do: x*x - 4
...> def dfdx(x), do: 2*x
...> end
iex> computed_zero = Fluxion.NewtonSolver.find_zero(XSq, 10)
iex> Fluxion.Math.is_equal(computed_zero, 2)
:true
iex> computed_zero = Fluxion.NewtonSolver.find_zero(XSq, -0.1)
iex> IO.puts computed_zero
iex> Fluxion.Math.is_equal(computed_zero, -2)
:true