https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BrentsMethod.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12// MOOSE includes
13#include "Moose.h"
14#include "MooseTypes.h"
15
16// C++ includes
17#include <functional>
18
26namespace BrentsMethod
27{
36void bracket(std::function<Real(Real)> const & f, Real & x1, Real & x2);
37
47Real root(std::function<Real(Real)> const & f, Real x1, Real x2, Real tol = 1.0e-12);
48}
Real f(Real x)
Test function for Brents method.
const double tol
Brent's method is used to find the root of a function f(x), i.e., find x such that f(x) = 0.
Real root(std::function< Real(Real)> const &f, Real x1, Real x2, Real tol=1.0e-12)
Finds the root of a function using Brent's method.
void bracket(std::function< Real(Real)> const &f, Real &x1, Real &x2)
Function to bracket a root of a given function.