sigma  1.0.0
Loading...
Searching...
No Matches
sigma::TaylorModel< ValueType > Class Template Reference

Pairs a Taylor polynomial with a remainder interval to guarantee Eq. \(\eqref{eq:tm-inclusion}\). More...

#include <taylor_model.hpp>

Public Types

using size_type = std::size_t
 Type used for indexing, offsets, and truncation order.
using value_t = ValueType
 Type used for storing floating point values.
using taylor_t = Taylor<ValueType>
 Type of the underlying Taylor polynomial.
using deviation_t = typename taylor_t::deviation_t
 Opaque type used to identify an expansion variable.
using monomial_t = typename taylor_t::monomial_t
 Sparse exponent multi-index type.
using coeffs_t = typename taylor_t::coeffs_t
 Type used to map monomials to their coefficients.
using interval_t = typename taylor_t::interval_t
 Type of an interval.
using Order = typename taylor_t::Order

Public Member Functions

 TaylorModel ()=default
 Constructs an empty TaylorModel.
 TaylorModel (value_t center, Order order=default_max_order())
 Constructs a TaylorModel from a constant value.
 TaylorModel (value_t lo, value_t hi, Order order=default_max_order())
 Constructs a TaylorModel from a lower and upper bound.
 TaylorModel (const interval_t &interval, Order order=default_max_order())
 Constructs a TaylorModel from an interval.
 TaylorModel (taylor_t polynomial, interval_t remainder)
 Constructs a TaylorModel by re-wrapping a polynomial and a remainder.
 TaylorModel (const TaylorModel &other)=default
 Makes a deep copy of other.
 TaylorModel (TaylorModel &&other) noexcept=default
 Constructs a TaylorModel by moving other.
TaylorModel & operator= (const TaylorModel &other)=default
 Assigns the value of other to this model.
TaylorModel & operator= (TaylorModel &&other) noexcept=default
 Moves the value of other to this model.
const taylor_t & polynomial () const noexcept
 Returns the underlying polynomial.
const interval_t & remainder () const noexcept
 Returns the remainder interval.
size_type max_order () const noexcept
 Forwards to polynomial().max_order().
value_t constant () const
 Forwards to polynomial().constant().
const coeffs_t & coefficients () const noexcept
 Forwards to polynomial().coefficients().
size_type n_terms () const noexcept
 Forwards to polynomial().n_terms().
bool empty () const noexcept
 Checks if this TaylorModel represents the empty set.
interval_t range () const
 Returns an interval enclosing the values *this models.
bool contains (value_t value) const
 Checks if *this contains value.
bool contains (const interval_t &interval) const
 Checks if *this contains interval.
bool contains (const TaylorModel &other) const
 Checks if *this contains other.
std::string print_polynomial_form () const
 Creates a string of the polynomial form of *this.
std::string print_interval_form () const
 Creates a string of the interval form of *this.
TaylorModel operator- () const
 Returns the additive inverse of *this.
TaylorModel & operator+= (value_t value)
 Overwrites *this with the sum of *this and value.
TaylorModel & operator+= (const TaylorModel &other)
 Overwrites *this with the sum of *this and other.
TaylorModel operator+ (value_t value) const
 Returns the sum of *this and value.
TaylorModel operator+ (const TaylorModel &other) const
 Returns the sum of *this and other.
TaylorModel & operator-= (value_t value)
 Overwrites *this with the difference of *this and value.
TaylorModel & operator-= (const TaylorModel &other)
 Overwrites *this with the difference of *this and other.
TaylorModel operator- (value_t value) const
 Returns the difference of *this and value.
TaylorModel operator- (const TaylorModel &other) const
 Returns the difference of *this and other.
TaylorModel & operator*= (value_t value)
 Overwrites *this with the product of *this and value.
TaylorModel & operator*= (const TaylorModel &other)
 Overwrites *this with the product of *this and other.
TaylorModel operator* (value_t value) const
 Returns the product of *this and value.
