6#ifndef THEORETICA_EXTREMA_H
7#define THEORETICA_EXTREMA_H
9#include "../core/constants.h"
23 template<
typename RealFunction>
36 unsigned int iter = 0;
57 return (
x2 +
x1) / 2.0;
68 template<
typename RealFunction>
81 unsigned int iter = 0;
102 return (
x2 +
x1) / 2.0;
115 template<
typename RealFunction>
140 template<
typename RealFunction>
165 template<
typename RealFunction>
190 template<
typename RealFunction>
#define TH_MATH_ERROR(F_NAME, VALUE, EXCEPTION)
TH_MATH_ERROR is a macro which throws exceptions or modifies errno (depending on which compiling opti...
Definition error.h:225
Main namespace of the library which contains all functions and objects.
Definition algebra.h:27
double real
A real number, defined as a floating point type.
Definition constants.h:198
real minimize_bisection(RealFunction f, RealFunction Df, real a, real b)
Approximate a function minimum inside an interval given the function and its first derivative using b...
Definition extrema.h:191
real root_newton(RealFunction f, RealFunction Df, real guess=0.0, real tol=OPTIMIZATION_TOL, unsigned int max_iter=OPTIMIZATION_NEWTON_ITER)
Find a root of a univariate real function using Newton's method.
Definition roots.h:217
dual2 abs(dual2 x)
Compute the absolute value of a second order dual number.
Definition dual2_functions.h:198
std::remove_reference_t< decltype(std::declval< Structure >()[0])> vector_element_t
Extract the type of a vector (or any indexable container) from its operator[].
Definition core_traits.h:134
real maximize_bisection(RealFunction f, RealFunction Df, real a, real b)
Approximate a function maximum inside an interval given the function and its first derivative using b...
Definition extrema.h:166
constexpr real OPTIMIZATION_TOL
Approximation tolerance for root finding.
Definition constants.h:288
constexpr unsigned int OPTIMIZATION_GOLDENSECTION_ITER
Maximum number of iterations for the golden section search algorithm.
Definition constants.h:294
TH_CONSTEXPR real nan()
Return a quiet NaN number in floating point representation.
Definition error.h:54
real root_bisect(RealFunction f, real a, real b, real tol=OPTIMIZATION_TOL, unsigned int max_iter=OPTIMIZATION_BISECTION_ITER)
Find the root of a univariate real function using bisection inside a compact interval [a,...
Definition roots.h:58
real deriv_central(RealFunction f, real x, real h=CALCULUS_DERIV_STEP)
Approximate the first derivative of a real function using the central method.
Definition deriv.h:73
real maximize_goldensection(RealFunction f, real a, real b)
Approximate a function maximum using the Golden Section search algorithm.
Definition extrema.h:24
real minimize_goldensection(RealFunction f, real a, real b)
Approximate a function minimum using the Golden Section search algorithm.
Definition extrema.h:69
real maximize_newton(RealFunction f, RealFunction Df, RealFunction D2f, real guess=0)
Approximate a function maximum given the function and the first two derivatives using Newton-Raphson'...
Definition extrema.h:116
constexpr real PHI
The Phi (Golden Section) mathematical constant.
Definition constants.h:210
real minimize_newton(RealFunction f, RealFunction Df, RealFunction D2f, real guess=0)
Approximate a function minimum given the function and the first two derivatives using Newton-Raphson'...
Definition extrema.h:141
Root approximation of real functions.