# Polynomial

public class Polynomial : Expression

Special type of Expression to represent polynomials

•  coefs 

List of coefficients

#### Declaration

Swift

public var coefs: [BigDouble] { get set }
•  init(_:) 

Creates a polynomial based on the coefficients

#### Declaration

Swift

public convenience init(_ coefficients: BigDouble...) throws
•  init(_:) 

Creates a polynomial based on the coefficients

#### Declaration

Swift

public init(_ coefficients: [BigDouble]) throws
•  evaluate(at:) 

Evaluates the current polynomial at the given point

Let f be a polynomial function. Evaluate returns the number given by f(x)

#### Declaration

Swift

public func evaluate(at x: BigNumber) -> BigNumber

#### Parameters

  x  The input value for the polynomial function
•  ==(_:_:) 

Equal operator

Returns true only if all the coefficient exactly match.

#### Declaration

Swift

public static func == (lhs: Polynomial, rhs: Polynomial) -> Bool

#### Parameters

  lhs  Left hand side  rhs  Right hand side
•  description 

Produces a string represenation of the polynomial

#### Declaration

Swift

public override var description: String { get }
•  +(_:_:) 

Add polynomials to each other non-destructively.

#### Declaration

Swift

public static func + (lhs: Polynomial, rhs: Polynomial) -> Polynomial

#### Parameters

  lhs  Left hand side  rhs  Right hand side
•  -(_:_:) 

Substract polynomials to each other non-destructively.

#### Declaration

Swift

public static func - (lhs: Polynomial, rhs: Polynomial) -> Polynomial

#### Parameters

  lhs  Left hand side  rhs  Right hand side
•  negated 

Negates this polynomial.

Does so non-destructively

#### Declaration

Swift

public var negated: Polynomial { get }
•  derivative 

Computes the derivative of this polynomial

#### Declaration

Swift

public var derivative: Polynomial { get }
•  normalized 

Divides the polynomial by the leading coefficient so that we would have a monic polynomial

#### Declaration

Swift

public var normalized: Polynomial { get }
•  cauchyPoly 

Returns the Cauchy Polynomial from this polynomial

#### Declaration

Swift

public var cauchyPoly: Polynomial { get }
•  linearDivision(x_coef:x_const:) 

Divides this polynomial by given linear (1 degree) polynomial (Non destructive)

#### Declaration

Swift

public func linearDivision(x_coef: BigDouble, x_const: BigDouble) -> Polynomial

#### Parameters

  x_coefs  coefficient of the (x-)term  x_const  constant term
•  *(_:_:) 

Multiplies through this polynomial by the given constant

#### Declaration

Swift

public static func * (lhs: Polynomial, rhs: BigDouble) -> Polynomial

#### Parameters

  lhs  Left hand side  rhs  Right hand side
•  roots 

Finds roots of the polynomial

Not always inclusive. Sometimes, for the same polynomials, results are different as it relies on guesses.

Note to dev team: performance is not ideal and could be improved by relying on native numbers when possible.

#### Declaration

Swift

public var roots: [BigDouble] { get }