TaylorModel operator* (const TaylorModel &other) const
 Returns the product of *this and other.
TaylorModel & operator/= (value_t value)
 Overwrites *this with the quotient of *this and value.
TaylorModel & operator/= (const TaylorModel &other)
 Overwrites *this with the quotient of *this and other.
TaylorModel operator/ (value_t value) const
 Returns the quotient of *this and value.
TaylorModel operator/ (const TaylorModel &other) const
 Returns the quotient of *this and other.
TaylorModel multiplicative_inverse () const
 Returns the multiplicative inverse of *this.
TaylorModel compose_ (const std::vector< value_t > &outer_coeffs, const std::function< interval_t(const interval_t &)> &nth_derivative) const
 Evaluates a Taylor-model outer series about constant(), with a Lagrange remainder bound.
TaylorModel sweep_to_order (size_type new_order) const
 Reduces *this to a lower truncation order, bounding the removed terms into the remainder.
TaylorModel sweep_small (value_t threshold) const
 Removes individually small coefficients, bounding them into the remainder.
bool operator== (const TaylorModel &other) const
 Checks if *this and other represent the same model.
bool operator!= (const TaylorModel &other) const
 Checks if *this and other represent different models.

Static Public Member Functions

static constexpr Order default_max_order ()
 The truncation order used when none is specified.
static deviation_t make_deviation ()
 Forwards to Taylor::make_deviation().

(Note that these are not member symbols.)

template<typename ValueType>
std::ostream & operator<< (std::ostream &os, const TaylorModel< ValueType > &t)
 Outputs the range of a TaylorModel to an output stream.
template<typename ValueType>
TaylorModel< ValueType > operator* (ValueType value, const TaylorModel< ValueType > &t)
 Multiplies a scalar by a TaylorModel.
template<typename T>
TaylorModel< T > abs (const TaylorModel< T > &a)
 Absolute value of a TaylorModel.
template<typename T>
TaylorModel< T > fabs (const TaylorModel< T > &a)
 Absolute value of a TaylorModel.
template<typename T>
TaylorModel< T > sqrt (const TaylorModel< T > &a)
 Square root of a TaylorModel.
template<typename T>
TaylorModel< T > exp (const TaylorModel< T > &a)
 Exponential of a TaylorModel.
template<typename T>
TaylorModel< T > log (const TaylorModel< T > &a)
 Natural logarithm of a TaylorModel.
template<typename T, typename U>
TaylorModel< T > pow (const TaylorModel< T > &a, const U &exp)
 Power of a TaylorModel.

Detailed Description

template<typename ValueType>
class sigma::TaylorModel< ValueType >

Pairs a Taylor polynomial with a remainder interval to guarantee Eq. \(\eqref{eq:tm-inclusion}\).

Template Parameters
ValueTypeThe numeric type of the constant term, coefficients, and remainder bounds.

Where Taylor alone makes no claim to enclose anything, TaylorModel does: for every \(\delta \in [-1,1]^v\), range() – \(B(P) + I\) – encloses the modeled function. Every operation below exists to preserve that property (docs/taylor.md's "Every operation defined below exists to preserve Eq. \_form#91"): where Taylor's own arithmetic would silently discard a term it cannot represent, TaylorModel instead bounds that term with Taylor::bound() and folds it into the remainder.

Structurally this follows ThresholdedAffine: composition rather than inheritance, forwarding accessors, a polynomial() accessor exposing the underlying Taylor, and mutating operators that delegate and then repair the remainder. Unlike ThresholdedAffine, nothing here is auto-applied after every operation – sweep_to_order() and sweep_small() are explicit, user-invoked tools for controlling term count, matching the discipline Eq. \(\eqref{eq:tm-inclusion}\) demands: dropping a term without bounding it would invalidate the model, not merely loosen it.

Elementary functions (sqrt, exp, log, pow) and division are implemented as free functions and a multiplicative_inverse member, respectively, using the private compose_ hook: it evaluates the polynomial part exactly as Taylor::compose_ does, then bounds the discarded tail of the outer series with the Lagrange remainder of Eq. \(\eqref{eq:tm-outer-rem}\) and folds it into the returned model's remainder, so Eq. \(\eqref{eq:tm-inclusion}\) survives the operation (see docs/taylor.md's "Elementary functions" section). Antiderivation is still deferred; see docs/taylor.md's note on Eq. \(\eqref{eq:tm-antideriv}\) – nothing on this page depends on it.

