1 | initial version |

I am not sure i understand your question. Given a list `mydata`

of pairs `(point, value)`

, you want to find a polynomial `P`

with integer coefficients such that `P(point) == value`

for each element of `mydata`

?

If this is your question, you can do it with polynomials with coefficients on `RationalField`

:

```
sage: mydata = [(0,0),(2,1),(4,6)]
sage: R = PolynomialRing(QQ, 'x')
sage: P = R.lagrange_polynomial(mydata); P
1/2*x^2 - 1/2*x
```

This will not work if you replace `QQ`

by `ZZ`

, because Lagrange interpolation needs to make divisions. Note also that it is not sufficient to require that the pairs `(point, value)`

are integers to ensure that `P`

will have integer coefficients. For example, there is no polynomial $P$ with integer coefficients such that $P(0) = 0$ and $P(2) = 1$.

Now, if you want to *approximate* (not interpolate) you data with polynomials, you need to be more precise about the measure of the quality of the approximation. For example, if you are looking for a leas square approximation, you can hage a look at polyfit (but the coefficients will be floating points).

2 | No.2 Revision |

I am not sure i understand your question. Given a list `mydata`

of pairs `(point, value)`

, you want to find a polynomial `P`

with integer coefficients such that `P(point) == value`

for each element of `mydata`

?

If this is your question, you can do it with polynomials with coefficients on `RationalField`

:

```
sage: mydata = [(0,0),(2,1),(4,6)]
sage: R = PolynomialRing(QQ, 'x')
sage: P = R.lagrange_polynomial(mydata); P
1/2*x^2 - 1/2*x
```

This will not work if you replace `QQ`

by `ZZ`

, because Lagrange interpolation needs to make divisions. Note also that it is not sufficient to require that the pairs `(point, value)`

are integers to ensure that `P`

will have integer coefficients. For example, there is no polynomial $P$ with integer coefficients such that $P(0) = 0$ and $P(2) = ~~1$.~~1$ (the first condition implies that the variable $X$ divides $P$, which implies that $P(2)$ is even).

Now, if you want to *approximate* (not interpolate) you data with polynomials, you need to be more precise about the measure of the quality of the approximation. For example, if you are looking for a leas square approximation, you can hage a look at polyfit (but the coefficients will be floating points).

3 | No.3 Revision |

I am not sure i understand your question. Given a list `mydata`

of pairs `(point, value)`

, you want to find a polynomial `P`

with integer coefficients such that `P(point) == value`

for each element of `mydata`

?

If this is your question, you can do it with polynomials with coefficients on `RationalField`

:

```
sage: mydata = [(0,0),(2,1),(4,6)]
sage: R = PolynomialRing(QQ, 'x')
sage: P = R.lagrange_polynomial(mydata); P
1/2*x^2 - 1/2*x
```

This will not work if you replace `QQ`

by `ZZ`

, because Lagrange interpolation needs to make divisions. Note also that it is not sufficient to require that the pairs `(point, value)`

are integers to ensure that `P`

will have integer coefficients. For example, there is no polynomial $P$ with integer coefficients such that $P(0) = 0$ and $P(2) = 1$ ~~(the ~~(otherwise the first condition implies that the variable $X$ divides $P$, which implies that $P(2)$ is even).

Now, if you want to *approximate* (not interpolate) you data with polynomials, you need to be more precise about the measure of the quality of the approximation. For example, if you are looking for a leas square approximation, you can hage a look at polyfit (but the coefficients will be floating points).

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.