Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: In which interval?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13317] Re: In which interval?
  • From: Daniel Lichtblau <danl>
  • Date: Mon, 20 Jul 1998 02:49:32 -0400
  • Organization: Wolfram Research, Inc.
  • References: <6oklgc$1nq@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Pal Lillevold wrote:
> 
> I need to resolve the following problem:
> 
> Given N distinct real Intervals (x(i),x(i+1)); i=1,,,,N and a real
> number R - in which interval is R located. In other words to identify
> the unique value of i such that x(i)<=R<x(i+1). This is easy to do by
> straight forward checking which value of the N i's which match the
> inequalities. But this is very time-consuming when the number N is
> large. Has anyone been confronted with this problem and resolved it
> efficiently? I would highly appreciate any assistance.
> 
> Thank you in advance and best regards.
> 
> Pal Lillevold

If you plan to do this many times with different values for R, it is
best to presort the intervals (which may be slow for large N) and then
do a binary search for each specific R.

Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: Stacking Graphics
  • Next by Date: Re: Fast help for circle problem
  • Previous by thread: Re: In which interval?
  • Next by thread: Re: In which interval?