Member Typedef Documentation

◆ Order

template<typename ValueType>
using sigma::TaylorModel< ValueType >::Order = typename taylor_t::Order

Tag type used to pass the truncation order to constructors; see Taylor::Order.

Constructor & Destructor Documentation

◆ TaylorModel() [1/5]

template<typename ValueType>
sigma::TaylorModel< ValueType >::TaylorModel ( )
default

Constructs an empty TaylorModel.

An empty TaylorModel represents the empty set, exactly as an empty Taylor does.

Exceptions
noneNo throw guarantee

◆ TaylorModel() [2/5]

template<typename ValueType>
sigma::TaylorModel< ValueType >::TaylorModel ( value_t center,
Order order = default_max_order() )
inline

Constructs a TaylorModel from a constant value.

The resulting model has no non-constant coefficients, an empty remainder, and represents the single value given by center.

Parameters
[in]centerThe constant term of the polynomial.
[in]orderThe truncation order, defaults to default_max_order().
Exceptions
noneNo throw guarantee

◆ TaylorModel() [3/5]

template<typename ValueType>
sigma::TaylorModel< ValueType >::TaylorModel ( value_t lo,
value_t hi,
Order order = default_max_order() )
inline

Constructs a TaylorModel from a lower and upper bound.

Parameters
[in]loThe lower bound.
[in]hiThe upper bound.
[in]orderThe truncation order, defaults to default_max_order().
Exceptions
std::bad_allocIf memory allocation for the coefficient fails. Strong throw guarantee.

◆ TaylorModel() [4/5]

template<typename ValueType>
sigma::TaylorModel< ValueType >::TaylorModel ( const interval_t & interval,
Order order = default_max_order() )
inlineexplicit

Constructs a TaylorModel from an interval.

For a non-empty interval, the underlying polynomial is Taylor(interval, order). If order is at least 1, that polynomial represents interval exactly (a single linear term on a freshly minted expansion variable), so the remainder is empty – matching the Affine: order 1, empty remainder row of docs/taylor.md's equivalence table. If order is 0, Taylor has nowhere to put the linear term, so it is dropped from the polynomial and its full contribution becomes the remainder instead, preserving Eq. \(\eqref{eq:tm-inclusion}\). If interval is empty, the resulting model is also empty.

Parameters
[in]intervalThe interval represented by the model.
[in]orderThe truncation order, defaults to default_max_order().
Exceptions
std::bad_allocIf memory allocation for the coefficient fails. Strong throw guarantee.

◆ TaylorModel() [5/5]

template<typename ValueType>
sigma::TaylorModel< ValueType >::TaylorModel ( taylor_t polynomial,
interval_t remainder )
inline

Constructs a TaylorModel by re-wrapping a polynomial and a remainder.

Used internally by operations that produce a Taylor and a remainder interval separately and need to combine them into a TaylorModel. This ctor does not itself verify Eq. \(\eqref{eq:tm-inclusion}\) – callers are responsible for choosing a remainder that makes the invariant hold.

Parameters
[in]polynomialThe polynomial part of the model.
[in]remainderThe remainder interval.
Exceptions
noneNo throw guarantee

Member Function Documentation

◆ compose_()

template<typename ValueType>
auto sigma::TaylorModel< ValueType >::compose_ ( const std::vector< value_t > & outer_coeffs,
const std::function< interval_t(const interval_t &)> & nth_derivative ) const

Evaluates a Taylor-model outer series about constant(), with a Lagrange remainder bound.

