Small quantities in mathematica

In summary, the conversation discusses the use of the "Series" function in Mathematica to automatically remove terms of order epsilon^2 and higher in a calculation involving a small parameter, as well as the use of pattern matching to simplify expressions involving small parameters. The conversation also mentions the importance of carefully checking results when using pattern matching.
  • #1
JohnSimpson
92
0
"Small" quantities in mathematica

Hi, I'm doing a calculation in which I have a small parameter [tex]\epsilon[/tex] floating around, and I want to automatically remove terms of order [tex]\epsilon^2[/tex] and higher. Is this possible to do?
 
Physics news on Phys.org
  • #2


Sure! Just use:

Series[Expression,{epsilon,0,1}]. this will expand Expression in a power series about epsilon=0, and only keep terms up to order 1. If you use Normal[Series[Expression,{epsilon,0,1}]], that will get rid of the annoying O(epsilon^2) terms floating around.
 
  • #3


Thanks! One more question. Let's say I had something like

[tex]
\left(
\begin{array}{cc}
-2 \varepsilon & 1-\varepsilon \\
-1+\varepsilon & -1+2 \varepsilon
\end{array}
\right)
[/tex]

How could I retain the multiplicative terms but ditch the additive terms, so that this simplifies to

[tex]
\left(
\begin{array}{cc}
-2 \varepsilon & 1 \\
-1 & -1
\end{array}
\right)
[/tex]
 
  • #4


What you're asking doesn't make sense to me. In the upper left you kept the multiplicative term (2 epsilon) and not the additive term (0), while in the upper right you kept the additive term (1) and not the multiplicative term (- epsilon). What do you want to do exactly? If you can specify precisely what you want to do, we can program the computer to do it.
 
  • #5


Right, sorry. What I want to do is say that epsilon is small compared to some other number, in this case 1, but to keep epsilon finite.

[tex]
0 < \varepsilon << 1
[/tex]

Therefore, -1 + 2epsilon is ROUGHLY -1. So the first matrix above simplifies under this approximation to the second one.

EDIT: Hmmm, actually, I don't think the power series expansion is quite what I'm looking for. I'd like to have

[tex]
f(x) = \sqrt{x^2 + \varepsilon + \varepsilon^2} \simeq \sqrt{x^2 + \varepsilon}
[/tex]

since terms of eps^2 are very small compared to terms of power eps, but x is comparable to epsilon for small enough x. Unless I'm very confused a power series expansion in epsilon will not give me this. Any thoughts would be appreciated.
 
Last edited:
  • #6


Perhaps you can adapt something like this

In[1]:= {{-2ξ,1-ξ},{-1+ξ,-1+2ξ}}/.{x_+_*ξ->x,x_+ξ->x}

Out[1]= {{-2 ξ,1},{-1,-1}}

Or perhaps

In[2]:= Sqrt[x + ξ + ξ^2] /. ξ^2 -> 0

Out[2]= Sqrt[x + ξ]

Limit[expression,ξ->0] won't do what you want and I can't think of a single simple pattern substitution that will do all and only the things you want in all the kinds of expressions that someone could come up with.

With any pattern matching in particular and any Mathematica result in general you should carefully check the results to make sure there are no errors
 
Last edited:

Related to Small quantities in mathematica

1. What is a "small quantity" in Mathematica?

A small quantity in Mathematica refers to a number that is close to zero or has a very small magnitude. It is often denoted by the symbol ε (epsilon) and is used in mathematical calculations to represent a small error or deviation from an exact value.

2. How is a small quantity represented in Mathematica?

In Mathematica, a small quantity can be represented using the built-in function $MachineEpsilon. This gives the value of the smallest positive number that the system can represent. Alternatively, the user can also define their own small quantity using the Epsilon function.

3. What is the purpose of using small quantities in Mathematica?

Small quantities are used in Mathematica to account for errors or uncertainties in mathematical calculations. They can also be used to avoid division by zero errors and to prevent numerical instability in algorithms.

4. How can small quantities be manipulated in Mathematica?

Small quantities can be manipulated in Mathematica using the standard arithmetic operations such as addition, subtraction, multiplication, and division. They can also be used in functions such as Abs and Sign to determine the magnitude and sign of a small quantity.

5. Are there any precautions to take when working with small quantities in Mathematica?

Yes, it is important to keep in mind that small quantities in Mathematica are represented as approximate numbers and may not always be accurate. It is recommended to use them only when necessary and to avoid using them in calculations involving large numbers or complex functions.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
450
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
921
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
584
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
172
Back
Top