NumberPolynomial

com.phasmidsoftware.number.core.numerical.NumberPolynomial
See theNumberPolynomial companion object
case class NumberPolynomial(degree: Int, coefficients: Seq[Number])(implicit ev: Numeric[Number]) extends Polynomial[Number]

A case class representing a polynomial of numbers, extending the generic Polynomial trait. This polynomial includes a specific degree and a sequence of coefficients.

Value parameters

coefficients

a sequence of coefficients where the ith element corresponds to the coefficient of the x∧i term.

degree

the degree of the polynomial, which is the highest power of x.

ev

an implicit Numeric instance providing numeric operations for the coefficient type.

Attributes

Constructor

Creates a NumberPolynomial instance with the specified degree, coefficients, and an implicit Numeric instance.

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Number => Number
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def numeric: Numeric[Number]

Retrieves the implicit Numeric instance associated with the polynomial.

Retrieves the implicit Numeric instance associated with the polynomial.

Attributes

Returns

the Numeric instance of type X, which provides numeric operations for the coefficients

override def toString(): String

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
def unit(degree: Int, coefficients: Seq[Number])(implicit xn: Numeric[Number]): Polynomial[Number]

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∧i term

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

Inherited methods

def andThen[A](g: Number => A): Number => A

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 f such that f(x) == g(apply(x))

Inherited from:
Function1
def apply(x: Number): Number

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

Inherited from:
Polynomial
def compose[A](g: A => Number): A => Number

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 g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1

Computes the derivative of the polynomial.

Computes the derivative of the polynomial.

Attributes

Returns

a new polynomial representing the derivative of the current polynomial

Inherited from:
Polynomial
def derivativeN(n: Int): Polynomial[Number]

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

Inherited from:
Polynomial
def nthDerivative(n: Int, x: Number): Number

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 from:
Polynomial
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product

Inherited fields

lazy val render: String

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

Inherited from:
Polynomial