This is the TaylorModel analogue of Taylor::compose_ – the hook every elementary function is built from. It computes the polynomial part exactly as polynomial().compose_(outer_coeffs) does (see Taylor::compose_), then bounds the discarded tail of the outer series with the Lagrange remainder of Eq. \(\eqref{eq:tm-outer-rem}\)

\[R_{n} \in \frac{1}{\left(n+1\right)!} \left(B\left(\bar{P}\right) + I\right)^{n+1} \frac{d^{n+1}g}{df^{n+1}}\Big( c_f + \left[0, 1\right] \cdot \left(B\left(\bar{P}\right) + I\right) \Big) \]

Parameters
[in]outer_coeffsThe Taylor coefficients of the outer function \(g\) about constant(), starting from k=0; forwarded verbatim to polynomial().compose_.
[in]nth_derivativeA callable computing \(\frac{d^{n+1}g} {df^{n+1}}\), evaluated in interval arithmetic over the argument range in Eq. \(\eqref{eq:tm-outer-rem}\) above, where \(n\) = max_order().
Returns
A TaylorModel of \(g(f)\), where \(f\) is the function modeled by *this.
Exceptions
std::domain_errorIf *this is empty. Strong throw guarantee.
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ contains() [1/3]

template<typename ValueType>
bool sigma::TaylorModel< ValueType >::contains ( const interval_t & interval) const
inline

Checks if *this contains interval.

Parameters
[in]intervalThe interval to check.
Returns
True if range() contains interval, false otherwise.
Exceptions
noneNo throw guarantee

◆ contains() [2/3]

template<typename ValueType>
bool sigma::TaylorModel< ValueType >::contains ( const TaylorModel< ValueType > & other) const
inline

Checks if *this contains other.

Parameters
[in]otherThe TaylorModel to check.
Returns
True if range() contains other's range, false otherwise. True (vacuously) if other is empty.
Exceptions
noneNo throw guarantee

◆ contains() [3/3]

template<typename ValueType>
bool sigma::TaylorModel< ValueType >::contains ( value_t value) const
inline

Checks if *this contains value.

Parameters
[in]valueThe value to check.
Returns
True if range() contains value, false otherwise.
Exceptions
noneNo throw guarantee

◆ empty()

template<typename ValueType>
bool sigma::TaylorModel< ValueType >::empty ( ) const
inlinenoexcept

Checks if this TaylorModel represents the empty set.

Returns
True if *this represents the empty set, false otherwise.
Exceptions
noneNo throw guarantee

◆ multiplicative_inverse()

template<typename ValueType>
auto sigma::TaylorModel< ValueType >::multiplicative_inverse ( ) const

Returns the multiplicative inverse of *this.

Composes the outer series of \(1/x\) about constant() with *this via compose_(), which folds the Lagrange remainder into the result. See compose_() for details.

Returns
The multiplicative inverse of *this.
Exceptions
std::domain_errorIf *this is empty or 0 is in range(). Strong throw guarantee.
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator!=()

template<typename ValueType>
bool sigma::TaylorModel< ValueType >::operator!= ( const TaylorModel< ValueType > & other) const
inline

Checks if *this and other represent different models.

Parameters
[in]otherThe model to compare with *this.
Returns
True if *this and other represent different models, false otherwise.
Exceptions
noneNo throw guarantee

◆ operator*() [1/2]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator* ( const TaylorModel< ValueType > & other) const
inline

Returns the product of *this and other.

This is a convenience method for calling TaylorModel(*this) *= other.

Parameters
[in]otherThe model to multiply *this by.
Returns
The product of *this and other.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator*() [2/2]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator* ( value_t value) const
inline

Returns the product of *this and value.

This is a convenience method for calling TaylorModel(*this) *= value.

Parameters
[in]valueThe value to multiply *this by.
Returns
The product of *this and value.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator*=() [1/2]

template<typename ValueType>
auto sigma::TaylorModel< ValueType >::operator*= ( const TaylorModel< ValueType > & other)

