Questions tagged [polynomials]

For challenges involving polynomials, mathematical expressions that consist of variables and coefficients.

Filter by
Sorted by
Tagged with
7 votes
5 answers
474 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 ...
bsoelch's user avatar
  • 4,723
19 votes
14 answers
2k 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) = \...
alephalpha's user avatar
  • 45.6k
15 votes
7 answers
1k 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 ...
bsoelch's user avatar
  • 4,723
14 votes
14 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 ...
bsoelch's user avatar
  • 4,723
14 votes
13 answers
1k 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 ...
alephalpha's user avatar
  • 45.6k
12 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 ...
AndrovT's user avatar
  • 2,786
10 votes
10 answers
454 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 ...
alephalpha's user avatar
  • 45.6k
18 votes
16 answers
1k 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 ...
alephalpha's user avatar
  • 45.6k
6 votes
2 answers
373 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 ...
DialFrost's user avatar
  • 5,035
13 votes
7 answers
972 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 ...
alephalpha's user avatar
  • 45.6k
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) ...
alephalpha's user avatar
  • 45.6k
7 votes
2 answers
283 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 ...
Shieru Asakoto's user avatar
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\$ ...
alephalpha's user avatar
  • 45.6k
12 votes
9 answers
803 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 ...
alephalpha's user avatar
  • 45.6k
4 votes
3 answers
226 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 ...
caird coinheringaahin g's user avatar
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}$$ ...
caird coinheringaahin g's user avatar
9 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 \$...
user avatar
19 votes
3 answers
387 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 ...
Peter Kagey's user avatar
  • 8,649
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(...
Bubbler's user avatar
  • 73.1k
18 votes
1 answer
667 views

Golfing Expressions

We can write mathematical expressions using the standard math operators (,),+,...
Jay's user avatar
  • 281
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 ...
Rydwolf Programs's user avatar
13 votes
12 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 + ...
VJZ's user avatar
  • 479
12 votes
18 answers
1k 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 ...
caird coinheringaahin g's user avatar
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)(...
caird coinheringaahin g's user avatar
-2 votes
1 answer
145 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 ...
Nip Dip's user avatar
  • 417
26 votes
19 answers
3k 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 \$...
golf69's user avatar
  • 2,049
15 votes
14 answers
1k 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 ...
RGS's user avatar
  • 14k
20 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 ...
Zach Hunter's user avatar
9 votes
5 answers
551 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 ...
RGS's user avatar
  • 14k
17 votes
18 answers
2k 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 ...
RGS's user avatar
  • 14k
17 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 \$...
nwellnhof's user avatar
  • 10.5k
11 votes
2 answers
949 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., "...
Dustin G. Mixon's user avatar
29 votes
22 answers
3k 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 ...
Shieru Asakoto's user avatar
11 votes
2 answers
460 views

​Plane​ ​Blow​up​

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 ...
flawr's user avatar
  • 43.6k
21 votes
4 answers
510 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 ...
pasbi's user avatar
  • 451
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 ...
Damien's user avatar
  • 2,447
29 votes
26 answers
3k 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 ...
flawr's user avatar
  • 43.6k
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 ...
Beefster's user avatar
  • 9,861
13 votes
7 answers
1k 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 ...
flawr's user avatar
  • 43.6k
12 votes
6 answers
561 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 ...
Hood's user avatar
  • 2,085
18 votes
19 answers
4k 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 ...
Luis felipe De jesus Munoz's user avatar
11 votes
3 answers
493 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, -...
l4m2's user avatar
  • 19.1k
3 votes
2 answers
88 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 ...
Joris Guex's user avatar
38 votes
23 answers
3k views

Pretty Print Polynomials

Introduction Humans are a remarkable species, but we can be very awkward to understand sometimes—especially for computers. In particular, we seem to like writing polynomials in a very ...
Oisín Moran's user avatar
15 votes
16 answers
895 views

Euler-Poincaré-Characteristic of Polyhedra

Given a triangulation of the surface of a polyhedron p, calculate its Euler-Poincaré-Characteristic χ(p) = V-E+F, where ...
flawr's user avatar
  • 43.6k
12 votes
2 answers
414 views

Decompose Polynomials

Given an integral polynomial of degree strictly greater than one, completely decompose it into a composition of integral polynomials of degree strictly greater than one. Details An integral ...
flawr's user avatar
  • 43.6k
8 votes
6 answers
358 views

Simplify and Take Partial Derivative to a Polynomial String

Introduction Write a program to calculate the partial derivative of a polynomial (possibly multivariate) with respect to a variable. Challenge Derivatives are very important mathematical tools that ...
Weijun Zhou's user avatar
  • 3,627
14 votes
11 answers
4k views

Find The Local Maxima And Minima

Definition The maxima and minima of a given function are the largest and smallest values of the function either within a given range or otherwise within the entire domain of the function. Challenge ...
Manish Kundu's user avatar
  • 5,250
20 votes
17 answers
2k views

Find Integral Roots of A Polynomial

Challenge The challenge is to write a program that takes the coefficients of any n-degree polynomial equation as input and returns the integral values of x for which the equation holds true. The ...
Manish Kundu's user avatar
  • 5,250
7 votes
2 answers
341 views

Rational Polynomial Interpolation

Explanation In this task you'll be given a set of N points (x1,y1),…,(xN,yN) with distinct xi values and your task is to interpolate a polynomial through these points. If you know what Lagrange ...
ბიმო's user avatar
  • 16.7k