SDDSlib
|
Functions for evaluating polynomials and their derivatives, as well as solving quadratic equations. More...
#include "mdb.h"
Go to the source code of this file.
Functions | |
double | poly (double *a, long n, double x) |
Evaluate a polynomial at a given point. | |
double | dpoly (double *a, long n, double x) |
Evaluate the derivative of a polynomial at a given point. | |
double | polyp (double *a, long *power, long n, double x) |
Evaluate a polynomial with arbitrary powers at a given point. | |
double | dpolyp (double *a, long *power, long n, double x) |
Evaluate the derivative of a polynomial with arbitrary powers at a given point. | |
int | solveQuadratic (double a, double b, double c, double *solution) |
Solve a quadratic equation for real solutions. | |
Functions for evaluating polynomials and their derivatives, as well as solving quadratic equations.
Definition in file poly.c.
double dpoly | ( | double * | a, |
long | n, | ||
double | x ) |
Evaluate the derivative of a polynomial at a given point.
Given an array of coefficients a and the number of terms n, this function returns the value of the derivative of the polynomial at x. The polynomial is assumed to be: a[0] + a[1]*x + a[2]*x^2 + ... Its derivative is: a[1] + 2*a[2]*x + 3*a[3]*x^2 + ...
[in] | a | Pointer to the array of polynomial coefficients. |
[in] | n | Number of coefficients (degree+1 of the polynomial). |
[in] | x | The point at which to evaluate the derivative. |
Definition at line 58 of file poly.c.
double dpolyp | ( | double * | a, |
long * | power, | ||
long | n, | ||
double | x ) |
Evaluate the derivative of a polynomial with arbitrary powers at a given point.
Given arrays a and power that define a polynomial a[0]*x^(power[0]) + a[1]*x^(power[1]) + ... + a[n-1]*x^(power[n-1]), this function returns the derivative of that polynomial at x: power[0]*a[0]*x^(power[0]-1) + power[1]*a[1]*x^(power[1]-1) + ...
[in] | a | Pointer to the array of polynomial coefficients. |
[in] | power | Pointer to the array of powers for each term. |
[in] | n | Number of terms. |
[in] | x | The point at which to evaluate the derivative. |
double poly | ( | double * | a, |
long | n, | ||
double | x ) |
Evaluate a polynomial at a given point.
Given an array of coefficients a and the number of terms n, this function returns the value of the polynomial at x. The polynomial is assumed to be of the form: a[0] + a[1]*x + a[2]*x^2 + ... + a[n-1]*x^(n-1).
[in] | a | Pointer to the array of polynomial coefficients. |
[in] | n | Number of coefficients (degree+1 of the polynomial). |
[in] | x | The point at which to evaluate the polynomial. |
Definition at line 30 of file poly.c.
double polyp | ( | double * | a, |
long * | power, | ||
long | n, | ||
double | x ) |
Evaluate a polynomial with arbitrary powers at a given point.
This function computes the value of a polynomial at x, where each term may have an arbitrary power. Given arrays a and power, the polynomial is: a[0]*x^(power[0]) + a[1]*x^(power[1]) + ... + a[n-1]*x^(power[n-1]).
[in] | a | Pointer to the array of polynomial coefficients. |
[in] | power | Pointer to the array of powers for each term. |
[in] | n | Number of terms. |
[in] | x | The point at which to evaluate the polynomial. |
int solveQuadratic | ( | double | a, |
double | b, | ||
double | c, | ||
double * | solution ) |
Solve a quadratic equation for real solutions.
Given a quadratic equation of the form a*x^2 + b*x + c = 0, this function finds its real solutions, if any. The solutions are returned in the array solution. The function returns the number of real solutions found:
[in] | a | Quadratic coefficient (for x^2). |
[in] | b | Linear coefficient (for x). |
[in] | c | Constant term. |
[out] | solution | Array of size 2 for storing the found solutions. |
Definition at line 139 of file poly.c.