
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
lex-polynomial
Advanced tools
This library provides classes to work with polynomials, monomials, and terms. The main classes included are `Polynomial`, `Monomial`, and `Term`.
This library provides classes to work with polynomials, monomials, and terms. The main classes included are Polynomial
, Monomial
, and Term
.
You can install this library by cloning the repository and importing the classes as needed.
npm install lex-polynoimal
import { Monomial, Term, Polynomial } from 'lex-polynomial'
A Monomial represents a single term in a polynomial with variables and their respective powers.
const monomial = new Monomial({ x: 2, y: 1 });
console.log(monomial.toString()); // Outputs: x^2y
A Term consists of a coefficient and a Monomial.
const monomial = new Monomial({ x: 2, y: 1 });
const term = new Term(3, monomial);
console.log(term.toString()); // Outputs: 3x^2y
A Polynomial
is a collection of Term
objects.
const term1 = new Term(3, new Monomial({ x: 2, y: 1 }));
const term2 = new Term(-1, new Monomial({ y: 1 }));
const polynomial = new Polynomial([term1, term2]);
console.log(polynomial.toString()); // Outputs: 3x^2y-y
You can also create a Polynomial
from a string representation:
const polynomial = new Polynomial("3x^2y - y");
console.log(polynomial.toString()); // Outputs: 3x^2y-y
const poly1 = new Polynomial("3x^2y - y");
const poly2 = new Polynomial("x^2y + 2");
const sum = poly1.add(poly2);
console.log(sum.toString()); // Outputs: 4x^2y-y+2
const poly1 = new Polynomial("3x^2y - y");
const poly2 = new Polynomial("x^2y + 2");
const difference = poly1.sub(poly2);
console.log(difference.toString()); // Outputs: 2x^2y-y-2
const poly1 = new Polynomial("3x^2y - y");
const poly2 = new Polynomial("x + 1");
const product = poly1.multiplyPolynomial(poly2);
console.log(product.toString()); // Outputs: 3x^3y+3x^2y-yx-y
const poly1 = new Polynomial("3x^2y - y");
const term = new Term(3, new Monomial({ x: 2 }));
const quotient = poly1.divideByTerm(term);
console.log(quotient.toString()); // Outputs: y - y/(3x^2)
getVarNames()
: Returns the sorted variable names.getVariables()
: Returns the variables with their powers.toString()
: Returns the string representation.dividableByMonomial(mono)
: Checks if the monomial is divisible by another monomial.compare(mono)
: Compares two monomials.equal(mono)
: Checks if two monomials are equal.static isSame(mono1, mono2)
: Static method to check if two monomials are the same.static compare(mono1, mono2)
: Static method to compare two monomials.static getGCD(mono1, mono2)
: Static method to get the GCD of two monomials.static getLCM(mono1, mono2)
: Static method to get the LCM of two monomials.getCoefficient()
: Returns the coefficient.getMonomial()
: Returns the monomial part.getVarNames()
: Returns the variable names.getVariables()
: Returns the variables.toString()
: Returns the string representation.getNonCoefficientPart()
: Returns the non-coefficient part as a monomial.multiplyPolynomial(poly)
: Multiplies the term with a polynomial.divideByMonomial(divisor)
: Divides the term by a monomial.divideByTerm(divisor)
: Divides the term by another term.static compare(term1, term2)
: Static method to compare two terms.getLeadingTerm()
: Returns the leading term.getLeadingCofficient()
: Returns the leading coefficient.getLeadingMonomial()
: Returns the leading monomial.getTerms()
: Returns the terms.removeTerm(removeTerm)
: Removes a term.negative()
: Returns the negation of the polynomial.multiplyTerm(term)
: Multiplies the polynomial by a term.divideByTerm(term)
: Divides the polynomial by a term.multiplyPolynomial(poly)
: Multiplies the polynomial by another polynomial.quotient(divisor)
: Returns the quotient of the polynomial division.reminder(divisor)
: Returns the remainder of the polynomial division.divideByPolynomial(divisor)
: Divides the polynomial by another polynomial.clone()
: Clones the polynomial.toString()
: Returns the string representation.add(poly)
: Adds another polynomial.sub(poly)
: Subtracts another polynomial.static sum(poly1, poly2)
: Static method to sum two polynomials.static createTermsFromString(polyString)
: Static method to create terms from a string.FAQs
This library provides classes to work with polynomials, monomials, and terms. The main classes included are `Polynomial`, `Monomial`, and `Term`.
We found that lex-polynomial demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.