How to neglect specific terms in an expression?

In summary: This means that Plus has to be given a list of expressions that are all of the same structure, and g in the above example does not have to be a variable.
  • #1
Robin04
260
16
I've just started using Mathematica and I'm still trying to get used to how things are properly done with it. I tried to do a calculation (this one: https://www.physicsforums.com/threads/lagrangian-of-a-driven-pendulum-landau-problem.965714/) and I had to neglect some terms in an expression.

Is there any tool in Mathematica where I can specify some condition like 'term has explicit time dependence' and it automatically throws out the terms that meet that condition? Or how is this done with these calculations? For now, I just subtracted it from the variable manually but I suppose there's some more elegant way of doing this.

EDIT: As the problem above has been solved I must add that I actually don't need to neglect terms there, because they fall out on their own, but I'm still curious if there are such tools in Mathematica.
 
Last edited:
Physics news on Phys.org
  • #2
Will something like this

Select[a*t*Cos+c*Sin[t]+E^(t-1)+d*Cos+f-1,FreeQ[t]]

which returns this

-1 + f + d*Cos

correctly handle all the cases that you are considering?

You must be very careful with pattern matching methods like this and check that they correctly do exactly what you are expecting in every single case.

Notice for example

Select[a*t*Cos+(c+t)*Sin[g]+E^(t-1)+d*Cos+f-1,FreeQ[t]]

"incorrectly" returns

-1 + f + d*Cos

instead of

-1 + f + d*Cos + c*Sin[g]

if you are expecting this to understand that you intend to eliminate all and only those terms which do not have explicit time dependence.

What is happening, but not shown, is that Plus has a list of arguments, Select is going through that list of arguments at a time, if there is no t in an argument then Select is returning that, otherwise it is discarding that. (c+t)*Sin[g] is one of the arguments in that list. c*Sin[g]+t*Sin[g] is not one of the arguments in that list.

Mathematica does "structural pattern matching", it is simply trying to match the literal structure of expressions, not "semantic pattern matching" or trying to match the meaning of the expression.
 

1. How do I identify which terms to neglect in an expression?

To neglect specific terms in an expression, you need to first identify the terms that have very small coefficients or exponents compared to the other terms. These terms can be considered negligible and can be neglected without significantly affecting the overall value of the expression.

2. Can I just eliminate all the variables with small coefficients or exponents?

No, not all terms with small coefficients or exponents can be neglected. Some terms may have a small coefficient but a large exponent, which can still have a significant impact on the overall value of the expression. It is important to carefully analyze each term before neglecting it.

3. Is it necessary to neglect terms in an expression?

Neglecting terms in an expression is not always necessary. It depends on the purpose of the expression and the level of accuracy required. For some calculations, neglecting specific terms may not make a significant difference, while for others it may be crucial.

4. Are there any specific rules for neglecting terms in an expression?

There are no set rules for neglecting terms in an expression. It is a subjective process that depends on the individual's judgment and the context of the problem. However, it is important to ensure that the neglected terms have a minimal impact on the overall value of the expression.

5. Can neglecting specific terms lead to incorrect results?

If done carefully and with proper consideration, neglecting specific terms in an expression should not lead to incorrect results. However, it is important to double-check the calculations and consider the level of accuracy required to ensure the results are as accurate as possible.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • Introductory Physics Homework Help
Replies
4
Views
831
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Precalculus Mathematics Homework Help
Replies
7
Views
944
  • Calculus and Beyond Homework Help
Replies
6
Views
561
  • Calculus and Beyond Homework Help
Replies
8
Views
176
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Replies
13
Views
1K
  • General Math
Replies
2
Views
1K
Back
Top