Overwrites *this with the product of *this and other.

Implements Eq. \(\eqref{eq:tm-mul}\). As in operator+=(TaylorModel), mixed orders are first resolved by sweeping the higher-order operand down with sweep_to_order(), so the base formula only ever has to handle two equal-order polynomials:

\[\left(P_1, I_1\right) \cdot \left(P_2, I_2\right) = \left( \left(P_1 P_2\right)_{\leq n},\; B\left(\left(P_1 P_2\right)_{>n}\right) + B\left(P_1\right) I_2 + B\left(P_2\right) I_1 + I_1 I_2 \right) \]

Unlike Taylor::operator*=(Taylor), which simply discards \((P_1 P_2)_{>n}\), this bounds it with Taylor::bound() and folds it into the remainder, so Eq. \(\eqref{eq:tm-inclusion}\) survives the operation.

Parameters
[in]otherThe model to multiply *this by.
Returns
Reference to this model after multiplication.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator*=() [2/2]

template<typename ValueType>
TaylorModel & sigma::TaylorModel< ValueType >::operator*= ( value_t value)
inline

Overwrites *this with the product of *this and value.

Scalar multiplication is linear, so both the polynomial and the remainder are scaled by value.

Parameters
[in]valueThe value to multiply *this by.
Returns
Reference to this model after multiplication.
Exceptions
noneNo throw guarantee

◆ operator+() [1/2]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator+ ( const TaylorModel< ValueType > & other) const
inline

Returns the sum of *this and other.

This is a convenience method for calling TaylorModel(*this) += other.

Parameters
[in]otherThe model to add to *this.
Returns
The sum of *this and other.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator+() [2/2]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator+ ( value_t value) const
inline

Returns the sum of *this and value.

This is a convenience method for calling TaylorModel(*this) += value.

Parameters
[in]valueThe value to add to *this.
Returns
The sum of *this and value.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator+=() [1/2]

template<typename ValueType>
auto sigma::TaylorModel< ValueType >::operator+= ( const TaylorModel< ValueType > & other)

Overwrites *this with the sum of *this and other.

Implements Eq. \(\eqref{eq:tm-add}\): \((P_1+P_2,\, I_1+I_2)\). If *this and other have different truncation orders, the higher-order operand is first reduced with sweep_to_order() – which bounds its excess terms into its own remainder rather than dropping them – so the two polynomials being added are always at equal order and the sum never has terms to discard (see docs/taylor.md's "Mixed orders resolve downward").

Parameters
[in]otherThe model to add to *this.
Returns
Reference to this model after addition.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator+=() [2/2]

template<typename ValueType>
TaylorModel & sigma::TaylorModel< ValueType >::operator+= ( value_t value)
inline

Overwrites *this with the sum of *this and value.

Adding a scalar shifts the constant term only; it introduces no new uncertainty, so the remainder is unaffected (or, if *this was empty, set to the empty interval \([0,0]\)).

Parameters
[in]valueThe value to add to *this.
Returns
Reference to this model after addition.
Exceptions
noneNo throw guarantee

◆ operator-() [1/3]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator- ( ) const
inline

Returns the additive inverse of *this.

Negates both the polynomial and the remainder: if \(f(x) \in P(\delta) + I\) then \(-f(x) \in -P(\delta) + (-I)\).

Returns
The additive inverse of *this.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator-() [2/3]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator- ( const TaylorModel< ValueType > & other) const
inline

Returns the difference of *this and other.

This is a convenience method for calling TaylorModel(*this) -= other.

Parameters
[in]otherThe model to subtract from *this.
Returns
The difference of *this and other.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator-() [3/3]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator- ( value_t value) const
inline

Returns the difference of *this and value.

This is a convenience method for calling TaylorModel(*this) -= value.

Parameters
[in]valueThe value to subtract from *this.
Returns
The difference of *this and value.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator-=() [1/2]

template<typename ValueType>
TaylorModel & sigma::TaylorModel< ValueType >::operator-= ( const TaylorModel< ValueType > & other)
inline

Overwrites *this with the difference of *this and other.

This is implemented as *this += -other. See the documentation for operator+=(TaylorModel) and operator-() for details.

Parameters
[in]otherThe model to subtract from *this.
Returns
Reference to this model after subtraction.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator-=() [2/2]

template<typename ValueType>
TaylorModel & sigma::TaylorModel< ValueType >::operator-= ( value_t value)
inline

Overwrites *this with the difference of *this and value.

Parameters
[in]valueThe value to subtract from *this.
Returns
Reference to this model after subtraction.
Exceptions
noneNo throw guarantee

◆ operator/() [1/2]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator/ ( const TaylorModel< ValueType > & other) const
inline

Returns the quotient of *this and other.

This is a convenience method for calling TaylorModel(*this) /= other.

Parameters
[in]otherThe model to divide *this by.
Returns
The quotient of *this and other.
Exceptions
std::domain_errorIf other is empty or 0 is in its range().
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator/() [2/2]

template<typename ValueType>
TaylorModel sigma::TaylorModel< ValueType >::operator/ ( value_t value) const
inline

Returns the quotient of *this and value.

This is a convenience method for calling TaylorModel(*this) /= value.

Parameters
[in]valueThe value to divide *this by.
Returns
The quotient of *this and value.
Exceptions
std::domain_errorIf value is zero.

◆ operator/=() [1/2]

template<typename ValueType>
TaylorModel & sigma::TaylorModel< ValueType >::operator/= ( const TaylorModel< ValueType > & other)
inline

Overwrites *this with the quotient of *this and other.

Implemented as the product of this and other.multiplicative_inverse(). See the documentation for operator=(TaylorModel) and multiplicative_inverse() for details.

Parameters
[in]otherThe model to divide *this by.
Returns
Reference to this model after division.
Exceptions
std::domain_errorIf other is empty or 0 is in its range().
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator/=() [2/2]

template<typename ValueType>
TaylorModel & sigma::TaylorModel< ValueType >::operator/= ( value_t value)
inline

Overwrites *this with the quotient of *this and value.

Parameters
[in]valueThe value to divide *this by.
Returns
Reference to this model after division.
Exceptions
std::domain_errorIf value is zero.

◆ operator==()

template<typename ValueType>
bool sigma::TaylorModel< ValueType >::operator== ( const TaylorModel< ValueType > & other) const
inline

Checks if *this and other represent the same model.

Two TaylorModels are equal if they are both empty, or if they have the same polynomial and the same remainder.

Parameters
[in]otherThe model to compare with *this.
Returns
True if *this and other represent the same model, false otherwise.
Exceptions
noneNo throw guarantee

◆ polynomial()

template<typename ValueType>
const taylor_t & sigma::TaylorModel< ValueType >::polynomial ( ) const
inlinenoexcept

Returns the underlying polynomial.

Returns
Const reference to the polynomial part of *this.
Exceptions
noneNo throw guarantee

◆ print_interval_form()

template<typename ValueType>
std::string sigma::TaylorModel< ValueType >::print_interval_form ( ) const
inline

Creates a string of the interval form of *this.

This is a convenience method for calling range().print_interval_form().

Returns
A string representation of the interval form of *this.
Exceptions
std::domain_errorIf *this is empty. Strong throw guarantee.
std::bad_allocIf memory allocation for the string fails. Strong throw guarantee.

◆ print_polynomial_form()

template<typename ValueType>
std::string sigma::TaylorModel< ValueType >::print_polynomial_form ( ) const
inline

Creates a string of the polynomial form of *this.

This is a convenience method for calling polynomial().print_polynomial_form(); the remainder is not included.

Returns
A string representation of the polynomial part of *this.
Exceptions
std::bad_allocIf memory allocation for the string fails. Strong throw guarantee.

◆ range()

template<typename ValueType>
interval_t sigma::TaylorModel< ValueType >::range ( ) const
inline

Returns an interval enclosing the values *this models.

This is \(B(P) + I\): the polynomial's bound (Taylor::bound(), currently the quadratic fast bounder) plus the remainder. Together with the constructors and arithmetic below, this is what guarantees Eq. \(\eqref{eq:tm-inclusion}\).

Returns
An interval enclosing the values of *this.
Exceptions
std::domain_errorIf *this is empty. Strong throw guarantee.

◆ remainder()

template<typename ValueType>
const interval_t & sigma::TaylorModel< ValueType >::remainder ( ) const
inlinenoexcept

Returns the remainder interval.

Returns
Const reference to the remainder interval \(I\).
Exceptions
noneNo throw guarantee

◆ sweep_small()

template<typename ValueType>
auto sigma::TaylorModel< ValueType >::sweep_small ( value_t threshold) const

Removes individually small coefficients, bounding them into the remainder.

Serves the purpose that ThresholdedAffine's automatic thresholding serves – controlling how many terms are carried – but rigorously: a coefficient \(c_\beta\) is removed when \(|c_\beta| / \mathrm{radius}(\mathrm{range}()) < \) threshold (every monomial is bounded in magnitude by 1 over \([-1,1]^v\), so \(|c_\beta|\) is exactly that term's maximum contribution), and its contribution is bounded with Taylor::bound() and added to the remainder rather than discarded.

