PowerRange

PowerRange[b]

generates the list {1,10,100,,max}, where max is the largest power of 10 that does not exceed b.

PowerRange[a,b]

generates the list {a,10a,100a,,max}, with successive elements increasing by factors of 10.

PowerRange[a,b,r]

uses factors of r instead of 10.

Details

  • PowerRange effectively behaves like Range, but in "log-space".
  • The arguments a and b to PowerRange need not be integers or powers of r, but must be either both positive or both negative.
  • PowerRange starts from a and successively multiplies by r until the result is larger than b.
  • If b/a is not a power of r, the endpoint b will not be included in the list generated by PowerRange.

Examples

open allclose all

Basic Examples  (2)

Generate a list of powers of 10 from 1 to 1 million:

Generate a list of powers of 2 less than a hundred:

Scope  (3)

Specify a power other than 10:

A range with negative numbers:

Parameters need not be numeric:

Properties & Relations  (3)

PowerRange produces lists whose elements have a constant ratio:

Range produces lists whose elements have a constant difference:

PowerRange can be implemented with NestWhileList:

PowerRange produces an explicit list of values with a constant ratio:

RSolveValue generates a formula for generating such a list:

Introduced in 2014
 (10.0)