# Error in polynomial interpolation

I have edited this question to insist on what goes wrong

The following code ends with an indetermined parameter.

```
# Polynomial interpolation
# Passing the matrix
A = Matrix([[0,0],[0.5,0.25],[0.6,0.36],[2,4]])
var('a0, a1, a2, a3, a4')
B =[[A[i][1], a3*A[i][0]^3+ a2*A[i][0]^2+ a1*A[i][0]+ a0] for i in range(0,4)]
C=[[(B[i][0]-B[i][1])^2] for i in range(0,4)]
# sum of the square of errors
ssr=sum(C[i][0] for i in range(4))
# First order condition of optimality
ssr_a0=ssr.diff(a0)
ssr_a1=ssr.diff(a1)
ssr_a2=ssr.diff(a2)
ssr_a3=ssr.diff(a3)
ssr_a4=ssr.diff(a4)
# solution
sol=solve([ssr_a0==0,ssr_a1==0,ssr_a2==0,ssr_a3==0,ssr_a4==0], a0, a1, a2, a3, a4, solution_dict=True)
sol
```

The proposed solution being `[{a0: 0, a1: 0, a2: 1, a3: 0, a4: r3}]`

.

But the `ssr_ai`

$i = 0,\ldots, 3$ are all linear. So `sol`

should gives the same result that the following code

```
C=matrix([[8, 6.2, 9.22, 16.682], [6.2, 9.22,16.68,32.3842],[9.22,16.682,32.3842,64.21802],[16.68,32.3842,64.21802,128.124562]])
b=vector([9.22,16.68,32.3842,64.21902])
C.solve_right(b)
```

So why it is not the case ? (There is one and only one solution)

This lead to a second question : for the `ssr_ai`

how can I select the parameters to construct the `C`

matrix and
the `b`

vector not by hand as I have been obliged to do ?

Please add what are your expectations. Deciphering the code allows to understand the expected result, but not what is in your mind.

I should obtain a value for a0, a1, a3, and a4. So what is this result

`a4 : r3`

? What means r3 ? I already encounter such a result but I have forgoten how to resolve it.`r3`

is a parameter in the space of solution. In the documentation of`solve`

, you can see this example: "If there is a parameter in the answer, that will show up as a new variable. In the following example, "r1" is an arbitrary constant (because of the "r")":Thanks Sebastien for your comment. But this is weird. My system is linear so either there is no solution either there is one. I have tried to substitute

`find_root()`

to`solve`

but I suspect that it is only programmed to solve one variable equation. The solution would be to write the system in matrix notation but I do not know how to select the parameters to wtrite a matrix."

But this is weird. My system is linear so either there is no solution either there is one." This is not true as a system of linear equations can have 0, 1 or an infinity of solutions. See the example in my previous comment.