2
$\begingroup$

I have a function of $f(x,y)$, where $x,y$ are very small numbers. I want to series expand it to the $3$rd power. However I don't want the terms such that $x^2y^2$, $xy^3$ etc. because I would reckon this as $4$th power. How do I tell mathematica to do this.

As a concrete example, consider the following input:

ClearAll["Global`*"]
δE = 
  x^2 (Sqrt[1 + x^2] - 
      x) (2 - (Sqrt[1 + x^2] - x)/(Sqrt[1 + y^2] - y)) + 
   2/3 ((Sqrt[1 + y^2]^3 - y^3) - (Sqrt[1 + x^2]^3 - x^3)) - 
   y^2 (Sqrt[1 + y^2] - y);
Series[δE, {x, 0, 3}, {y, 0, 3}] // Simplify

In the output, I need only the terms $y^3/3-yx^2+2x^3/3$ kept.

$\endgroup$
8
  • $\begingroup$ Try // Normal // Simplify $\endgroup$
    – user9660
    Oct 28, 2015 at 15:16
  • $\begingroup$ @Lou This won't eliminate the higher orders. $\endgroup$ Oct 28, 2015 at 15:17
  • 1
    $\begingroup$ Well then, this should work: Expand[Fold[(#1.{x, y} + #2) &, Take[CoefficientArrays[Normal[series], {x, y}], {4, 1, -1}]]]. $\endgroup$ Oct 28, 2015 at 15:21
  • 4
    $\begingroup$ Redefine x -> x t and y-> y t and use Series with regard to t upto third order. After taking Normal, you can then replace t -> 1 again. $\endgroup$
    – Sungmin
    Oct 28, 2015 at 15:23
  • 1
    $\begingroup$ Have a look How to neglect higher power terms in a polynomial expression $\endgroup$
    – user9660
    Oct 28, 2015 at 15:28

3 Answers 3

2
$\begingroup$

Bound to be a better way, but this will do it

Sum[
 UnitStep[3 - (n + m)] SeriesCoefficient[δE, {x, 0, n}, {y, 0, 
    m}] x^n y^m, {n, 0, 3}, {m, 0, 3}]
(* (2 x^3)/3 - x^2 y + y^3/3 *)
$\endgroup$
3
$\begingroup$

As pointed out in the comment by @Sungmin. A very simple way to do this is following:

δEt = 
  Series[δE /. {x -> x t, y -> y t}, {t, 0, 3}] // Normal;
δEt /. {t -> 1}
$\endgroup$
0
$\begingroup$
taylor = (vars - point).# &;
init := D[f[vars], {vars, j}] /. Thread[vars -> point];
taylorPolynom[m_] := Sum[1/j! Nest[taylor, init, j], {j, 0, m}]

vars = {x, y};
point = {0, 0};

f[vars_] = x^2 (Sqrt[1 + x^2] -x) (2 - (Sqrt[1 + x^2] - x)/(Sqrt[1 + y^2] - y)) + 2/3 ((Sqrt[1 + y^2]^3 - y^3) - (Sqrt[1 + x^2]^3 - x^3)) - 
   y^2 (Sqrt[1 + y^2] - y);

taylorPolynom[3] // Expand
(2 x^3)/3 - x^2 y + y^3/3
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.