[Mathematica] Sorting polynomial terms

In summary, the conversation discusses sorting a Series object so that the terms are in increasing powers of the exponent. The code provided uses the Normal function and replaces variables to produce a series with increasing powers of 1/z. One member suggests using TraditionalForm to achieve the desired result.
  • #1
jackmell
1,807
54
Hi. Can someone explain to me how to sort a Series so that the terms are in increasing powers of the exponent? For example the code:

myseries = Normal[ Series[Sqrt[1 - w], {w, 0, 5}]] /. w -> 1/z

produces
[tex]1-\frac{7}{256 z^5}-\frac{5}{128 z^4}-\frac{1}{16 z^3}-\frac{1}{8 z^2}-\frac{1}{2 z}[/tex]

I would like them to be

[tex]1-\frac{1}{2z}-\frac{1}{8z^2}-\cdots[/tex]

Thanks,
Jack
 
Physics news on Phys.org
  • #2
You can make a series around [itex]\infty[/itex]. I don't know if that will appear sorted the way you want.
 
  • #3
Sorry. I'm afraid I'm having some problems with this. The series is being reported by Mathematica in increasing powers of 1/z like it should and like I'd want it to be.

Thanks Hurky for suggesting expanding it around infinity which is what I'd want for the function outside the unit circle.
 
Last edited:
  • #4
myseries = Normal[Series[Sqrt[1 - w], {w, 0, 5}]] /. w -> 1/z;
TraditionalForm[myseries]
 
  • #5
Series[Sqrt[1 - w] /. w -> 1/z, {z, \[Infinity], 5}]
 
  • #6
Ok, thanks guys. TraditionalForm does what I wanted.
 

1. How can I sort polynomial terms in Mathematica?

To sort polynomial terms in Mathematica, you can use the Sort function and specify the variable you want to sort by. For example, if you have a polynomial x^3 + x^2 + x, you can use Sort[x^3 + x^2 + x, x] to sort the terms in ascending order by the variable x.

2. Can Mathematica sort polynomial terms by degree?

Yes, Mathematica can sort polynomial terms by degree using the Exponent function. This function returns the degree of a polynomial term, which can then be used in the Sort function. For example, Sort[x^3 + x^2 + x, Exponent[#1, x] &] will sort the terms in descending order by degree.

3. Is there a way to sort polynomial terms in descending order by coefficient?

Yes, you can use the Coefficient function to extract the coefficients of polynomial terms, and then use them in the Sort function. For example, Sort[x^3 + 2x^2 + 3x + 1, Coefficient[#1, x] &] will sort the terms in descending order by coefficient.

4. How do I sort polynomial terms by multiple variables in Mathematica?

To sort polynomial terms by multiple variables in Mathematica, you can use the Sort function and specify the variables in the order you want to sort by. For example, Sort[x^2y + xy^2 + y^2 + x + y, {x, y}] will sort the terms first by x and then by y.

5. Can Mathematica sort polynomial terms in a specific order?

Yes, you can use the Order function to specify the desired order for sorting polynomial terms. For example, Sort[x^2 + x + 1, Order[{x^2, x, 1}, {x^2, x, 1}, {x, 1}] will sort the terms first by x^2, then by x, and finally by 1.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
6
Views
739
Replies
6
Views
1K
  • Calculus and Beyond Homework Help
Replies
12
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • Calculus and Beyond Homework Help
Replies
3
Views
482
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • Calculus and Beyond Homework Help
Replies
2
Views
490
  • Calculus and Beyond Homework Help
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
257
Back
Top