Questions tagged [polynomials]
For challenges involving polynomials, mathematical expressions that consist of variables and coefficients.
96 questions
12
votes
10
answers
733
views
Polynomial Basis Conversion
The most common way to represent a polynomial is writing it as a linear combination of monomials, i.e., powers of the variable. For example, the polynomial \$p(x) = x^3 + 2x^2 + x + 1\$ is a linear ...
5
votes
1
answer
333
views
Implement 2ˣ using the polynomial system
Your job is to implement \$2^x\$ using polynomials, such that in a way that for all integers \$x\$ and \$y\$,
$$\exists(v_0,v_1,\dots)[P_1(x,y,v_0,v_1,v_2,\cdots) = 0 \land P_2(x,y,v_0,v_1,v_2,\cdots)=...
17
votes
6
answers
875
views
Decompose a palindromic polynomial
A palindromic polynomial is a polynomial whose list of coefficients is a palindrome. For example, the polynomial \$p(x) = x^4 + 2x^3 + 3x^2 + 2x + 1\$ is palindromic because its coefficients are \$[1, ...
14
votes
7
answers
1k
views
Squaring the roots of a polynomial
In this challenge, you are given a polynomial \$p(x)\$, and you need to find a polynomial \$q(x)\$ whose roots are exactly the squares of the roots of \$p(x)\$ (counted with multiplicity). In other ...
7
votes
8
answers
426
views
Padé approximant of \$\exp(x)\$
In mathematics, a Padé approximant (Wikipedia, MathWorld) is the "best" approximation of a function by a rational function. For a function \$f(x)\$, the Padé approximant of order \$[m/n]\$ ...
14
votes
9
answers
1k
views
Sum of square roots (as an algebraic number)
An algebraic number is a number that is a root of a non-zero polynomial with integer coefficients. It is well-known that the sum of two algebraic numbers is algebraic. In particular, the sum of a list ...
10
votes
6
answers
658
views
Hermite interpolation
We already have a challenge for polynomial interpolation: given a list of points, output the coefficients of the polynomial that passes through them.
Hermite interpolation is a generalization of ...
7
votes
5
answers
607
views
Multiply multivariate polynomials
We already have a challenge about multiplying multiply single-variable polynomials. This challenge is about multiply two polynomials with multiple variables
Your task is given two multi-variable ...
19
votes
14
answers
3k
views
Rook Polynomials
In combinatorics, the rook polynomial \$R_{m,n}(x)\$ of a \$m \times n\$ chessboard is the generating function for the numbers of arrangements of non-attacking rooks. To be precise:
$$R_{m,n}(x) = \...
15
votes
7
answers
2k
views
Solve quadratic equations when 1+1=0
There already have been multiple challenges about carryless
multiplication, this challenge will work with the same calculation rules.
You task is given a quadratic polynomial ...
14
votes
15
answers
2k
views
Print all Polynomials
The set of all polynomials with integer coefficients is countable.
This means that there is a sequence that contains each polynomial with integer coefficients exactly once.
Your goal is it to write a ...
15
votes
14
answers
2k
views
Resultant of two polynomials
The resultant of two polynomials is a polynomial in their coefficients that is zero if and only if \$p\$ and \$q\$ have a common root. It is a useful tool for eliminating variables from systems of ...
13
votes
6
answers
1k
views
Approximate a root of an odd degree polynomial
Every odd degree polynomial has at least one real root. However this root does not have to be a rational number so your task is to output a sequence of rational numbers that approximates it.
Rules
...
10
votes
10
answers
570
views
CGAC2022 Day 3: \$n\$-dimensional Chocolate Pyramid
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
I've got an infinite supply of \$n\$-dimensional chocolate for some positive integer \$n\$. The shape of the ...
18
votes
16
answers
2k
views
Multiplicity of a root of a polynomial
Let \$p(x)\$ be a polynomial. We say \$a\$ is a root of multiplicity \$k\$ of \$p(x)\$, if there is another polynomial \$s(x)\$ such that \$p(x)=s(x)(x-a)^k\$ and \$s(a)\ne0\$.
For example, the ...
6
votes
2
answers
425
views
Partial Fractions
Given an input of a string, output the partial fraction in string form.
The partial fraction decomposition of a rational fraction of the form \$\frac{f(x)}{g(x)}\$, where \$f\$ and \$g\$ are ...
14
votes
7
answers
1k
views
Exponential transform of an integer sequence
The exponential generating function (e.g.f.) of a sequence \$a_n\$ is defined as the formal power series \$f(x) = \sum_{n=0}^{\infty} \frac{a_n}{n!} x^n\$.
When \$a_0 = 0\$, we can apply the ...
18
votes
16
answers
2k
views
Fibonacci polynomials
The Fibonacci polynomials are a polynomial sequence defined as:
\$F_0(x) = 0\$
\$F_1(x) = 1\$
\$F_n(x) = x F_{n-1}(x) + F_{n-2}(x)\$
The first few Fibonacci polynomials are:
\$F_0(x) = 0\$
\$F_1(x) ...
7
votes
2
answers
486
views
Find the Circle-Tangent Polynomials
Introduction
A circle-tangent polynomial is a polynomial of degree \$N\ge3\$ or above that is tangent to the unit circle from inside at all of its N-1 intersection points. The two tails that exits the ...
19
votes
10
answers
2k
views
Is this polynomial a square?
Given an integral polynomial \$p\$, determine if \$p\$ is a square of another integral polynomial.
An integral polynomial is a polynomial with only integers as coefficients.
For example, \$x^2+2x+1\$ ...
12
votes
9
answers
1k
views
Chromatic polynomial of a graph
Given a undirected graph \$G\$ and a integer \$k\$, how many \$k\$-coloring does the graph have?
Here by a \$k\$-coloring, we mean assigning one of the \$k\$ colors to each vertex of the graph, such ...
5
votes
3
answers
334
views
Order of an algebraic number
Consider some arbitrary polynomial with integer coefficients,
$$a_n x^n + a_{n-1}x^{n-1} + \cdots + a_1x + a_0 = 0$$
We'll assume that \$a_n \ne 0\$ and \$a_0 \ne 0\$. The solutions to this polynomial ...
17
votes
5
answers
1k
views
Are you a probabilist or a physicist?
Hermite polynomials refer to two sequences of polynomials:
The "probabilist's Hermite polynomials", given by
$${He}_n(x) = (-1)^n e ^ \frac {x^2} 2 \frac {d^n} {dx^n} e ^ {-\frac {x^2} 2}$$
...
10
votes
14
answers
1k
views
ASCII-Plot the equation
You are given a polynomial function, in the following format:
\$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$
where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$...
19
votes
3
answers
435
views
A multiple of n in every base!
In November 2019, Alon Ran published a particularly lovely sequence in the OEIS, A329126:
\$a(n)\$ is the lexicographically earliest string of digits which yields a multiple of \$n\$ when read in any ...
27
votes
7
answers
1k
views
Recover polynomial \$f(x)\$ from \$f^2(x)\$
Related: Calculate \$f^n(x)\$, Polynomialception
Challenge
Given a polynomial \$f(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_k x^k\$ of order \$k\$, we can compute its composition with itself \$f\left(f(...
19
votes
1
answer
740
views
Golfing Expressions
We can write mathematical expressions using the standard math operators (,),+,...
18
votes
18
answers
2k
views
Determine the degree of a polynomial
Background:
For this challenge, a polynomial looks like this:
$$P(x)=a_nx^n+a_{n-1}x^{n-1}+\dots+a_2x^2+a_1x+a_0$$
The degree, \$n\$, is the highest power \$x\$ is raised to. An example of a degree 7 ...
15
votes
14
answers
1k
views
Definite integral of polynomial functions
You will need to evaluate the definite integral (bounded by \$a\$ and \$b\$) of a certain polynomial function that takes the form of:
$$\int_a^b \left( k_n x^n + k_{n-1} x^{n-1} + \cdots + k_2x^2 + ...
12
votes
18
answers
2k
views
Polynomial Laplace transform
This is a repost of this challenge, intended to revamp it for looser I/O formats and updated rules
You are to write a program which takes an integer polynomial in \$t\$ as input and outputs the ...
23
votes
28
answers
3k
views
"Factorise" a quadratic [duplicate]
When learning to factorise quadratics in the form \$x^2 + ax + b\$, a common technique is to find two numbers, \$p, q\$ such that
$$pq = b \\
p + q = a$$
as, for such numbers, \$x^2 + ax + b = (x + p)(...
-4
votes
1
answer
184
views
The Perfect Polynomial [closed]
The coefficients of a perfect square polynomial can be calculated by the formula \$(ax)^2 + 2abx + b^2\$, where both a and b are integers. The objective of this challenge is to create a program that ...
26
votes
19
answers
4k
views
Laguerre Polynomials
Laguerre polynomials are nontrivial solutions to Laguerre's equation, a second-order linear differential equation: \$xy''+(1-x)y'+ny=0\$. For a given value of \$n\$, the solution, \$y\$, is named \$...
15
votes
14
answers
2k
views
Generating generating expressions for sequences
(yes, "generating generating" in the title is correct :) )
Context
In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the ...
21
votes
8
answers
1k
views
Counting Distinct Real Roots of Low-Degree Polynomials
Challenge: I want to know about the real roots of polynomials. As a pure mathematician, I care about the existence of such roots, rather than their numeric values.
The challenge is to write the ...
9
votes
5
answers
613
views
Computing a specific coefficient in a quotient of polynomials
Context
After "Computing a specific coefficient in a product of polynomials", asking you to compute a specific coefficient of polynomial multiplication, I wish to create a "mirror" challenge, asking ...
17
votes
18
answers
3k
views
Computing a specific coefficient in a product of polynomials
Generator functions
This gives the context for why this challenge came to life. Feel free to ignore.
Generator functions are a nice way of encoding the solution to a problem of combinatorics. You ...
18
votes
7
answers
2k
views
Define the finite field GF(9)
\$GF(9)\$ or \$GF(3^2)\$ is the smallest finite field whose order isn't a prime or a power of two. Finite fields of prime order aren't particurlarly interesting and there are already challenges for \$...
11
votes
2
answers
1k
views
Find the largest root of a polynomial with a neural network
The challenge
Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "...
29
votes
22
answers
4k
views
Calculate the Ultraradical
What is the Ultraradical?
The ultraradical, or the Bring radical, of a real number \$a\$ is defined as the only real root of the quintic equation \$x^5+x+a=0\$.
Here we use \$\text{UR}(\cdot)\$ to ...
11
votes
2
answers
497
views
Plane Blowup
The Blow-up is a powerful tool in algebraic geometry. It allows the removal of singularities from algebraic sets while preserving the rest of their structure.
If you're not familiar with any of that ...
22
votes
4
answers
642
views
Compute height of Bowl Pile
Bowl Pile Height
The goal of this puzzle is to compute the height of a stack of bowls.
A bowl is defined to be a radially symmetric device without thickness.
Its silhouette shape is an even ...
5
votes
2
answers
1k
views
Point-free madness
This challenge is about Haskell point-free style polynomial functions.
Although you don't need to know Haskell language to do this challenge, Haskellers might have an advantage here.
Point-free ...
29
votes
26
answers
4k
views
Fundamental Solution of the Pell Equation
Given some positive integer \$n\$ that is not a square, find the fundamental solution \$(x,y)\$ of the associated Pell equation
$$x^2 - n\cdot y^2 = 1$$
Details
The fundamental \$(x,y)\$ is a pair of ...
15
votes
14
answers
2k
views
Multiply Two Integer Polynomials
Your task is to take two single-variable integer polynomial expressions and multiply them into their unsimplified first-term-major left-to-right expansion (A.K.A. FOIL in the case of binomials). Do ...
13
votes
7
answers
2k
views
Ryley's Theorem
S. Ryley proved following theorem in 1825:
Every rational number can be expressed as a sum of three rational cubes.
Challenge
Given some rational number \$r \in \mathbb Q \$ find three rational ...
13
votes
8
answers
739
views
Multiply numerical polynomials
A numerical polynomial is a polynomial \$p\$ in one variable with rational coefficients such that for every integer \$i\$, \$p(i)\$ is also an integer. The numerical polynomials have a basis given by ...
18
votes
19
answers
5k
views
Evaluate polynomial expression string
Create a function which takes a polynomial equation, a value for x and returns the result of the operation.
Example: given ...
12
votes
3
answers
565
views
Polynomial -> Integrate
Given a polynomial in one variable with rational coefficients, output an equivalent expression containing only 1, variables, and definite integrals. For example, -...
3
votes
2
answers
133
views
Generate lowest degree polynomial from sequence [duplicate]
Introduction
A sequence of numbers is passed in as the input. The program has to generate the lowest degree polynomial possible. This was my first programming project in college and it would be ...