2
$\begingroup$

I have an expression of the form $a\,x^3 + b\,x^2 + c\,x$ in my answer. I want to avoid those terms in my answer of order 1, but want to keep those of order > 1 in $x$. Can you suggest how to do in Mathematica 8?

$\endgroup$
1
  • 1
    $\begingroup$ Can we see the actual Mathematica expression from which you want to delete the terms of order < 2? Post the code by editing your question, not by making a comment. $\endgroup$
    – m_goldberg
    Sep 24, 2015 at 11:20

2 Answers 2

6
$\begingroup$

You don't say explicitly how you want to handle terms of order zero. Assuming that these are also to be discarded

expr = a x^3 + b x^2 + c x + d;

minOrder = 2;
coefList = CoefficientList[expr, x];
lenCoefList = Length[coefList];

Expand[(Expand[x*expr] /. ((x^n_ /; n > minOrder) -> $t^n) /. {x -> 0, $t -> 
      x})/x]

(*  b x^2 + a x^3  *)

Subtract @@ ((Series[expr, {x, 0, # - 1}] // Normal) & /@ {lenCoefList, 
    minOrder})

(*  b x^2 + a x^3  *)

ReplacePart[coefList,
  Thread[Range[minOrder] -> 0]].x^Range[0, lenCoefList - 1]

(*  b x^2 + a x^3  *)

Nest[Integrate[#, x] &, D[expr, {x, minOrder}], minOrder]

(*  b x^2 + a x^3  *)

EDIT:

To include the constant term, add Coefficient[expr, x, 0] to any other solution. This will work whether this coefficient is symbolic, numeric, or any combination.

$\endgroup$
2
  • 1
    $\begingroup$ I like the differentiate-integrate one. $\endgroup$
    – march
    Sep 24, 2015 at 16:59
  • $\begingroup$ I want to neglect only "cx" term...other constants in x are remain as it is... $\endgroup$ Sep 25, 2015 at 12:14
1
$\begingroup$
Normal@Series[your expression,{x,0,1}]
$\endgroup$
3
  • $\begingroup$ No no dear, I want to neglect that part not to collect them. This can be same as "Collect[%,{x}]"....Have any idea...Or I may be wrong ? what does {x,0,1} represents, one by one please... $\endgroup$ Sep 24, 2015 at 11:37
  • 1
    $\begingroup$ You could use Series this way: Normal@Series[a x^3 + b x^2 + c x + d /. x -> 1/x, {x, 0, -2}] /. x -> 1/x $\endgroup$
    – march
    Sep 24, 2015 at 17:05
  • $\begingroup$ Hi Yohbs,Thank you somuch $\endgroup$ Oct 2, 2015 at 9:15

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.