MathGroup Archive 1998

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

Search the Archive

Re: Simplifying algebraic expr: howto?


  • To: mathgroup@smc.vnet.net
  • Subject: [mg11473] Re: Simplifying algebraic expr: howto?
  • From: Allan Hayes <hay@haystack.demon.co.uk>
  • Date: Thu, 12 Mar 1998 01:35:01 -0500
  • References: <6dqqf0$rk0@smc.vnet.net> <6dv577$5jm@smc.vnet.net>

Daniel G. Hyams wrote:
> 
> On 7 Mar 1998, Daniel G. Hyams wrote:
> 
> >
> > I apologize for the (probable) simpleness of this questions, but I am
> > new to mathamatica...
> >
> > I have an expression (for example):
> >
> > u*(nx*u + ny*v)     ---- (1)
> >
> > and a definition:
> >
> > theta x*u+ny*v
> >
> > How do I get mathematica to simplify the expression (1) such that it
> > returns:
> >
> > u*theta ?
> 
> Thanks to the couple of folks who responded to the questions, but I am
> afraid that I did not make it clear enough...
> 
> 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 (nx*u + ny*v) *t
> 
>    or
> 
>    nx^2*u + 2*nx*ny*u*v + ny^2*v nx*u+ny*v)^2 
^2
> 
> and I would like Mathematica to identify occurances like these.
> 
> ----------------------------------------------------------- Daniel G.
> Hyams
> email:  dhyams@ebicom.net
> phone:  (601) 323-4198
> -----------------------------------------------------------

Daniel,

PolynomialReduce may help

?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.

T nx*u+ny*v)*u + (-nx*u-ny*v)*v;

z 
 - (nx*u+ny*v)  ;

PolynomialReduce[T,{z},{u,v}]

{{-u+v},t u-t v}

So, with z   T reduces to

Last[%]

t u-t v


A problem with

z2 *nx*u + ny*v^2 - v*t;

is that z2  only implies z   if v *0

Here is a way that might be built into a more automatic process (perhaps
displaying all possibilities or allowing assumptions to be included
initi
lly)

FactorList[z2]

{{-1,1},{v,1},{t-nx u-ny v,1}}

First/@Rest[%]

{v,t-nx u-ny v}

Last[PolynomialReduce[T,%[[2]],{u,v}]]

t u-t v

z3 x^2*u^2 + 2*nx*ny*u*v + ny^2*v^2 - t^2;

The third example 

First/@FactorList[z3]

{-1,t-nx u-ny v,t+nx u+ny v}

Last[PolynomialReduce[T,%[[2]],{u,v}]]

t u-t v


-- 
Allan Hayes
Mathematica Training and Consulting
Leicester, UK
hay@haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642




  • Prev by Date: Re: Re: FindRoot accuracy/precision
  • Next by Date: Computed dynamic functions
  • Prev by thread: Re: Simplifying algebraic expr: howto?
  • Next by thread: Re: Simplifying algebraic expr: howto?