Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Subdivide an interval such that the ratio of subsequent elements is constant
| ResourceFunction["PowerSubdivide"][xmax,n] generates the list of values obtained by subdiving the interval from 1 to xmax into n parts such that the ratio of subsequent elements is constant. | |
| ResourceFunction["PowerSubdivide"][xmin,xmax,n] generates the list of values obtained by subdiving the interval from xmin to xmax into n parts such that the ratio of subsequent elements is constant. | 
Subdivide the range 10–10000 in 3 steps:
| In[1]:= | ![ResourceFunction["PowerSubdivide"][10, 10000, 3]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/59fee09a3c98ad51.png) | 
| Out[1]= |  | 
With two arguments, the start of the sequence is assumed to be 1:
| In[2]:= | ![ResourceFunction["PowerSubdivide"][1000, 10]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/15279fd3bae6b9f3.png) | 
| Out[2]= |  | 
PowerSubdivide works on symbolic entries:
| In[3]:= | ![ResourceFunction["PowerSubdivide"][a, b, 4]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/10609275a966b58c.png) | 
| Out[3]= |  | 
xmin can be larger than xmax:
| In[4]:= | ![ResourceFunction["PowerSubdivide"][1000, 10, 4]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/48ad04b32ad56f96.png) | 
| Out[4]= |  | 
PowerSubdivide gives points that are "logarithmically useful" for plotting on a logarithmic scale:
| In[5]:= | ![ListLogLogPlot[
 Table[{x, x^2}, {x, ResourceFunction["PowerSubdivide"][10, 10^6, 40]}]]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/7fec8dbad40cb4c2.png) | 
| Out[5]= |  | 
The ratio between subsequent values is constant:
| In[6]:= | ![Ratios[ResourceFunction["PowerSubdivide"][a, b, 8]]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/2b67fac9d4a41231.png) | 
| Out[6]= |  | 
PowerSubdivide is related to Subdivide:
| In[7]:= | ![ResourceFunction["PowerSubdivide"][10, 20, 8] == Exp[Subdivide[Log[10], Log[20], 8]]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/3f764a63116cdad7.png) | 
| Out[7]= |  | 
Negative and positive end points results in intermediate values in the complex plane:
| In[8]:= | ![ComplexListPlot[ResourceFunction["PowerSubdivide"][-10, 25, 40]]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/03ea05a96c838411.png) | 
| Out[8]= |  | 
Calculate the geometric mean of two values:
| In[9]:= | ![ResourceFunction["PowerSubdivide"][6.0, 10.0, 2][[2]]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/6b9e2e729e85c44c.png) | 
| Out[9]= |  | 
Compare to the built-in function:
| In[10]:= | ![GeometricMean[{6.0, 10.0}]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/4f2d4b95e667fd14.png) | 
| Out[10]= |  | 
If the start or end is a negative number, intermediate values might be complex numbers:
| In[11]:= | ![ResourceFunction["PowerSubdivide"][-1.0, 1.0, 10]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/6e078454c09d9453.png) | 
| Out[11]= |  | 
If both end points are negative real numbers, Chop might be needed to remove approximate zeros:
| In[12]:= | ![values = ResourceFunction["PowerSubdivide"][-1.0, -100.0, 10]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/473b8170cd64c0df.png) | 
| Out[12]= |  | 
| In[13]:= | ![Chop[values]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/2ecb151430092c13.png) | 
| Out[13]= |  | 
Because Log(0) equals -∞, all but the last entry will be 0:
| In[14]:= | ![ResourceFunction["PowerSubdivide"][0, 100, 10]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/78e82b2069e0e1a4.png) | 
| Out[14]= |  | 
Connect pairs of random complex numbers:
| In[15]:= | ![SeedRandom[1];
ComplexListPlot[
 ResourceFunction["PowerSubdivide"][##, 40] & @@@ RandomComplex[{-10 - 10 I, 10 + 10 I}, {100, 2}], Joined -> True]](https://www.wolframcloud.com/obj/resourcesystem/images/518/518b225a-3b21-4865-a62a-0ffbf4bca70b/72d34af66eec9aa0.png) | 
| Out[16]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License