Re: Need help to a beginner.
- To: mathgroup at smc.vnet.net
- Subject: [mg9693] Re: [mg9642] Need help to a beginner.
- From: Allan Hayes <hay at haystack.demon.co.uk>
- Date: Fri, 21 Nov 1997 01:31:29 -0500
- Sender: owner-wri-mathgroup at wolfram.com
shink at iastate.edu (Shinichiro Kondo) [mg9642] Need help to a beginner.
Shinichiro,
Here is one way of getting the result that you want. The method will
work more generally. We could put the steps together into one
function.
In[1]:=
e1=1/Sqrt[(a-x)^2+y^2+z^2]
Out[1]=
1/Sqrt[(a - x)^2 + y^2 + z^2]
In[2]:=
e2=Expand//@e1
Out[2]=
1/Sqrt[a^2 - 2*a*x + x^2 + y^2 + z^2]
In[3]:=
e3 =e2/.x^2 +y^2 +z^2 -> r^2
Out[3]=
1/Sqrt[a^2 + r^2 - 2*a*x]
In[4]:=
e4=e3/. 1/Sqrt[u_] :> 1/(a Sqrt[Expand[u/a^2]]) Out[4]=
1/(a*Sqrt[1 + r^2/a^2 - (2*x)/a])
In[5]:=
e5=Series[e4, {x,0,2},{r,0,2}];
In[6]:=
e6 = Normal[e5]
Out[6]=
1/a + x/a^2 + (3*x^2)/(2*a^3) +
r^2*(-(1/(2*a^3)) - (3*x)/(2*a^4) - (15*x^2)/(4*a^5))
In[7]:=
e7 = Expand[e6]
Out[7]=
1/a - r^2/(2*a^3) + x/a^2 - (3*r^2*x)/(2*a^4) +
(3*x^2)/(2*a^3) - (15*r^2*x^2)/(4*a^5)
In[8]:=
e8=DeleteCases[e7, u_/;Plus@@Exponent[u,{x,r}]>2] Out[8]=
1/a - r^2/(2*a^3) + x/a^2 + (3*x^2)/(2*a^3)
In[9]:=
e9=(1/a)Expand[a e8]
Out[9]=
(1 - r^2/(2*a^2) + x/a + (3*x^2)/(2*a^2))/a
Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk/training.html voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
Leicester, UK
***********
Hi, all. I am quite new to Mathematica, and am using the older version,
v. 2.2. I hope someone will help me. My problem is nothing to do with
homework of a math class, or any sort. I am a physics graduate
student, and for my research project am trying to have an algebraic
expression of potential energy of certain ionic crystalline lattice.
The electrostatic (i.e. Coulomb) energy has the expression of 1/r,
where ris the distance between two charges. I am still far from
getting the answer I want because of this problem I am facing in the
very first stage where I am supposed to be used to
Mathematica.
First of all, let me explain my problem. It is known, if you expand
1/Sqrt[1-x], provided that x^2<<1, you have
1+(1/2)*x+(3/*)*x^2+(5/16)*x^3+.... Now, let's have a similar
expression to this: 1/Sqrt[(a-x)^2+y^2+z^2]. Suppose x, y and z are
cartesian coordinates, and r^2=x^2+y^2+z^2. And a is some positive
constant, and it satisfies a>>r. So factoring the denominator by a^2
and kicking it out of the Sqrt as a, I can continue this algebra by
my hand, and I should end up with:
(1/a)*(1+x/a-r^2/(2*a^2)+(3*x^2)/(2*a^2)+....) in which I only keep
up to the 2nd order of r/a (and x/a).
I would like to be able to do this by Mathematica. That is, given this
sort of a reciprocal of a Sqrt of quadratic expression with x, y and
z, I'd like it to expand "approximately" so that a resultant
expression only contain the terms up to a specified order of r/a
(thus, x/a, y/a, and z/a). How can I do this? This kind of expansion
goes on forever, but I don't need many higher order terms. How can I
specify the maximum order that I want to have?
I will greatly appreciate someone's help to this problem. Meanwhile, I
am trying to find a solution in the manual by myself. If you don't
mind, please send your solution to my email address: shink at iastate.edu
Thank you for your attention.