1 | initial version |

`list`

method and the optional parameter `sparse`

Short answer: use the `list`

method.

Longer answer: use `f.coefficients?`

to get the documentation.

This reveals an optional parameter `sparse`

which
decides whether zero coefficients are included.

Having defined a polynomial:

```
sage: R.<x> = QQ[]
sage: f = x^4 - x^2 + 1
```

we get the list of coefficients:

```
sage: A = f.list()
sage: A
[1, 0, -1, 0, 1]
```

Then `A[i]`

is the coefficient of `x^i`

in `f`

.

Note that we can also get the coefficient of `x^i`

directly using `f[i]`

.

Try this to explore further.

```
sage: f.coefficients?
sage: f.coefficients()
sage: f.coefficients(sparse=True)
sage: f.coefficients(sparse=False)
```

2 | No.2 Revision |

`list`

method and the optional parameter `sparse`

Short answer: use the `list`

method.

Longer answer: use `f.coefficients?`

to get the documentation.

This reveals an optional parameter `sparse`

which
decides whether zero coefficients are included.

Having defined a polynomial:

```
sage: R.<x> = QQ[]
sage: f = x^4 - x^2 + 1
```

we get the list of coefficients:

```
sage: A = f.list()
sage: A
[1, 0, -1, 0, 1]
```

Then `A[i]`

is the coefficient of `x^i`

in `f`

.

~~Note that ~~**Important note**: we can ~~also ~~get the coefficient of `x^i`

in `f`

directly using `f[i]`

~~.~~

`f`

: ```
sage: f[0]
1
sage: f[2]
-1
sage: f[9]
0
```

Try this to explore further.

```
sage: f.coefficients?
sage: f.coefficients()
sage: f.coefficients(sparse=True)
sage: f.coefficients(sparse=False)
```

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.