Adept Scientific - English
The world's best software for research, science and engineering.
flag arrow
clearclear
 

 Adept Store | register Join My Adept | Flags  
Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055  
UKusdedksvnofi
Home
Products
Training
Consultancy
 Buy Online
Downloads
Education
Support
My Adept
International |  About Us |  Contact Us |  Press Room |  Jobs


The Next Steps

• Ask us a question
• Maple Product Tour
• Buy Maple Now
• View Maple Pricing
• Find out about Online Training
• Download a Brochure
• Request a Brochure
• Download a Demo
• Request a Demo
• Meet Our Team
• Read our RSS Feeds

Learn More

Maple Home
Maple 11 Professional
Maple 11 Academic
Maple 11 Student Use
Recorded Online Seminars
FREE Training Resources


MapleNet
Maple T.A.
MapleConnect
BlockImporter for Simulink
BlockBuilder for Simulink
Maple Toolboxes
Maple Rave Reviews
Maple Study Guides
Books about Maple
System Requirements

View Maple 10 in Action
Product Comparison Chart

Latest Information

New Features: Professional
New Features: Academic
The Maple Reporter
The Maple Reporter Online
Numerical Algorithms Group
(NAG)


Service & Support

Maple 10 Training Videos
MaplePrimes, blogs, forums
Elite Maintenance Program
Application Centre
Powertools
Maple User Group (MUG)
Join the Maple User Group
(MUG)

Search the Knowledge Base
Technical Support request

List Archives >  Maple User Group List Archive >  Archive by date >  This Month By Date >  This Month By Topic

[MUG] Re: coeff on a generic polynomial

Search email archive for  

[MUG] Re: coeff on a generic polynomial
Author: Maple User Group    Posted: Fri, 22 Nov 2002 16:37:48 -0500

>> From: Maple User Group "maple_gr"

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Tue, 19 Nov 2002 16:14:31 -0800 (PST)
From: Robert Israel "israel"
To: "maple-list"
Subject: coeff on a generic polynomial

On Mon, 18 Nov 2002, Charles James Leonardo Quarra Cappiello wrote:

|> a definite polynomial like
|>
|> > p: x -> a*x^2 + b*x + c;
|>
|> can be accessed with coeff like
|> > coeff( p(z), z, 0 );
|> c
|>
|> BUt, if p is defined like
|>
|> >p:x->sum( a[i]*x^i , I=0..n );

I assume you mean := and i here, not : and I.

|> this still is considered a polynom object
|> > type ( p, polynom);
|> true

Yes, p is a "polynom", as is any other name, but p(z) is not:

> type(p(z), polynom);
false

Of course, p(z) is _not_ a polynomial, it is an unevaluated summation
(assuming n has not been assigned a value).

|> But, coeff doesnt have the desired effect:
|> > coeff( p(z) , z, 0);
|> Error, unable to compute coeff

Not too surprising, since coeff is designed for polynomials rather than
unevaluated series.

Actually, it's not quite clear what you should want as
the result of coeff for this example, if Maple doesn't know whether
n >= 0.

A simple work-around in this particular case is to evaluate p(z) with a
definite value of n (>= 0). So:

> coeff(eval(p(z),n=0),z,0);
a[0]

But doing it in general (maybe for a sum that's not in powers of z, but
of powers of z-c, or something more general) would not be so simple.


Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Tue, 19 Nov 2002 23:24:40 -0500 (EST)
From: Edwin Clark "eclark"
To: Charles James Leonardo Quarra Cappiello "charsquarra"
Subject: coeff on a generic polynomial

You might do this:

> p:=(x,n)->sum('a[i]*x^i','i'=0..n):
> coeff(p(z,0),z,0);

a[0]

> coeff(p(z,1),z,1);

a[1]

> coeff(p(z,2),z,2);

a[2]

>


------------------------------------------------------------
W. Edwin Clark, Math Dept, University of South Florida,
http://www.math.usf.edu/~eclark/
------------------------------------------------------------


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Wed, 20 Nov 2002 10:13:09 +0100
From: Preben Alsholm "P.K.Alsholm"
To: "maple-list"
Subject: coeff on a generic polynomial

Notice that if a is just a name then type(a,polynom) returns true. In
your case p is the name of a function (procedure). Procedures are only
evaluated to a name, so type(p,polynom) will return true.
Try instead:
type(p(x),polynom);
whattype(p(x));
op(0,p(x));
op(p(x));

and you see the problem.

Preben Alsholm
Department of Mathematics
Technical University of Denmark


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: "Dr Francis J. Wright" "F.J.Wright"
To: "charsquarra"
Subject: coeff on a generic polynomial
Date: Wed, 20 Nov 2002 13:23:36 -0000

Let me define p as follows (which I assume is what you intended):

p := x -> sum( a[i]*x^i , i=0..n );

It is true that p is of type polynom, because a variable to which a
procedure (or table) has been assigned evaluates to itself, so p is
(trivially) a polynomial in p of degree 1. However, the test you should
have made is this:

type(p(x), polynom);
false

This is because p(x) is a symbolic sum and not a polynomial.

> But, coeff doesnt have the desired effect:
> > coeff( p(z) , z, 0);
> Error, unable to compute coeff
>
> How can i do this?

I don't know of any straightforward way to extract polynomial terms from an
arbitrary symbolic sum of polynomial terms, although for this simple example
there are trivial tricks one could use, e.g. this extracts the constant
term, which appears to be what you wanted:

eval(op(1,p(x)), i=0);
a[0]

The general problem is an example of manipulating what one might call
"indefinite objects", which seems to be something that CA systems are
currently not very good at. I'm working on it.

Francis

[View Complete Thread]



Previous by date: [MUG] Numerical error, Madham53
Next by date: [MUG] Re: ODE with singularity, Maple User Group
Previous thread: [MUG] more about implicitdiff:complexity and recursiveness,  Charles James Leonardo Quarra Cappiello
Next thread: [MUG] ODE with singularity, Jens-Uwe Herrmann



Ready to buy?

Maple - single user licence
Add to shopping basket
$ 1,895.00
Upgrade to Maple 12 from v11
Add to shopping basket
$ 995.00
Upgrade to Maple 12 from v10 & below
Add to shopping basket
$ 1,395.00

Featured Downloads

Maple White Paper: Technical Knowledge - An Asset You Can Afford to Lose?
Maple in Electronics Application Pack
Maple in Robotics & Aerospace Application Pack
Maple in Finance Application Pack

Product Reviews

"Without the Maple software, we would have to spend weeks generating the equations of motion for every experiment. Then the chances that we did it right would basically be near zero. There would always be a mistake somewhere. It is very difficult to set up a dynamic motion model by hand."
- Jean-Claude PiedBeouf, Ph.D Manager of Robotics, Canadian Space Agency

"Its very good - highly accurate and easy to use. The speed of Maple allows me to change equations and quickly reintegrate them into the application, so more possibilities can be explored to achieve the precise effect desired."
Shawn Neely, Senior R & D Director for PDI/Dreamworks
adept

Top of the Page

Our Privacy and Terms and Conditions Statement
All Trademarks Recognised. Copyright © 2007, Adept Scientific plc.
Site designed and maintained by Adeptise

Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055