Parameters
[in]thresholdThe relative threshold below which a coefficient is swept into the remainder.
Returns
*this, with small coefficients swept into the remainder.
Exceptions
std::domain_errorIf *this is empty. Strong throw guarantee.

◆ sweep_to_order()

template<typename ValueType>
auto sigma::TaylorModel< ValueType >::sweep_to_order ( size_type new_order) const

Reduces *this to a lower truncation order, bounding the removed terms into the remainder.

Every coefficient whose monomial has degree above new_order is removed from the polynomial; their combined contribution is bounded with Taylor::bound() and added to the remainder. Unlike Taylor::truncate(), which simply discards those terms, this preserves Eq. \(\eqref{eq:tm-inclusion}\) – the enclosure gets wider, never invalid. If new_order is greater than or equal to max_order(), nothing is removed and the remainder is unchanged.

Parameters
[in]new_orderThe truncation order of the result.
Returns
*this, reduced to new_order.
Exceptions
std::domain_errorIf *this is empty. Strong throw guarantee.

◆ abs()

template<typename T>
TaylorModel< T > abs ( const TaylorModel< T > & a)
related

Absolute value of a TaylorModel.

Template Parameters
TThe value type of the model.

Unlike the elementary functions below, \(|\cdot|\) has no Taylor series at points where its argument's range straddles 0, so it is not built from compose_(). If range() lies entirely on one side of 0, \(|\cdot|\) is linear there and *this (or its negation) is returned unchanged. Otherwise, mirroring Affine::abs and Taylor::abs, the exact range of \(|\cdot|\) is returned directly: for \(f \in [\mathrm{lo}, \mathrm{hi}]\) with \(\mathrm{lo} < 0 < \mathrm{hi}\), \(|f| \in [0, \max(|\mathrm{lo}|, \mathrm{hi})]\), which the interval constructor turns directly into a model (per Eq. \(\eqref{eq:tm-inclusion}\)'s Interval row), preserving inclusion rigorously.

Parameters
[in]aThe TaylorModel.
Returns
The absolute value of a.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ exp()

template<typename T>
TaylorModel< T > exp ( const TaylorModel< T > & a)
related

Exponential of a TaylorModel.

Template Parameters
TThe value type of the model.

Composes the Taylor series of exp about constant() with a, per Eq. \(\eqref{eq:tm-exp}\), folding the Lagrange remainder of Eq. \(\eqref{eq:tm-exp-rem}\) into the result. See TaylorModel::compose_.

