Polynomial

Overview

The Polynomial class provides a framework for representing and manipulating polynomials in one variable. It supports essential mathematical operations such as addition, multiplication, differentiation, and evaluation. The class is designed for single-threaded use.

Functionality

This class enables the addition of polynomials or individual terms, allowing for the construction of complex polynomial expressions. It supports multiplication with other polynomials or individual terms, making it versatile for algebraic operations. Additionally, users can find roots of a polynomial using Newton's method, which provides precision control through configurable error margins and iteration limits.

The class also offers methods to compute and retrieve the derivative of a polynomial. The derivative can be further evaluated at specific points to analyze its behavior. Users can reset the polynomial to zero when needed, providing a clean state for new calculations.

Methods Summarized

Type
Name
Summary

void

Adds another polynomial to this polynomial.

void

Adds a term to this polynomial.

Finds a root of this polynomial using Newton's method, starting from an initial search value, and with a given precision.

Returns a polynomial that holds the derivative of this polynomial.

Returns the value of the derivative of this polynomial in a certain point.

Returns the value of this polynomial in a certain point.

void

Multiplies this polynomial with another polynomial.

void

Multiples this polynomial with a term.

void

Sets this polynomial to zero.

Methods Detailed

addPolynomial(polynomial)

Adds another polynomial to this polynomial.

Parameters

Returns: void

Sample

addTerm(coefficient, exponent)

Adds a term to this polynomial.

Parameters

Returns: void

Sample

findRoot(startValue, error, iterations)

Finds a root of this polynomial using Newton's method, starting from an initial search value, and with a given precision.

Parameters

Returns: Number The root value after the specified number of iterations or as soon as the error condition is satisfied. Returns Double.NaN if the derivative was zero during the computation.

Sample

getDerivative()

Returns a polynomial that holds the derivative of this polynomial.

Returns: Polynomial A polynomial representing the derivative of this polynomial.

Sample

getDerivativeValue(x)

Returns the value of the derivative of this polynomial in a certain point.

Parameters

Returns: Number The value of the derivative of this polynomial at the specified point.

Sample

getValue(x)

Returns the value of this polynomial in a certain point.

Parameters

Returns: Number The value of this polynomial at the specified point.

Sample

multiplyByPolynomial(polynomial)

Multiplies this polynomial with another polynomial.

Parameters

Returns: void

Sample

multiplyByTerm(coefficient, exponent)

Multiples this polynomial with a term.

Parameters

Returns: void

Sample

setToZero()

Sets this polynomial to zero.

Returns: void

Sample


Last updated

Was this helpful?