MathGroup Archive 1998

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

Search the Archive

Re: Re: Simplifying algebraic expr: howto?



Daniel G. Hyams wrote:
> ...
> The code that follows does indeed work:
> 
> T = (nx*u+ny*v)*u
> T /. (nx*u+ny*v -> t)
> 
> Mathematica: t*u
> 
> But, this seems to do just a textual-type substitution.  The following
> snippet does not work (like I want it to):
> 
> T = (nx*u+ny*v)*u + (-nx*u-ny*v)*v
> T /. (nx*u+ny*v -> t)
> 
> Mathematica: t*u + v(-nx*u - ny*v)
> 
> Obviously, the solution that I want is:  t*u-t*v
> 
> The point is that the variable "t" is in a very complicated  expression,
> which can be considerably simplified by factoring it out, if only I
> could tell Mathematica its identity.  It also appears as
>    v*nx*u + ny*v^2 = v(nx*u + ny*v) = v*t
> 
>    or
> 
>    nx^2*u + 2*nx*ny*u*v + ny^2*v = (nx*u+ny*v)^2 = t^2
> 
> and I would like Mathematica to identify occurances like these.
> 
> ----------------------------------------------------------- Daniel G.
> Hyams
> email:  dhyams@ebicom.net
> phone:  (601) 323-4198
> -----------------------------------------------------------


In[4]:= ??PolynomialReduce
PolynomialReduce[poly, {poly1, poly2, ... }, {x1, x2, ... }] yields a
list
   representing a reduction of poly in terms of the polyi. The list has
the
   form {{a1, a2, ... }, b}, where b is minimal and a1 poly1 + a2 poly2
+ ...
   + b is exactly poly.
Attributes[PolynomialReduce] = {Protected} Options[PolynomialReduce] =
  {CoefficientDomain -> Rationals, Modulus -> 0,
   MonomialOrder -> Lexicographic, ParameterVariables -> {}, Sort ->
False}

In[5]:= ee = T = (nx*u+ny*v)*u + (-nx*u-ny*v)*v;

In[6]:= Last[PolynomialReduce[ee, nx*u+ny*v-t, Variables[ee]]] Out[6]= t
u - t v

We use Variables[ee] because any variable not listed, e.g. t, will be
placed lexicographically after those explicitly given.

For non-polynomial input you would need to map PolynomialReduce to
relevant parts; for input with outrageously large exponents you may
need to go inside the powers (PolynomialReduce will balk if exponents
are too big).


Daniel Lichtblau
Wolfram Research



  • Prev by Date: Re: Defining a Function??
  • Next by Date: Re: Re: FindRoot accuracy/precision
  • Prev by thread: Re: Simplifying algebraic expr: howto?
  • Next by thread: Re: Simplifying algebraic expr: howto?