Polynomial Math is a subset of mathematics dealing with mathematical expressions constructed from variables and constants using only the operations of addition, subtraction, multiplication, and non-negative integer exponents. Any polynomial math question should be programming related.
Questions tagged [polynomial-math]
630 questions
7
votes
5 answers
Storing polynomials in TreeMaps --- Why?
I wrote an exam paper today, for a university course concerned with the implementation of data structures in Java. The last question was along these lines:
Explain why it's convienient to use a TreeMap to store a polynomial with…

jforberg
- 6,537
- 3
- 29
- 47
7
votes
1 answer
Multivariate polynomial regression in javascript?
How can multivariate linear regression be adapted to do multivariate polynomial regression in Javascript? This means that the input X is a 2-D array, predicting a y target that is a 1-D array.
The python way is to do it with…

mikal94305
- 4,663
- 8
- 31
- 40
7
votes
5 answers
What is a simple way to find real roots of a (cubic) polynomial?
this seems like an obvious question to me, but I couldn't find it anywhere on SO.
I have a cubic polynomial and I need to find real roots of the function. What is THE way of doing this?
I have found several closed form formulas for roots of a cubic…

cube
- 3,867
- 7
- 32
- 52
7
votes
1 answer
How is naive evaluation of polynomials bad for accuracy?
In this Code Review answer:
https://codereview.stackexchange.com/a/59405/11633
I found the following (nested quote ahead!):
Let me quote the wonderful book Numerical Recipes in C++ (but also applicable)
We assume that you know enough never to…

Emilio M Bumachar
- 2,532
- 3
- 26
- 30
7
votes
1 answer
Algorithm for computing the inverse of a polynomial
I'm looking for an algorithm (or code) to help me compute the inverse a polynomial, I need it for implementing NTRUEncrypt. An algorithm that is easily understandable is what I prefer, there are pseudo-codes for doing this, but they are confusing…

Mohammad Sepahvand
- 17,364
- 22
- 81
- 122
7
votes
2 answers
How can I create functions that handle polynomials?
I have these problems about polynomials and I've spent about 4 hours on this, but I just can't get it. I'm new to Python and programming and I've tried working it out on paper, but I just don't know.
Write and test a Python function negate(p) that…

confusedstudent
- 139
- 2
- 3
- 9
7
votes
3 answers
Transform 2d spline function f(t) into f(x)
So I've got a special case set of cubic splines, whose 2d control points will always result in a curve that will never cross itself in the x axis. That is, the curves look like they could be a simple polynomial function such that y=f(x). I want to…

vercellop
- 553
- 5
- 18
6
votes
4 answers
How to use polynomials instead of bits to improve the performance?
I have a 128-bit string, and my supervisor has asked me to represent those 128 bits as a polynomial. This is a scan of the paper he was writing on:
His idea is, since we are eliminating the 0s from these bits, we will be able to perform the next…

mota
- 5,275
- 5
- 34
- 44
6
votes
1 answer
library for affine k-algebra computations?
I'm looking for a library or computer algebra system that will help compute operations on polynomials in the ring
F_2[x_1, ..., x_n] /
where F_2 is the 2-element finite field, and is the ideal generated from elements f^2 - f for…

gatoatigrado
- 16,580
- 18
- 81
- 143
6
votes
1 answer
Boosting the runtime of NumPy Code with NumExpr: An analysis
Since NumPy doesn't make use of multiple cores, I'm learning to speed up NumPy code with NumExpr since it has very good support for multithreading. Below is an example that I'm working with:
# input array to work with
x = np.linspace(-1, 1, 1e7)
#…

kmario23
- 57,311
- 13
- 161
- 150
6
votes
1 answer
Number of ways to write n as sum of k numbers with restrictions on each part
Title says it all.
I need to split n as sum of k parts where each part ki should be in the range of
1 <= ki <= ri for given array r.
for example -
n = 4, k = 3 and r = [2, 2, 1]
ans = 2
#[2, 1, 1], [1, 2, 1]
Order matters. (2, 1, 1) and (1, 2, 1)…

Atul
- 546
- 4
- 16
6
votes
1 answer
How to represent a binary field in programming language?
I am working on my project of Elliptic Curve Cryptography which requires programming on binary fields. It includes basic operations like addition, multiplication, inversion etc w.r.t. an irreducible binary polynomial.
I am searching for a way by…

Gaurav
- 398
- 8
- 23
6
votes
3 answers
Is my subset sum algorithm of polynomial time?
I came up with a new algorithm to solve the subset sum problem, and I think it's in polynomial time. Tell me I'm either wrong or a total genius.
Quick starter facts:
Subset sum problem is an NP-complete problem. Solving it in polynomial time means…

Puppy
- 144,682
- 38
- 256
- 465
6
votes
2 answers
SymPy cannot solve polynomial equation of 4th order
I have an polynomial equation of 4th order and I need to find all roots.
Simple example:
from sympy import (Symbol,solve,I)
a=4+5*I; b=3+7*I; c=12-56*I; d=33+56*I; e=345-67*I; x=Symbol('x')
eq=a*x**4 + b*x**3 + c*x**2 + d*x +e
solve(eq,x)
If…

K4stan
- 61
- 4
6
votes
1 answer
Python multiplicative inverse in GF(2) finite field
These 2 functions perform Extended Euclidean Algorithm, and then find the multiplicative inverse. The order seems right, but it's not coming back with what I'm expecting as per this tool from U of Sydney http://magma.maths.usyd.edu.au/calc/ and…

stackuser
- 869
- 16
- 34