4

Unexpected application of cosines

 1 year ago
source link: https://codeforces.com/blog/entry/113803
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Hi everyone!

This blog is inspired by some contestant solutions to 104234F - Palindromic Polynomial. In short, problem asks you to find a polynomial such that for several given pairs , and the coefficients of read the same left-to-right and right-to-left (i.e., they form a palindrome). The intended solution utilizes the fact that for such polynomial, it always holds that

as is exactly the polynomial with reversed coefficients (assuming the degree is ).

Representing palindromic polynomials with polynomials in

Several solutions from contestants, however, relied on a different criterion for . Rather than using the identity above, participants found out that palindromic polynomials can always be represented as

when its degree is even, or as

when its degree is odd. In both cases, is a polynomial of degree . This representation allows for much simpler solution, but in this blog we will talk about why it exists in the first place, rather than how to use it to solve the problem.

Thanks to ecnerwala for explaining me this approach in more detail!

Getting rid of odd degrees

First things first, we should notice that a palindromic polynomial of odd degree always has a root , as it is an alternating sum of the polynomial's coefficients, and coefficients from the right half go into this sum with different sign from corresponding coefficients in the left half. Then, dividing by we get a palindromic polynomial of degree instead of .

This allows us to focus on the polynomials of even degree.

Representing polynomials of even degrees with

First of all we may notice that palindromic polynomials of even degree can always be represented as

for some sequence which is easily derived from the coefficients of . Now we should show that the sum

can be rewritten as

with some sequence .

Changing basis from to

Consider the sequence of Laurent polynomials (i.e. polynomials, in which negative degrees are allowed)

and another sequence of Laurent polynomials

As it turns out, these two sequences have the same linear span. What it practically means, is that every element of may be represented as a finite linear combination of the elements of , and vice versa. It is somewhat trivial in one direction:

With some special consideration for even , as the middle coefficient should be additionally divided by . You can represent it with lower triangular matrix with on the diagonal (except for the first row where it's ), which would mean that the matrix is invertible and there is, indeed, the representation for in terms of as well.

But what about cosines?

We will need a bit of complex numbers magic here. The explanation above, while technically correct, doesn't really shed any light on why it is true at all. To better understand it, consider the substitution , then one can use the explicit formula for :

and notice that

Then, it is a well known fact that can be represented in terms of . To prove it, consider the identity

then on one hand

on the other hand

Now, we're only interested in the real part of the said expression, hence the one with even . Using , we get

Hence, if we define

we can see that . The sequence of polynomials defined in such way is also known as Chebyshev polynomials. In the context of our problem, it would mean that

meaning that the desired transition could be expressed as


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK