Polynomial
Represents a polynomial function with a numeric type parameter X. Supports evaluation, differentiation, and construction of new polynomials.
TODO create an abstract Polynomial which will have the implicit Numeric[X] value
Attributes
- Graph
-
- Supertypes
-
trait X => Xclass Objecttrait Matchableclass Any
- Known subtypes
-
class NumberPolynomialclass RationalPolynomial
Members list
Value members
Abstract methods
Retrieves the coefficients of the polynomial in ascending order of powers.
Retrieves the coefficients of the polynomial in ascending order of powers.
Attributes
- Returns
-
a sequence of coefficients of type X, where the ith element corresponds to the coefficient of the
x∧iterm
Returns the degree of the polynomial.
Returns the degree of the polynomial.
Attributes
- Returns
-
the degree of the polynomial as an integer
Retrieves the Numeric instance associated with the polynomial.
Retrieves the Numeric instance associated with the polynomial.
Attributes
- Returns
-
the Numeric instance of type X, which provides numeric operations for the coefficients
Constructs a polynomial with the given degree and coefficients.
Constructs a polynomial with the given degree and coefficients.
Value parameters
- coefficients
-
a sequence of coefficients of type X, where the ith element corresponds to the coefficient of the
x∧iterm - degree
-
the degree of the polynomial, an integer representing the highest power of x
- xn
-
an implicit Numeric instance that provides numeric operations for the type X
Attributes
- Returns
-
a new Polynomial instance of type X constructed with the specified degree and coefficients
Concrete methods
Evaluates the polynomial for a given input value.
Evaluates the polynomial for a given input value.
The method calculates the polynomial value by summing the contributions of each term. Each term is computed as the coefficient multiplied by the corresponding power of the input value.
Value parameters
- x
-
the input value of type X at which the polynomial is to be evaluated
Attributes
- Returns
-
the value of the polynomial at the given input value
Computes the derivative of the polynomial.
Computes the derivative of the polynomial.
Attributes
- Returns
-
a new polynomial representing the derivative of the current polynomial
Computes the nth derivative of the polynomial.
Computes the nth derivative of the polynomial.
TODO fix me
Value parameters
- n
-
the number of times to compute the derivative, where n must be a non-negative integer
Attributes
- Returns
-
a new polynomial representing the nth derivative of the current polynomial
Computes the nth derivative of the polynomial and evaluates it at the given input value.
Computes the nth derivative of the polynomial and evaluates it at the given input value.
Value parameters
- n
-
the order of the derivative to compute, where n is a non-negative integer
- x
-
the input value of type X at which the nth derivative will be evaluated
Attributes
- Returns
-
the result of evaluating the nth derivative of the polynomial at the given input value
Inherited methods
Composes two instances of Function1 in a new Function1, with this function applied first.
Composes two instances of Function1 in a new Function1, with this function applied first.
Type parameters
- A
-
the result type of function
g
Value parameters
- g
-
a function R => A
Attributes
- Returns
-
a new function
fsuch thatf(x) == g(apply(x)) - Inherited from:
- Function1
Composes two instances of Function1 in a new Function1, with this function applied last.
Composes two instances of Function1 in a new Function1, with this function applied last.
Type parameters
- A
-
the type to which function
gcan be applied
Value parameters
- g
-
a function A => T1
Attributes
- Returns
-
a new function
fsuch thatf(x) == apply(g(x)) - Inherited from:
- Function1
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.
- Definition Classes
-
Function1 -> Any
- Inherited from:
- Function1
Concrete fields
Generates a string representation of the polynomial in the format: "Polynomial(degree, coefficient1, coefficient2, ..., coefficientN)".
Generates a string representation of the polynomial in the format: "Polynomial(degree, coefficient1, coefficient2, ..., coefficientN)".
Attributes
- Returns
-
a string that represents the polynomial, including its degree and coefficients