• To: mathgroup at smc.vnet.net
• Subject: [mg31943] Re: Simple questions about Mathematica
• From: uhap023 at alpha1.rhbnc.ac.uk (Tom Crane)
• Date: Thu, 13 Dec 2001 01:08:50 -0500 (EST)
• Organization: Dept. Physics, Royal Holloway, University of London
• References: <9v25kb\$lcs\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```In article <9v25kb\$lcs\$1 at smc.vnet.net>, BobHanlon at aol.com writes:
>
> 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.

> 1. Use substitution rules:
>
[details removed]

What would be nice would be something like Simplify[] or FullSimplify[] but
which would identify common sub-expressions like the sqrt(a^2+b^2) above and
substitute them automatically subject to some criteria. eg. produce a result
which minimises the total numbers of terms (in the main expression plus all the
substituted sub-expressions) subject to a minimum size of substituting
sub-expression to prevent it doing silly things like turning,

R=Sqrt[a^2+b^2) into,

sub1=a
sub2=b
sub3=sub1*sub1
sub4=sub2*sub2
sub5=sub3+sub4
R=Sqrt[sub5]

... this being effectively what the FortranDef utility does.

Tom.

--
Tom Crane, Dept. Physics, Royal Holloway, University of London, Egham Hill,
Egham, Surrey, TW20 0EX, England.
Email:	uhap023 at vms.rhbnc.ac.uk
SPAN:   19.875
Fax:    +44 (0) 1784 472794

```

• Prev by Date: Re: Solve[] for equations?
• Next by Date: Re: Solve[] for equations?