Parameters
[in]aThe TaylorModel whose exponential is computed.
Returns
A TaylorModel enclosing the exponential of the function modeled by a.
Exceptions
std::domain_errorIf a is empty. Strong throw guarantee.
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ fabs()

template<typename T>
TaylorModel< T > fabs ( const TaylorModel< T > & a)
related

Absolute value of a TaylorModel.

Template Parameters
TThe value type of the model.

This function is an alias for abs(const TaylorModel<T>&). See its documentation for details.

Parameters
[in]aThe TaylorModel.
Returns
The absolute value of a.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ log()

template<typename T>
TaylorModel< T > log ( const TaylorModel< T > & a)
related

Natural logarithm of a TaylorModel.

Template Parameters
TThe value type of the model.

Composes the series of log about constant() with a, folding the Lagrange remainder into the result. See TaylorModel::compose_.

Parameters
[in]aThe TaylorModel whose natural logarithm is computed.
Returns
A TaylorModel enclosing the natural logarithm of the function modeled by a.
Exceptions
std::domain_errorIf a is empty or range() contains non-positive values. Strong throw guarantee.
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator*()

template<typename ValueType>
TaylorModel< ValueType > operator* ( ValueType value,
const TaylorModel< ValueType > & t )
related

Multiplies a scalar by a TaylorModel.

Template Parameters
ValueTypeThe type of the values in the model.

This is a convenience method for calling t * value.

Parameters
[in]valueThe scalar to multiply by.
[in]tThe TaylorModel to multiply.
Returns
The product of the scalar and the model.
Exceptions
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ operator<<()

template<typename ValueType>
std::ostream & operator<< ( std::ostream & os,
const TaylorModel< ValueType > & t )
related

Outputs the range of a TaylorModel to an output stream.

Template Parameters
ValueTypeThe type of the values in the model.

For a non-empty model, this method defers to the output operator for interval_t to print range(). An empty model is printed as "&#8709;", matching Interval's own operator<<, rather than throwing (range() throws for an empty model). See TaylorModel::print_polynomial_form() for a string representation showing the individual terms instead.

Parameters
[in]osThe output stream to write to.
[in]tThe TaylorModel to output.
Returns
The output stream.
Exceptions
noneNo throw guarantee

◆ pow()

template<typename T, typename U>
TaylorModel< T > pow ( const TaylorModel< T > & a,
const U & exp )
related

Power of a TaylorModel.

Template Parameters
TThe value type of the model.
UThe type of the exponent.

For a strictly one-signed range this method takes advantage of the fact that:

\[x^y = e^{y \log(x)} \]

mirroring Affine::pow. If range() straddles or touches 0 (and is not exactly the point 0, where \(0^y = 0\) for any \(y > 0\)), neither \(\log\) branch is valid, so exp must be a positive integer, and the result is computed by repeated multiplication instead – which stays rigorous (Eq. \(\eqref{eq:tm-mul}\)) across a zero-containing range, unlike the \(\log\)/ \(\exp\) route.

Parameters
[in]aThe TaylorModel whose power is computed.
[in]expThe exponent.
Returns
A TaylorModel enclosing a raised to exp.
Exceptions
std::domain_errorIf range() contains 0 and exp is negative, or if range() contains non-positive values (and is not exactly the point 0) and exp is not an integer. Strong throw guarantee.
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

◆ sqrt()

template<typename T>
TaylorModel< T > sqrt ( const TaylorModel< T > & a)
related

Square root of a TaylorModel.

Template Parameters
TThe value type of the model.

Composes the binomial series of sqrt about constant() with a, per Eq. \(\eqref{eq:tm-outer-split}\), folding the Lagrange remainder into the result. See TaylorModel::compose_.

Parameters
[in]aThe TaylorModel whose square root is computed.
Returns
A TaylorModel enclosing the square root of the function modeled by a.
Exceptions
std::domain_errorIf a is empty or range() contains non-positive values. Strong throw guarantee.
std::bad_allocIf memory allocation for the new model fails. Strong throw guarantee.

The documentation for this class was generated from the following files: