       • To: mathgroup at smc.vnet.net
• Subject: [mg31891] Re: [mg31888] Simple questions about Mathematica
• From: BobHanlon at aol.com
• Date: Mon, 10 Dec 2001 06:14:30 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

In a message dated 12/9/01 7:11:31 AM, stevebg at adelphia.net writes:

>1. Suppose I solve some equations and get a complicated
>expression containing multiple identical elements such as
>sqrt(a^2+b^2). To make the expression smaller, clearer, and
>easier to deal with, I want to substitute say R=sqrt(a^2+b^2)
>everywhere in the main expression and have R available as
>a symbol from then on. I see nothing in Help or anywhere
>else about how to do this. But it's such a standard thing to
>do that there must be an easy answer.
>
>2. I'm not sure how a "batch" file is suppposed to be
>prepared and fed to Mathematica. That is, I want to
>prepare a bunch of operations and variables in advance
>and feed it in, preferably having mathematica give me
>line-by-line output as it would if I were typing each line
>in  one by one.
>

1. Use substitution rules:

Clear[a, b, R];

useR = (Sqrt[a^2+b^2] :> R);

removeR = (R :> Sqrt[a^2+b^2]);

expr = (Sqrt[a^2+b^2]+c)/(Sqrt[a^2+b^2]-c);

expR = (expr /. useR)

(c + R)/(-c + R)

(expR /. removeR) == expr

True

2.  In the Master index, look under 'Batch files"

Bob Hanlon
Chantilly, VA  USA

• Prev by Date: Re: Simple questions about Mathematica
• Next by Date: Re: Simple Eval Question