       Re: To extract the power of variable

• To: mathgroup at smc.vnet.net
• Subject: [mg50080] Re: [mg50053] To extract the power of variable
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Sat, 14 Aug 2004 01:50:36 -0400 (EDT)
• References: <200408130955.FAA03634@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On 13 Aug 2004, at 11:55, Tun Myint Aung wrote:

> Hi,
>
>             I want to extract the power of x and y from the polynomial
> function. For example x--2+xy+y2 , I want to get 2 for the first term,
> 1
> for second term and 2 for last term.
>
> Thanks for help
>
> Tun Myint Aung
>
>
> National University of Singapore
>
>
First of all, you won't get anywhere with Mathematica unless you learn
the proper syntax. And the syntax for inputing this polynomial is x^2 +
x*y + y^2. Secondly, what you are asking for does not make much sense.
I can't imagine any sensible interpretation of "power of a variable* in
which the exponent of x y is 1, unless of course you really mean xy to
be a name of a variable and not a product. But you can get the answer
you want using:

Exponent[x^2+x y+y^2,#]&/@{x,x y,y}

Out=
{2,1,2}

Assuming that xy really meant the product of x and y (in other words x
y or x*y)   a more sensible answer is returned by:

First[Transpose[Internal`DistributedTermsList[
x^2 + x*y + y^2, {x, y}][]]]

{{2, 0}, {1, 1}, {0, 2}}

which means that you have a second power of the first variable, a
product of terms of degree 1 and a second power of the second variable.

Andrzej Kozlowski
Chiba, Japan
http://www.mimuw.edu.pl/~akoz/

```

• Prev by Date: Re: How does a notebook get its own filename or directory?
• Next by Date: Re: How does a notebook get its own filename or directory?
• Previous by thread: To extract the power of variable
• Next by thread: Help with parameter estimation