時間序列︰生成函數‧漸近展開︰白努利多項式之根《引言》

明代仇英繪《玉洞仙源圖》,現藏北京故宮博物院

桃花源

桃花源,出自陶淵明詩《桃花源詩》。詩的序《桃花源記》記述一個世俗的漁人偶然進入與世隔絕之地的奇遇記。

桃花源記

本文由晉朝文人陶淵明作於永初二年(421年),文章描繪了一個沒有戰亂,沒有壓迫,自給自足,人人自得其樂的社會,是當時的黑暗社會的鮮明對照,是作者與世人所嚮往的一種理想社會,它體現了人們的追求與想往,也反映出人們對現實的不滿與反抗。

原文

太元中,武陵人,捕魚為業。緣溪行,忘路之遠近。忽逢桃花林,夾岸數百步,中無雜樹,芳草鮮美,落英繽紛。漁人甚異之。復前行,欲窮其林。

林盡水源,便得一山。山有小口,彷彿若有光。便舍船,從口入。初極狹,纔通人。復行數十步,豁然開朗。土地平曠,屋舍儼然,有良田、美池、桑、竹之屬。阡陌交通,雞犬相聞。其中往來種作,男女衣著,悉如外人;黃髮、垂髫,並怡然自樂。

見漁人,乃大驚,問所從來。具答之。便要還家,設酒殺雞作食。村中聞有此人,咸來問訊。自雲先世避時亂,率妻子邑人來此絕境,不復出焉,遂與外人間隔。問今是何世,乃不知有,無論、晉。此人一一為具言所聞,皆嘆惋。餘人各復延至其家,皆出酒食。停數日,辭去。此中人語云:「不足為外人道也。」

既出,得其船,便扶向路,處處誌之。及下,詣太守說如此。太守即遣人隨其往,尋向所志,遂迷不復得路。

南陽劉子驥,高尚士也,聞之,欣然規往。未果,尋病終。後遂無問津者。

桃花源之美容易想像,桃花成林芳草落英怎不迷人!為何向路誌之不復得路呢?原居世外者自言︰不足為外人道也。無緣自是不得見的吧 。若問知性有美乎?果有,卻乏人問津?恐非無緣,怕是自己不想見哩!所以數學家到底在想些什麼?你非他,常常搞不懂也!不過就算是人非魚,有人能想出『出遊而從容,是魚之樂也。』? ?那麼數學家所樂真無法得之嗎!!

作者偶因靈感,

『豆鵝狐人』之問題就是

狐狸、鵝、豆子問題
狐狸、鵝、豆子問題〔又稱狼、羊、菜問題〕是一則古老的智力遊戲題。

問題
有一個農民到集市買了一隻狐狸、一隻鵝和一袋豆子,回家時要渡過一條河。河中有一條船,但是只能裝一樣東西。而且,如果沒有人看管,狐狸會吃掉鵝,而鵝又很喜歡吃豆子。問:怎樣才能讓這些東西都安全過河?

解答

第一步、帶鵝過河;
第二步、空手回來;
第三步、帶狐狸〔或豆子〕過河;
第四步、帶鵝回來;
第五步、帶豆子〔或狐狸〕過河;
第六步、空手回來;
第七步、帶鵝過河。

在此『問』的『問題』是︰

如何將之用 pyDatalog 語言『改寫重述』,使得可以用『程式』來執行『推理』,得到『答案』的呢?

─── 摘自《勇闖新世界︰ 《 pyDatalog 》 導引《十》豆鵝狐人之問題篇

 

,嘗寫序列文字,故而得識『豆鵝狐人』其人,得聞其事︰

我聽到有聲音說︰這裡是『數學桃花源』。我見到︰定義、原理、定律鱗次櫛比之實物。那裡概念栩栩如生,色香味俱全。嚇的我一覺醒來……

。已經有前車之鑑,豈敢造次??!!但其後又聞『符號算術』

bernoulli

class sympy.functions.combinatorial.numbers.bernoulli

Bernoulli numbers / Bernoulli polynomials

The Bernoulli numbers are a sequence of rational numbers defined by B_0 = 1 and the recursive relation (n > 0):

      n
     ___
    \      / n + 1 \
0 =  )     |       | * B .
    /___   \   k   /    k
    k = 0

They are also commonly defined by their exponential generating function, which is x/(exp(x) – 1). For odd indices > 1, the Bernoulli numbers are zero.

The Bernoulli polynomials satisfy the analogous formula:

          n
         ___
        \      / n \         n-k
B (x) =  )     |   | * B  * x   .
 n      /___   \ k /    k
        k = 0

Bernoulli numbers and Bernoulli polynomials are related as B_n(0) = B_n.

We compute Bernoulli numbers using Ramanujan’s formula:

                         / n + 3 \
B   =  (A(n) - S(n))  /  |       |
 n                       \   n   /

where A(n) = (n+3)/3 when n = 0 or 2 (mod 6), A(n) = -(n+3)/6 when n = 4 (mod 6), and:

       [n/6]
        ___
       \      /  n + 3  \
S(n) =  )     |         | * B
       /___   \ n - 6*k /    n-6*k
       k = 1

This formula is similar to the sum given in the definition, but cuts 2/3 of the terms. For Bernoulli polynomials, we use the formula in the definition.

  • bernoulli(n) gives the nth Bernoulli number, B_n
  • bernoulli(n, x) gives the nth Bernoulli polynomial in x, B_n(x)

See also

bell, catalan, euler, fibonacci, harmonic, lucas

References

[R91] http://en.wikipedia.org/wiki/Bernoulli_number
[R92] http://en.wikipedia.org/wiki/Bernoulli_polynomial
[R93] http://mathworld.wolfram.com/BernoulliNumber.html
[R94] http://mathworld.wolfram.com/BernoulliPolynomial.html

 

。心想又能探看『白努利多項式根』之鄉,或可不擾其清靜,因此方敢無所忌憚大膽說之也☆★

pi@raspberrypi:~ $ ipython3
Python 3.4.2 (default, Oct 19 2014, 13:31:11) 
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from sympy import *

In [2]: from sympy.plotting import plot

In [3]: init_printing()

In [4]: x = symbols('x')

In [5]: bernoulli(5,x)
Out[5]: 
        4      3    
 5   5⋅x    5⋅x    x
x  - ──── + ──── - ─
      2      3     6

In [6]: plot(bernoulli(5,x), (x, -1,2), ylim = (-0.5, 0.5))
Out[6]: <sympy.plotting.plot.Plot at 0x74d0cad0>

In [7]: solve(bernoulli(5,x))
Out[7]: 
⎡           1   √21    √21   1⎤
⎢0, 1/2, 1, ─ + ───, - ─── + ─⎥
⎣           2    6      6    2⎦

In [8]: