Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Algebraic Manipulation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46180] Re: [mg46159] Algebraic Manipulation
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Tue, 10 Feb 2004 00:05:50 -0500 (EST)
  • References: <200402091054.FAA20968@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

David Park wrote:
> Dear MathGroup,
> 
> I'm always interested in Mathematica techniques for manipulating and simplifying
> algebraic expressions. I came across the following problem, which I was only able
> to do with a fair amount of difficulty.
> 
> expr = x*y*(-(z^2/(r^2*(x^2 + y^2))) - 1/(r*(k + r)) + 1/(x^2 + y^2))
> 
> where
> 
> r^2 == x^2 + y^2 + z^2
> 
> reduces to
> 
> (k*x*y)/(r^2*(k + r))
> 
> I wonder if anyone can show an elegant or short method to do the simplification?
> 
> (The problem arose in calculating the components of the Schwarzschild metric
in Cartesian coordinates.)
> 
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/ 
> 

One method is shown at:

http://forums.wolfram.com/mathgroup/archive/2002/Jan/msg00354.html

The code is short so I'll repeat it here.

replacementFunction[expr_,rep_,vars_] := If [
   PolynomialQ[Numerator[expr],vars] &&
   PolynomialQ[Denominator[expr],vars],
     PolynomialReduce[expr, rep, vars][[2]], expr]

For your example, one might do as follows.

expr = x*y*(-(z^2/(r^2*(x^2 + y^2))) - 1/(r*(k + r)) + 1/(x^2 + y^2));
rep = r^2 - (x^2 + y^2 + z^2);

In[6]:= InputForm[MapAll[replacementFunction[#, rep, {r}]&,
   Together[expr]]]

Out[6]//InputForm= (k*x*y)/(r^2*(k + r))


Daniel Lichtblau
Wolfram Research



  • Prev by Date: Re: extracting a list to a list, help please
  • Next by Date: Re: extracting a list to a list, help please
  • Previous by thread: Re: Algebraic Manipulation
  • Next by thread: Re: Algebraic Manipulation