maths.polynomials.single_indeterminate_operations ================================================= .. py:module:: maths.polynomials.single_indeterminate_operations .. autoapi-nested-parse:: This module implements a single indeterminate polynomials class with some basic operations Reference: https://en.wikipedia.org/wiki/Polynomial Classes ------- .. autoapisummary:: maths.polynomials.single_indeterminate_operations.Polynomial Module Contents --------------- .. py:class:: Polynomial(degree: int, coefficients: collections.abc.MutableSequence[float]) .. py:method:: __add__(polynomial_2: Polynomial) -> Polynomial Polynomial addition >>> p = Polynomial(2, [1, 2, 3]) >>> q = Polynomial(2, [1, 2, 3]) >>> p + q 6x^2 + 4x + 2 .. py:method:: __eq__(polynomial_2: object) -> bool Checks if two polynomials are equal. >>> p = Polynomial(2, [1, 2, 3]) >>> q = Polynomial(2, [1, 2, 3]) >>> p == q True .. py:method:: __mul__(polynomial_2: Polynomial) -> Polynomial Polynomial multiplication >>> p = Polynomial(2, [1, 2, 3]) >>> q = Polynomial(2, [1, 2, 3]) >>> p * q 9x^4 + 12x^3 + 10x^2 + 4x + 1 .. py:method:: __ne__(polynomial_2: object) -> bool Checks if two polynomials are not equal. >>> p = Polynomial(2, [1, 2, 3]) >>> q = Polynomial(2, [1, 2, 3]) >>> p != q False .. py:method:: __neg__() -> Polynomial Polynomial negation >>> p = Polynomial(2, [1, 2, 3]) >>> -p - 3x^2 - 2x - 1 .. py:method:: __repr__() -> str >>> p = Polynomial(2, [1, 2, 3]) >>> p 3x^2 + 2x + 1 .. py:method:: __str__() -> str >>> p = Polynomial(2, [1, 2, 3]) >>> print(p) 3x^2 + 2x + 1 .. py:method:: __sub__(polynomial_2: Polynomial) -> Polynomial Polynomial subtraction >>> p = Polynomial(2, [1, 2, 4]) >>> q = Polynomial(2, [1, 2, 3]) >>> p - q 1x^2 .. py:method:: derivative() -> Polynomial Returns the derivative of the polynomial. >>> p = Polynomial(2, [1, 2, 3]) >>> p.derivative() 6x + 2 .. py:method:: evaluate(substitution: float) -> float Evaluates the polynomial at x. >>> p = Polynomial(2, [1, 2, 3]) >>> p.evaluate(2) 17 .. py:method:: integral(constant: float = 0) -> Polynomial Returns the integral of the polynomial. >>> p = Polynomial(2, [1, 2, 3]) >>> p.integral() 1.0x^3 + 1.0x^2 + 1.0x .. py:attribute:: coefficients :type: list[float] .. py:attribute:: degree