MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Algebraic re-substitution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71095] Re: Algebraic re-substitution
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Wed, 8 Nov 2006 06:07:36 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <eicn5h$ft3$1@smc.vnet.net>

In article <eicn5h$ft3$1 at smc.vnet.net>,
 "James" <cannonjunk at hotmail.com> wrote:

> I am trying to work out how to simplify an equation by resubstituting
> variables back into the result to make the result more readable. As a
> simple example:
> 
> In three dimentions, the distance between two points is given by:
> r[xi_,yi_,zi_,xj_,yj_zj_] := Sqrt[(xj-xi)^2 + (yj-yi)^2 + (zj-zi)^2]
> 
> If I have an equation like:
> V=r[xi,yi,zi,xj,yj,zj]^2+2r[xi,yi,zi,xj,yj,zj]-5
> 
> Then I can tell mathematica to find the derivative, wrt xi:
> f=D[V,xi]
> 
> This will then result in a long equation with many xi's, yi's, etc...
> which would look much cleaner and simpler is mathematica re-substituted
> r back into the equation.
> 
> How can I get mathematica to do this? I have been playing with Simplify
> and FullSimplify, but I can't work it out. My actual problem is much
> more complicated, but I made this up as a basic example to illustrate
> the question.

Here is one way. Automatically simplify your results using $Post.

 $Post := Simplify[# //. r[xi, yi, zi, xj, yj, zj]^2 -> r^2, r > 0] & 

 r[xi_,yi_,zi_,xj_,yj_,zj_] = Sqrt[(xj-xi)^2 + (yj-yi)^2 + (zj-zi)^2]

 V=r[xi,yi,zi,xj,yj,zj]^2+2r[xi,yi,zi,xj,yj,zj]-5

 D[V,xi]

Cheers,
Paul

_______________________________________________________________________
Paul Abbott                                      Phone:  61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    
AUSTRALIA                               http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: Re: Factor.....
  • Next by Date: Re: xvnc Mathematica menu fonts
  • Previous by thread: Re: Algebraic re-substitution
  • Next by thread: Clarification re. Curiosity concerning transformation rules for List