Core 1.0
|
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. | |
Quartic & | operator+= (const Quartic &) |
Destructive sum of two quartics. | |
Quartic & | operator-= (const Quartic &) |
Destructive difference. | |
Quartic & | operator*= (const double &) |
Scale a quartic by a double value. | |
Quartic & | operator/= (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... | |
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:
|
inlineexplicit |
Empty.
Creates a quartic.
|
protected |
Check if any coefficient of the quartic is more than 1012 times larger than the smallest.
Small coefficients are set to 0.
Compose the quadric by another one.
This function computes p ( q(x) ), where p denotes the quadric and q the argument.
q | The quadric. |
p | The argument quadric. |
|
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.
x | Real. |
double Quartic::K | ( | const double & | a, |
const double & | b | ||
) | const |
Compute the Lipschitz constant of the quartic.
a,b | Interval. |
|
inlineconstexpr |
Evaluates the quartic.
x | Argument value of the function. |
|
inlineconstexpr |
Empty.
Access to the coefficients of the quartic.
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.
a,b | Interval. |
x,y | Returned range. |
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.
results | Array for storing the roots. |
int Quartic::Solve | ( | double * | roots, |
const double & | a, | ||
const double & | b | ||
) |
Search the roots of a quartic equation over a given interval.
roots | Array for storing the roots. |
a,b | Interval range. |
Multiply two quadrics which generates a quartic.
u,v | Argument quadrics. |
|
friend |
Overloaded output-stream operator.
s | Stream. |
p | The quartic. |