Core 1.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Quartic Class Reference

Quartic polynomials. More...

#include <quartic.h>

Public Member Functions

 Quartic (const double &, const double &, const double &, const double &, const double &)
 Empty. More...
 
 Quartic (const Quadric &)
 Creates a quartic given a quadric.
 
 Quartic (const Cubic &)
 Creates a quartic given a cubic.
 
constexpr double & operator[] (int)
 Empty. More...
 
constexpr double operator[] (int) const
 Overloaded.
 
int CheckDegree () const
 Check the degree of the quartic.
 
Quartic operator- () const
 Unary.
 
Quarticoperator+= (const Quartic &)
 Destructive sum of two quartics.
 
Quarticoperator-= (const Quartic &)
 Destructive difference.
 
Quarticoperator*= (const double &)
 Scale a quartic by a double value.
 
Quarticoperator/= (const double &)
 Scale a quartic by a double value.
 
Cubic Prime () const
 Computes the first derivative of a cubic, which is a cubic.
 
Quadric Second () const
 Computes the second derivative of a quartic, which is a quadric.
 
Linear Third () const
 Computes the third derivative of a quartic, which is a linear.
 
double K (const double &, const double &) const
 Compute the Lipschitz constant of the quartic. More...
 
constexpr double operator() (const double &) const
 Evaluates the quartic. More...
 
constexpr double Derivative (const double &) const
 Computes the derivative value at a given point. More...
 
int Solve (double *)
 Search the roots of a quartic equation. More...
 
int Solve (double *, const double &, const double &)
 Search the roots of a quartic equation over a given interval. More...
 
void Range (double &, double &, const double &=0.0, const double &=1.0) const
 Compute the range of values taken by a quartic over a given interval. More...
 

Static Public Member Functions

static Quartic Compose (const Quadric &, const Quadric &)
 Compose the quadric by another one. More...
 

Static Public Attributes

static double epsilon = 1.0e-10
 Epsilon value used to check discriminant terms in the root finding process.
 

Protected Member Functions

bool Analyze ()
 Check if any coefficient of the quartic is more than 1012 times larger than the smallest. More...
 

Protected Attributes

double c [5] = { 0.0,0.0,0.0,0.0,0.0 }
 Array of coefficients.
 

Friends

Quartic operator+ (const Quartic &, const Quartic &)
 Overloaded.
 
Quartic operator- (const Quartic &, const Quartic &)
 Overloaded.
 
Quartic operator* (const Quartic &, const double &)
 Overloaded.
 
Quartic operator* (const double &, const Quartic &)
 Overloaded.
 
Quartic operator/ (const Quartic &, const double &)
 Overloaded.
 
Quartic operator* (const Quadric &, const Quadric &)
 Multiply two quadrics which generates a quartic. More...
 
std::ostream & operator<< (std::ostream &, const Quartic &)
 Overloaded output-stream operator. More...
 

Detailed Description

Quartic polynomials.

Closed form expression of roots exist for quartics.

Constructors should provide the coefficients in descending order. Example of how to code the quartic x4+x3-x+1:

Quartic p(3.0,1.0,0.0,-1.0,1.0);
Quartic polynomials.
Definition: quartic.h:8

Constructor & Destructor Documentation

◆ Quartic()

Quartic::Quartic ( const double &  a,
const double &  b,
const double &  c,
const double &  d,
const double &  e 
)
inlineexplicit

Empty.

Creates a quartic.

Member Function Documentation

◆ Analyze()

bool Quartic::Analyze ( )
protected

Check if any coefficient of the quartic is more than 1012 times larger than the smallest.

Small coefficients are set to 0.

◆ Compose()

Quartic Quartic::Compose ( const Quadric p,
const Quadric q 
)
static

Compose the quadric by another one.

This function computes p ( q(x) ), where p denotes the quadric and q the argument.

Parameters
qThe quadric.
pThe argument quadric.

◆ Derivative()

constexpr double Quartic::Derivative ( const double &  x) const
inlineconstexpr

Computes the derivative value at a given point.

If only one evaluation is to be made, this function is more efficient than Prime() and then evaluating the derivative for a given input value.

Parameters
xReal.
See also
Quartic::Prime

◆ K()

double Quartic::K ( const double &  a,
const double &  b 
) const

Compute the Lipschitz constant of the quartic.

Parameters
a,bInterval.

◆ operator()()

constexpr double Quartic::operator() ( const double &  x) const
inlineconstexpr

Evaluates the quartic.

Parameters
xArgument value of the function.

◆ operator[]()

constexpr double & Quartic::operator[] ( int  i)
inlineconstexpr

Empty.

Access to the coefficients of the quartic.

◆ Range()

void Quartic::Range ( double &  x,
double &  y,
const double &  a = 0.0,
const double &  b = 1.0 
) const

Compute the range of values taken by a quartic over a given interval.

Compute the roots of the first derivative, and evaluates the cubic at the roots if they are within the interval bounds.

Parameters
a,bInterval.
x,yReturned range.

◆ Solve() [1/2]

int Quartic::Solve ( double *  results)

Search the roots of a quartic equation.

The roots are not sorted.

This function calls other root solving functions, invoking Cubic::Solve() or Quadric::Solve() as appropriate if the degree is lower than four (which means that closed form expressions of the roots exist).

Otherwise, solve the quartic using the method of Francois Vieta (Circa 1735).

This function checks if the higher coefficients are nul, possibly calling Quadric::Solve() and Cubic::Solve() if need be.

Parameters
resultsArray for storing the roots.

◆ Solve() [2/2]

int Quartic::Solve ( double *  roots,
const double &  a,
const double &  b 
)

Search the roots of a quartic equation over a given interval.

Parameters
rootsArray for storing the roots.
a,bInterval range.

Friends And Related Function Documentation

◆ operator*

Quartic operator* ( const Quadric u,
const Quadric v 
)
friend

Multiply two quadrics which generates a quartic.

Parameters
u,vArgument quadrics.

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Quartic p 
)
friend

Overloaded output-stream operator.

Parameters
sStream.
pThe quartic.