MathGroup Archive 2004

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

Search the Archive

Algebraic simplification and speed

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52665] Algebraic simplification and speed
  • From: Steve Gray <stevebg at adelphia.net>
  • Date: Tue, 7 Dec 2004 04:10:09 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

1. I'm not sure how to do manually aided simplification. Suppose Mathematica solves a set of equations and
comes up with something like
x=(x1^2 + 2 y1^2+3 Z1^2)/Sqrt[x1^2+y1^2+z1^2] and similarly for y and z. I want to manually tell it
to use r=Sqrt[x1^2+y1^2+z1^2] for the denominator from here on in all expressions and further work.
How do I do that? (The actual expressions are much more complex.) I could manually substitute "r"
for the Sqrt by copying/pasting etc. in the further expressions, but doing this in the actual
equations is very error-prone, so I need Mathematica's help in subsequent stages.
	Unless Mathematica does a great job of removing redundant calculations, my manually defined
temporary variables will also speed up the calculations.

2. I had a Solve inside a loop. It was taking too long for the millions of numerical executions I
need. Then I changed the code, executing a Solve once outside the loop, using symbols instead of
numbers. Then I copied the resulting symbolic expressions into the loop, leaving Mathematica to do only
numeric multiplies etc. in the loop, there now being no Solve in the loop. This made it about 30
times faster. This seems like an obvious thing to do, but is there a more standard way? I almost
didn't think of that trick, obvious as is may be to experienced users.

 
	Thanks for any help.

Steve Gray


  • Prev by Date: Re: Compile with ReplaceList: bug report
  • Next by Date: Re: Re: Solve given that a variable is between 0 and 1
  • Previous by thread: Re: Compile with ReplaceList: bug report
  • Next by thread: Re: Algebraic simplification and speed