# Approximating giant polynomial expression

Suppose I have a giant polynomial expression analogous to

$$F=a_1xX^6+a_2x^2X^5+a_3x^3X^4+a_4x^4X^3+a_5x^5X^2+a_6x^6X$$

and it is true that $$X \gg x$$. Let it be enough for me to approximate this expression up to order $$(\frac{x}{X})^3$$, so that

$$F \approx a_1xX^6+a_2x^2X^5+a_3x^3X^4.$$

What is the cleanest way to do something like this? Bear in mind that the expression is not in the neat form of the first equation.

I suppose the most obvious way would be to write a list of terms after expanding the expression and cut out every term of the form $$a_ix^{i_x}X^{i_X}$$ such that $$i_x\geq O$$ (where $$O$$ is the order of approximation) and $$N-i_X\geq O$$, but I wonder if there isn't a smarter way.

• Is your actual polynomial homogeneous, like the one shown? A test case (in code) might help get folks to participate (e.g. Expand@Fold[FromDigits, SparseArray[{i_, j_} /; i + j == 7 :> RandomInteger[{1, 9}], {7, 7}], {x, y}]) – Michael E2 Jun 13 at 12:59

To make the relationship between $$x$$ and $$X$$ explicit, in the sense that we want $$|x/X|\ll1$$ instead of simply assuming that $$x$$ is small, we can set $$z=x/X$$ and series-expand for small $$z$$:

F = Sum[a[i] * x^i * X^(7 - i), {i, 6}];

Series[F /. x -> z*X, {z, 0, 3}]
(*    a X^7 z + a X^7 z^2 + a X^7 z^3 + O[z]^4    *)


In practice this is pretty much the same as what @MichaelSeifert suggests, but behind the scenes it is more explicit about the relationship between $$x$$ and $$X$$. In more complicated situations this may make a difference.

If you only need the terms up to a given order in one of the polynomial's variables, you could just use Series and Normal:

Series[expr, {x, 0, 3}]
Normal[%]


Series returns a result in terms of SeriesData objects, which include O[x^n] terms that allow Mathematica to keep track of the validity of the approximation. Normal takes a SeriesData object and returns just the explicit polynomial terms.