Thread View: sci.math.num-analysis
4 messages
4 total messages
Started by Muyu Guo
Fri, 14 Aug 1992 04:09
Integration of Step function algorithm/code any?
Author: Muyu Guo
Date: Fri, 14 Aug 1992 04:09
Date: Fri, 14 Aug 1992 04:09
18 lines
901 bytes
901 bytes
I am having trouble doing the integral using either qtrap
or qsimp from Numerical Recipes:
b
/
| f(x)dx, with a < 1, b > 2
/
a
and f(x) = 1 (1 <= x <= 2)
= 0 otherwise
For example a=0, b=4 or the like the results were nonsense.
Does anyone know if there is a good way to get thru this?
Thanks a million for your attention.
--
--
Muyu Guo
Re: Integration of Step function algorithm/code any?
Author: Andrew Mullhaupt
Date: Sun, 16 Aug 1992 23:07
Date: Sun, 16 Aug 1992 23:07
20 lines
1325 bytes
1325 bytes
In article <1992Aug14.040957.16304@Princeton.EDU> muyu@burn.Princeton.EDU (Muyu Guo) writes: [Integration of step function] >Does anyone know if there is a good way to get thru this? >Thanks a million for your attention. You will find that integrands which are easy for the simple approaches to numerical quadrature are _smooth_. When you have a discontinuity in a derivative, or in the function itself, other methods are appropriate. Usually the best thing to do is to break the integral up into pieces over which the integrand is 'nice'. Failing this, you should consider using adaptive quadrature with extrapolation. A reasonable approach is afforded by the quadpack routine QAGS, which can deal automatically with some kinds of singularities. You should take a look in the QUADPACK user's guide, or in the excellent book by Davis and Rabinowitz on numerical quadrature for more information. Later, Andrew Mullhaupt
Re: Integration of Step function algorithm/code any?
Author: Jeffrey Oliver Breen
Date: Fri, 28 Aug 1992 01:19
Date: Fri, 28 Aug 1992 01:19
33 lines
1413 bytes
1413 bytes
In article <1992Aug14.040957.16304@Princeton.EDU> muyu@burn.Princeton.EDU (Muyu Guo) writes: >I am having trouble doing the integral using either qtrap >or qsimp from Numerical Recipes: > > b > / > | f(x)dx, with a < 1, b > 2 > / > a > and f(x) = 1 (1 <= x <= 2) > = 0 otherwise > >For example a=0, b=4 or the like the results were nonsense. > >Does anyone know if there is a good way to get thru this? >Thanks a million for your attention. Since f(x) will be one from x=1 to x=2, and this range is included by the a<1 and b>2 guarantee, and the function is zero everywhere else, then the integral just becomes: 2 / | 1 dx, otherwise known as 1. Is there a reason you were trying to / 1 solve this numerically? -- +----------- | Jeffrey Oliver Breen Harvard-Smithsonian Center for Astrophysics, | (617) 495-7252 60 Garden St., Room B-340, MS 6, Cambridge, MA 02138 |
Re: Integration of Step function algorithm/code any?
Author: Herman Rubin
Date: Fri, 28 Aug 1992 19:59
Date: Fri, 28 Aug 1992 19:59
44 lines
2141 bytes
2141 bytes
In article <1992Aug28.011918.22579@harlow.harvard.edu> job@head-cfa.harvard.edu (Jeffrey Oliver Breen) writes:
>In article <1992Aug14.040957.16304@Princeton.EDU> muyu@burn.Princeton.EDU (Muyu Guo) writes:
>>I am having trouble doing the integral using either qtrap
>>or qsimp from Numerical Recipes:
>> b
>> /
>> | f(x)dx, with a < 1, b > 2
>> /
>> a
>> and f(x) = 1 (1 <= x <= 2)
>> = 0 otherwise
>>For example a=0, b=4 or the like the results were nonsense.
>>Does anyone know if there is a good way to get thru this?
>>Thanks a million for your attention.
>Since f(x) will be one from x=1 to x=2, and this range is included by
>the a<1 and b>2 guarantee, and the function is zero everywhere else,
>then the integral just becomes:
> 2
> /
> | 1 dx, otherwise known as 1. Is there a reason you were trying to
> /
> 1
>solve this numerically?
THIS function can be done that way, but what if things are more complicated?
It is not too difficult to handle discontinuous functions, or functions with
discontinuous derivatives, if one knows where the discontinuities are, and
the programmer breaks up the range. For infinities, the problem is worse,
and for unknown discontinuities, still worse.
Some integrators will attempt to handle this, but most assume that the
function is sufficiently smooth that this problem does not arise.
--
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
Phone: (317)494-6054
hrubin@pop.stat.purdue.edu (Internet, bitnet)
{purdue,pur-ee}!pop.stat!hrubin(UUCP)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads