Ask Your Question
1

How do we filter the degree of polynomials?

asked 3 years ago

Sam gravatar image

I have an output of symbolic expressions.. Is there a way to filter out the outcome using the 'IF' statement that only outputs the polynomial of degree 1 or 2

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 3 years ago

tmonteil gravatar image

You can use list comprehension and the fact that symbolic expressions have a degree method as follows:

sage: L = [3*x+2, 4*x^3, x+x^2, SR(2)]
sage: [i for i in L if 1 <= i.degree(x) <= 2]
[3*x + 2, x^2 + x]
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 3 years ago

Seen: 221 times

Last updated: Oct 15 '21