Article View: sci.math.num-analysis
Article #372Re: Integration of Step function algorithm/code any?
From: Muyu Guo
Date: Fri, 28 Aug 1992 15:03
Date: Fri, 28 Aug 1992 15:03
48 lines
2113 bytes
2113 bytes
From article <1992Aug28.011918.22579@harlow.harvard.edu>, by job@head-cfa.harvard.edu (Jeffrey Oliver Breen): > 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 > | I think I should rephrase the original question in the definition of f(x): f(x) = 1 ( a < x1 < x < x2 < b) = 0 otherwise I don't know a prior what is x1 and x2. So I was told better use an adaptive algorithm for this. Actually I can do it even with simple trap routine provided I don't want too much accuracy, say, relative error 1e-5 between successive approximate values of the integral. -- Muyu Guo
Technical Details
Message-ID:
<1992Aug28.150316.21775@Princeton.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!princeton!burn.Princeton.EDU!muyuReferences:
<1992Aug28.011918.22579@harlow.harvard.edu>Show Full Headers
Complete Article Headers
Newsgroups: sci.math.num-analysis Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!princeton!burn.Princeton.EDU!muyu From: muyu@burn.Princeton.EDU (Muyu Guo) Subject: Re: Integration of Step function algorithm/code any? Message-ID: <1992Aug28.150316.21775@Princeton.EDU> Originator: news@nimaster Sender: news@Princeton.EDU (USENET News System) Nntp-Posting-Host: burn.princeton.edu Organization: Princeton University References: <1992Aug28.011918.22579@harlow.harvard.edu> Date: Fri, 28 Aug 1992 15:03:16 GMT Lines: 48