Adept Scientific - English
The world's best software and hardware 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  
UKdedksvnofi
Home
Products
Training
Events
 Buy Online
Downloads
Academic Discounts
Support
My Adept
International |  About Us |  Adept Scientific Blog |  Contact Us |  Press Room |  Jobs
Adept Scientific on Twitter Adept Scientific on LinkedIn


The Next Steps

• Ask us a question
• Maple Product Tour
• Buy Maple Now
• View Maple Pricing
• Download a Brochure
• Request a Brochure
• Request an Evaluation
• Meet Our Team
• Read our RSS Feeds

Learn More

Maple Home
Maple 15 Professional
Maple 15 Academic
Maple 15 Student Use
What's New in Maple 15
Maple Features
Maple History
Recorded Online Seminars

MapleSim
MapleNet
Maple T.A.
BlockImporter™
Maple Toolboxes

Maple Rave Reviews
Maple Study Guides
Books about Maple
System Requirements

Maple Home
Maple 15 Professional
Maple 15 Academic
Maple 15 Student Use
What's New in Maple 15
Maple Features
Maple History
Recorded Online Seminars

MapleSim
MapleNet
Maple T.A.
BlockImporter™
Maple Toolboxes and
Connectors


Maple Rave Reviews
Maple Study Guides
Books about Maple
System Requirements

Latest Information

New Features: Professional
New Features: Academic
Maple Features
The Maple Reporter Online

Service & Support

Maple Primes
blogs, forums etc

Elite Maintenance Program
Application Centre
Powertools
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] Integration bug dependent on N

Search email archive for  

[MUG] Integration bug dependent on N
Author: Glenn Sowell    Posted: Fri, 05 Apr 2002 19:15:14 -0600

>> From: Glenn Sowell />

I have seen the following integration bug in Maple 6 & 7, but not in 5.1.

The bug seems to be N dependent, where N is the power of the denominator
of the integrand.

> interface(version);
Maple Worksheet Interface, Maple 7.00,
APPLE_PPC_MAC, Tue, May 29, 2001 Build ID 96223
> assume(a>0);
> f := 1/(x^2+a^2)^N;
> #N=6 This does not work.
> N:=6:
> Df := diff(f,x,x);
> fDf := simplify( f * Df );
> Int1 := int( fDf, x=0..infinity );
Int1 := 0
> #A surprising result!

> #Try expanding fDf before integrating:
> Int2 := int( expand(fDf), x=0..infinity );

468027 Pi

Int2 := - ------- ---

1048576 25

a

> # A different result?!

> #The same dichotomy occurs for N>=6. For N<=5, both results are the
same.
> #It gets stranger...

> # Do the indefinite integral first
> Int3 := int( fDf, x);
> #Now apply the limit by hand:
> Int2 := limit( Int1, x=infinity ) - limit( Int1, x=0 );

468027 Pi

Int2 := - ------- ---

1048576 25

a

> #Another surprising result!

> #Evidently, the definite integral algorithm is doing something wrong!

Why does it occur for N>=6 and not for N<=5?

Thanks.
Glenn Sowell
Dept. of Physics
Univ. of Nebraska at Omaha




[MUG] Re: Integration bug dependent on N
Author: Helmut Kahovec    Posted: Fri, 12 Apr 2002 01:26:21 +0200

>> From: Helmut Kahovec />
Glenn Sowell wrote:

>| I have seen the following integration bug in Maple 6 & 7, but not in 5.1.
>|
>| The bug seems to be N dependent, where N is the power of the denominator
>| of the integrand.


Actually, the procedure `int/definite/contour/residue`, which computes
residues during definite integration, is flawed. Additionally, the
procedure 'residue' cannot compute a residue if the order of the pole is
sufficiently high. Following is a Maple7 session on a PC running MS
Windows NT 4.0.

> restart;
> assume(a>0);
> num,den,alpha,m:=(13*_X^2-a^2)*ln(-_X),(_X^2+a^2)^14,I*a,14:

> residue(eval(num/den,_X=x),x=alpha);

2 2
(13 x - a ) ln(-x)
residue(-------------------, x = I a)
2 2 14
(x + a )

'residue' returns unevaluated. We now modify 'residue' as indicated:

> unprotect(residue);

> residue:=proc(f,a)
local g,i,t,x,t1;
options remember;
if nargs<>2 or not type(a,equation) or not type(op(1,a),name) then
error "invalid arguments"
end if;
x:=op(1,a);
if has(op(2,a),x) then
error "invalid point"
elif type(op(2,a),infinity) then
g:=-1/x^2*subs(x=1/x,f)
else
g:=normal(subs(x=x+op(2,a),f),expanded)
end if;
# for i from 0 to 5 do <=== replace the number 5 by 6 ===
for i from 0 to 6 do
t:=traperror(series(g,x,i^2+2));
if t=0 then return 0 end if;
if t=lasterror or not type(t,series) then next end if;
t1:=order(t);
if t1=infinity or -1<t1 then return coeff(t,x,-1) end if
end do;
'residue(args)'
end proc:

> protect(residue);

> residue(eval(num/den,_X=x),x=alpha): R11:=simplify(expand(%));

R11 :=

669278610 I ln(a) - 2269536821 I + 334639305 Pi
1/17993564160 -----------------------------------------------
25
a

This seems to be the correct value. During definite integration the
procedure `int/definite/contour/residue` gets called with the
appropriate arguments. However, since `int/definite/contour/residue` is
flawed, it will return an incorrect residue if the order of the pole is
high enough.

> `int/definite/contour/residue`(num,den,alpha,m);

