Ask Your Question
1

How do we filter the degree of polynomials?

asked 2021-10-15 06:00:18 +0100

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-10-15 20:29:33 +0100

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]
edit flag offensive delete link more

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: 2021-10-15 06:00:18 +0100

Seen: 210 times

Last updated: Oct 15 '21