2011-10-15 23 views
4

我想測試幾個強度值。對數間距編號

我需要他們對數從1到1000間隔不過我只是用1,10,100,1000,但我想有更多的數據點,突然想到說10

如何我可以在Mathematica中找到10對數間隔1和1000之間的數字嗎?

回答

17

如果a是開始,c是結束,b是間隔的號碼:

{a, b, c} = {1, 10, 1000}; 
t = (c/a)^(1/b) // N 
a*t^Range[b] 

1.99526 
{1.99526, 3.98107, 7.94328, 15.8489, 31.6228, 63.0957, 125.893, 251.189, 501.187, 1000.} 

我以前N只是爲了看得更清楚,我們有什麼。

+1

我打算髮布一些非常相似的東西,但是你在2秒內擊敗了我。順便說一下,'Power'是'Listable',所以你可以簡單地做'a * t^Range [b]'。 – Heike

+0

@喜歡,好!更新。在發佈後30分鐘,我在RSS中發現了這個問題。這是我的第一個Mathematica答案,所以我試圖做得很快...... P – Nakilon

+1

@Nakilon您可以使用'Range [0,b]'作爲列昂尼德從'a'開始的完整列表。 –

4

解方程x ** 9 = 1000 - 那麼你的號碼是:x ** 0x ** 1,... x ** 9

注:其中x ** y意味着xy

7

這裏的電力是一種方法:

In[11]:= base = Block[{a}, a /. NSolve[a^9 == 1000, a][[-1, 1]]] 
Out[11]= 2.15443 

In[13]:= base^Range[0, 9] 
Out[13]= {1., 2.15443, 4.64159, 10., 21.5443, 46.4159, 100., 
    215.443,464.159, 1000.} 

編輯

這裏是一個更短,更直接的方式來獲得相同:

In[18]:= N[10^Range[0, 3, 1/3]] 

Out[18]= {1., 2.15443, 4.64159, 10., 21.5443, 46.4159, 100., 
215.443, 464.159, 1000.} 
+0

謝謝Leonid,你介意使用「Block」還是「/」。 &好奇的「[[-1,1]]」。它有效,但我無法掌握這種語法。 – 500

+0

@ 500我認爲使用NSolve [a^9 == 1000,a,Reals]會更清晰。可以使用[Formal Symbol](http://reference.wolfram.com/mathematica/tutorial/LettersAndLetterLikeForms.html#173509264)['\ [FormalA]'](http://reference.wolfram。 com/mathematica/ref/character/FormalA.html),同樣的成功:'base = \ [FormalA] /。NSolve [\ [FormalA]^9 == 1000,\ [FormalA],Reals] // First'。 「'/ .'」只是['ReplaceAll'](http://reference.wolfram.com/mathematica/ref/ReplaceAll.html)。 –

+0

@ 500我認爲,使用'base = N [Power [1000,1/9]]'要容易得多。實際上,'base'是'10'的立方根。不知道我在想什麼。 –