|
TPCCLIB
|
Finding the real roots of equations. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <math.h>#include "tpcextensions.h"#include "tpclinopt.h"Go to the source code of this file.
Functions | |
| int | rootsCubic (const double a, const double b, const double c, double *x1, double *x2, double *x3) |
| int | rootsQuadratic (const double a, const double b, const double c, double *x1, double *x2) |
| int rootsCubic | ( | const double | a, |
| const double | b, | ||
| const double | c, | ||
| double * | x1, | ||
| double * | x2, | ||
| double * | x3 ) |
Find the real roots of cubic equation x^3 + a x^2 + b x + c = 0.
The number of real roots can be 1 or 3, but coincident roots are possible. Root values, excluding duplicates and triplicates, will be placed in pointers x1, x2, and x3 in ascending order, or set to NaN.
Based on GNU Scientific Library function gsl_poly_solve_cubic.
| a | Input: Parameter a of the cubic equation. |
| b | Input: Parameter b of the cubic equation. |
| c | Input: Parameter c of the cubic equation. |
| x1 | Output: Pointer for root 1 value. Will be set to NaN if there are no real roots. |
| x2 | Output: Pointer for root 2 value. Will be set to NaN if there is only one individual real root. |
| x3 | Output: Pointer for root 3 value. Will be set to NaN if there are only two individual real roots. |
Definition at line 30 of file roots.c.
| int rootsQuadratic | ( | const double | a, |
| const double | b, | ||
| const double | c, | ||
| double * | x1, | ||
| double * | x2 ) |
Find the real roots of quadratic equation a x^2 + b x + c = 0.
The number of real roots can be 0, 1, or 2, but coincident roots are possible. Root values, excluding duplicate value, will be placed in pointers x1 and x2 in ascending order, or set to NaN.
Based on GNU Scientific Library function gsl_poly_solve_quadratic.
| a | Input: Parameter a of the quadratic equation. |
| b | Input: Parameter b of the quadratic equation. |
| c | Input: Parameter c of the quadratic equation. |
| x1 | Output: Pointer for root 1 value. Will be set to NaN if there are no real roots. |
| x2 | Output: Pointer for root 2 value. Will be set to NaN if there is only one individual real root. |
Definition at line 111 of file roots.c.