Re: Substitute all known relations in result

• To: mathgroup at smc.vnet.net
• Subject: [mg86647] Re: Substitute all known relations in result
• From: Szabolcs Horvát <szhorvat at gmail.com>
• Date: Sat, 15 Mar 2008 17:46:13 -0500 (EST)
• Organization: University of Bergen
• References: <frg0ap\$eu5\$1@smc.vnet.net>

```Dr. Johannes Zellner wrote:
> Hi,
>
> How do I make mathematica to display results with all known
> relations / variables?
> E.g. if a result is
>    x^2+y^2
> and before I'd defined
>    r = x^2+y^2
> I'd like mathematica to display the result rather as "r".
>
> And: I'd like mathematica to do this for each relation defined before
> w/o specifying every possible replacement.
>
> Any help much appreciated.
>

It is not possible to do this.  When you define
r = x^2 + y^2
Mathematica will know that from now on whenever it sees 'r', it should
replace 'r' by x^2 + y^2.  This is like variable assignment in any other
programming language.  It is something completely different from
declaring the mathematical statement r == x^2 + y^2 to be true (which
cannot really be done in Mathematica, but *do* take a look at the
documentation of Assuming, Assumptions and \$Assumptions)

But even if we know that r == x^2 + y^2 is true, we can use this fact in
many different ways.  You say that you want Mathematica to replace
x^2+y^2 by r.  Why?  This is not the only possible replacement that can
be based on this fact.  Why not replace r by x^2+y^2 instead?  Or why
not replace x^2 + y^2 by (x^2 + y^2 + r)/2?  Or why not replace x by
Sqrt[r - y^2]?  (Okay, I know that (x)^2 == (-x)^2 so this last one was
not a correct transformation ... but I think you understand my point.)

Why would you select that *single* tranformation from the infinite
number of possibilities?

Is your goal to construct an expression that has as few parts as
possible?  Then use FullSimplify, e.g.

FullSimplify[x^2 + y^2, x^2 + y^2 == r]

FullSimplify will try many tranformations on the expression, and it will
return the shortest result (the one with the smallest LeafCount).  In
this example this happens to be r.

An alternative syntax is

Assuming[x^2 + y^2 == r, FullSimplify[x^2 + y^2]]

```

• Prev by Date: Re: Clearing selected variables
• Next by Date: Re: Clearing selected variables
• Previous by thread: Re: Substitute all known relations in result
• Next by thread: Re: Substitute all known relations in result