Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Substitute all known relations in result

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86660] Re: Substitute all known relations in result
  • From: magma <maderri2 at gmail.com>
  • Date: Mon, 17 Mar 2008 00:21:01 -0500 (EST)
  • References: <frg0ap$eu5$1@smc.vnet.net> <friu2g$ki$1@smc.vnet.net>

On Mar 16, 11:50 am, Szabolcs Horv=E1t <szhor... at gmail.com> wrote:
> 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 wa=
s
> 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]]

Very interesting question with 2 very interesting and different
answers by Andrzej and Szabolcs.
The solution by Andrzej is a good example of the use of Groebner
basis.
Groebner basis are probably not yet an household name, even among
Mathematica aficionados.
Certainly they were not for me, when I first read them in the
Mathematica documentation.
This reply by Andrzej will hopefully entice more  users to start
reading a bit about the theory behind them.
The reply by Szabolcs is entirely built inside Mathematica and is
definitely worth following his advice on reading about  Assumptions.
Another useful related function that I would like to suggest is
Refine.

Alessandro







  • Prev by Date: Re: V.6.0.2 gripes...
  • Next by Date: Re: Should I uninstall the old version before upgrading?
  • Previous by thread: Re: Substitute all known relations in result
  • Next by thread: ordering of multivariate polynomial terms