Skip to content

Namespace Approximate

Namespace List > Approximate

Provides functions for numerical approximations. More...

Classes

Type Name
struct ApproximateResult <typename T>
Represents the result of an approximation calculation.

Public Functions

Type Name
ApproximateResult< std::vector< T > > n_roots (const std::function< T(const T &)> func, const uint8_t n_roots, const T error=T(0.001), const uint8_t rounds=16)
Finds N roots of a function using a combination of the secant and bisection methods.
constexpr ApproximateResult< T > small_root (const std::function< T(const T &)> func, const T error=T(0.001), const uint8_t rounds=16)
Finds a small root of a function using a combination of the secant and bisection methods.

Detailed Description

This namespace contains a collection of mathematical functions that use approximation algorithms to compute their results, suitable for fixed-point arithmetic.

Public Functions Documentation

function n_roots

Finds N roots of a function using a combination of the secant and bisection methods.

template<typename T>
ApproximateResult < std::vector< T > > Approximate::n_roots (
    const std::function< T ( const  T &)> func,
    const  uint8_t n_roots,
    const  T error=T (0.001),
    const  uint8_t rounds=16
) 

This function attempts to find N roots of the given function func within a specified number of iterations for each root. It repeatedly searches for roots, beginning each new search just after the previously found root.

Template parameters:

  • T The numeric type for the calculation.

Parameters:

  • func The function for which to find roots.
  • n_roots The number of roots to find.
  • error The desired proportional error for convergence for each root.

Finds N smallest positive roots of a function using a combination of the secant and bisection methods.

This function attempts to find N roots of the given function func within a specified number of iterations for each root. It repeatedly searches for roots, beginning each new search just after the previously found root. This implementation finds the N smallest positive roots.

Template parameters:

  • T The numeric type for the calculation.

Parameters:

  • func The function for which to find roots.
  • n_roots The number of roots to find.
  • error The desired proportional error for convergence for each root.
  • rounds The maximum number of iterations to perform for each root.

Returns:

An ApproximateResult containing a std::vector of the found roots.


function small_root

Finds a small root of a function using a combination of the secant and bisection methods.

template<typename T>
constexpr  ApproximateResult < T > Approximate::small_root (
    const std::function< T ( const  T &)> func,
    const  T error=T (0.001),
    const  uint8_t rounds=16
) 

This function attempts to find a root of the given function func within a specified number of iterations. It starts by searching for an interval where a root is likely to exist and then refines the search using a numerical method.

Template parameters:

  • T The numeric type for the calculation.

Parameters:

  • func The function for which to find a root.
  • error The desired proportional error for convergence.
  • rounds The maximum number of iterations to perform.

Returns:

An ApproximateResult containing the outcome of the root-finding process.



The documentation for this class was generated from the following file aproximate_math.hpp