Sunday, December 4, 2016

Python: Returning Polynomial Function

Command:

$ cat makePoly.py 


Result:

# ax + b
def makePoly(arr):
    def fn(x):
        return sum(c*x**p for p,c in enumerate(arr))
    return fn

my_func = makePoly([6, 2])
print my_func(3) #return 12


Command:

$ python makePoly.py 


Result:

12

Python: Pi and Natural Logarithm

Command:

$ cat pi_and_natural_logarithm.py


Result:

import math

print 'Pi: %.30f' % math.pi
print 'e: %.30f' % math.e


Command:

$ python pi_and_natural_logarithm.py


Result:

Pi: 3.141592653589793115997963468544
e: 2.718281828459045090795598298428


Momoko Tsugunaga (嗣永桃子): PON!: ももち 卒業について告白!

Momoko Tsugunaga


  • 思ったより人気が出なかった

Robert Krulwich & Jonathan Borwein & Keith Devlin & Marcus du Sautoy & Simon Singh: World Science Festival: Mysteries of the Mathematical Universe

Robert Krulwich
Simon Singh
Marcus du Sautoy
Jonathan Borwein
Keith Devlin

Saturday, December 3, 2016

Python: Farey Sequence: The Farey sequences of orders 8

Command:

$ cat farey.py


Result:

def farey( n, asc=True ):
    if asc:
        a, b, c, d = 0, 1, 1 , n
    else:
        a, b, c, d = 1, 1, n-1, n
    print "%d/%d" % (a,b)
    while (asc and c <= n) or (not asc and a > 0):
        k = int((n + b)/d)
        a, b, c, d = c, d, k*c - a, k*d - b
        print "%d/%d" % (a,b)
farey(8)


Command:

$ python farey.py


Result:

0/1
1/8
1/7
1/6
1/5
1/4
2/7
1/3
3/8
2/5
3/7
1/2
4/7
3/5
5/8
2/3
5/7
3/4
4/5
5/6
6/7
7/8
1/1

Francis Bonahon (フランシス・ボナホン): Numberphile: Funny Fractions and Ford Circles

Francis Bonahon
Augustin-Louis Cauchy



  • Funny addition
  • Farey addition
  • Farey sum

Tadashi Tokieda (時枝正): Numberphile: A Strange Change of Rotation

Tadashi Tokieda

Ryoichi Taguchi (田口良一) & SEKAI NO OWARI: ミュージック・ポートレイト: 第一夜

Ryoichi Taguchi