-79
-------- I
14057472
----------
25
a

We fix the incorrect lines in `int/definite/contour/residue` as
indicated:

> `int/definite/contour/residue`:=proc(n,d,a,m)
local i,r,v1;
if nargs=4 and m=1 then
i:=n/diff(d,_X);
i:=traperror(eval(subs(_X=a,i)));
if i<>lasterror then return i end if
end if;
for i from 0 by 3 to 12 do
r:=traperror(`int/definite/contour/seriesc`(n/d,_X=a,i));
if r=FAIL then
return FAIL
elif r=lasterror or
not type(r,series) or
op(nops(r),r)<0 and op(nops(r)-1,r)=O(1)
then
next
else
break
end if
end do;
if i<=12 then
if hastype(n/d,'nonreal') or hastype(a,'nonreal') then
return coeff(r,evalc(_X-a),-1)
else
return coeff(r,_X-a,-1)
end if
end if;
if type(d,polynom(anything,_X)) and nargs=4 and 1<m then
v1:=quo(d,(_X-a)^m,_X,'r');
if r<>0 then return FAIL end if;
#
# One has to differentiate n/v1 instead of differentiating n
# alone and dividing by v1 afterwards!
#
# |||
# |||
# vvv
i:=traperror(eval(subs(_X=a,diff(n/v1,`$`(_X,m-1))/(m-1)!)));
if i<>lasterror then
return i
else
return FAIL
end if
elif nargs=4 and 1<m then
#
# One has to differentiate (_X-a)^m*(n/d) instead of (_X-a)^m
# alone!
# ||||
# ||||
# vvvv
i:=limit(diff((_X-a)^m*n/d,`$`(_X,m-1))/(m-1)!,_X=a);
if type(i,function) and op(0,i)=limit or
type(i,undefined) or
type(i,range)
then
FAIL
else
i
end if
else
FAIL
end if
end proc:

Now, `int/definite/contour/residue` returns the same result as
'residue':

> `int/definite/contour/residue`(num,den,alpha,m):
> R12:=simplify(expand(%));

R12 :=

669278610 I ln(a) - 2269536821 I + 334639305 Pi
1/17993564160 -----------------------------------------------
25
a

The other pole of your integrand gives the following residue:

> num,den,alpha,m:=(13*_X^2-a^2)*ln(-_X),(_X^2+a^2)^14,-I*a,14:
> residue(eval(num/den,_X=x),x=alpha): R21:=simplify(expand(%));

R21 := - 1/17993564160

669278610 I ln(a) - 334639305 Pi - 2269536821 I
-----------------------------------------------
25
a

> `int/definite/contour/residue`(num,den,alpha,m):
> R22:=simplify(expand(%));

R22 := - 1/17993564160

669278610 I ln(a) - 334639305 Pi - 2269536821 I
-----------------------------------------------
25
a

Finally, Maple will correctly compute your definite integral, too:

> f:=1/(x^2+a^2)^N:
> N:=6:
> Df:=diff(f,x,x):
> fDf:=simplify(f*Df);

2 2
13 x - a
fDf := 12 -----------
2 2 14
(x + a )

> int(fDf,x=0..infinity): normal(%,expanded);

468027 Pi
- ------- ---
1048576 25
a

If we expand the integrand then Maple first computes the antiderivatives
and takes the limits afterwards.

> int(expand(fDf),x=0..infinity): normal(%);

468027 Pi
- ------- ---
1048576 25
a


Kind regards

Helmut



Previous by date: [MUG] Re: Parallel use?,  Jerome BENOIT
Next by date: [MUG] Stop reducing & data points.,  Jason C Leach
Previous thread: [MUG] is there an easy way to compute a Fourier series spectrum of raw data taken from text file,  Deveney, Edward
Next thread: [MUG] Stop reducing & data points.,  Jason C Leach



Ready to buy?

For more pricing information:
Visit our webstore, call us on +1 800 724 8380 or email us at info@adeptscience.com

Featured Downloads

Maple 15 & MapleSim 5 Professional Brochure
Maple 15 Academic Datasheet
Maple 15 & MapleSim 5 Brochure - Academic Brochure
Maple 15 New Features data sheet
Maple 15 New Features - Flyer
Maple Whitepaper: Driving Innovation - How mathematical modeling and optimisation increase efficiency and productivity in vehicle design.
MapleSim Whitepaper: Technological Superiority in Multi-Domain Physical Modeling and Simulation

Latest Downloads

Maple Case Study: The Changing Face of Robotics
Maple Application Brief - Analyse the Path of a Liquid-Handling Robot
Maple Player for iPad - App
Maple Player for iPad - Datasheet
Case Study - Multi-Domain Modelling Critical to Unmanned Vehicle Designs

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

Latest News

NASA’s Jet Propulsion Laboratory begins widespread adoption of Maplesoft technology
NASA’s Jet Propulsion Laboratory begins widespread adoption of Maplesoft technology
Latest release marks the 10th anniversary of Maple T.A.
Maple Case Study: The Changing Face of Robotics
Maple Application Brief - Analyse the Path of a Liquid-Handling Robot
adept

Top of the Page

Popular Links: ChemDraw | ChemOffice | Data Acquisition | Data Analysis | EndNote | Maple | MapleSim | Mathcad | MathType | Quality Analyst | Reference Manager | VisSim

EU ePrivacy Directive | Our Privacy and Terms and Conditions Statement
All Trademarks Recognised. Copyright © 2012, Adept Scientific plc.
Site designed and maintained by Lyndon Ash

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