# 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 interesting to see how much smaller the solution could have been.

# Challenge

The input is a list of integers separated by a comma. The output is simply the equation that generates that sequence. The exact output of the equation is up to you i.e. no spaces are required between terms of the polynomial but it has to be human readable. The equation has to be expressed with the variable x. The first integer in the supplied sequence will correspond with x = 1, the second integer supplied would be x = 2 etc.

i.e.

x^2

would result in the sequence

1,4,9,16 NOT 0,1,4,9

Input:

5,14,27,44

Output:

2x^2 + 3x

# Edit

I marked the questions as duplicate, thanks for the head up.

• "it has to be human readable" is very subjective. Can you please elaborate on what you mean? Commented Apr 15, 2018 at 11:46
• @EriktheOutgolfer as a human, I don't mind reading a polynomial in list of coefficients format
– Angs
Commented Apr 15, 2018 at 11:49
• Duplicates: this and with less restrictive I/O this. I don't think just supplying the vector [1..n] adds much to the existing challenges. Commented Apr 15, 2018 at 11:53
• Now it's linked three times.. @ASCII-only: You should probably answer the other one and not this one if you think this is a duplicate.. Commented Apr 15, 2018 at 12:00
• And have anyone mentioned that? Welcome to PPCG! Next time you can use the sandbox for proposed challenges. (note that because of lack of people visiting the sandbox it takes a while to get feedback) Commented Apr 15, 2018 at 12:09

# Pari/GP, 28 bytes

l->polinterpolate([1..#l],l)


Try it online!

# Wolfram Language (Mathematica), 30 bytes

InterpolatingPolynomial[##,x]&


Try it online!

• Not to mention that this does not use infix notation. :/ Commented Apr 15, 2018 at 12:04
• @user202729 does it need to? Commented Apr 15, 2018 at 12:40