9827
Comment:
|
10286
|
Deletions are marked like this. | Additions are marked like this. |
Line 8: | Line 8: |
by Marshall Hampton. When the two frequencies are well seperated, we hear the right hand side of the identity. When they start getting close, we hear the higher-pitched factor in the left-hand side modulated by the lower-pitched envelope. {{{ |
by Marshall Hampton. When the two frequencies are well separated, we hear the right hand side of the identity. When they start getting close, we hear the higher-pitched factor in the left-hand side modulated by the lower-pitched envelope. {{{#!sagecell |
Line 28: | Line 28: |
def sinsound(freq_ratio = slider(0,1,1/144,1/12)): | def sinsound(freq_ratio = slider(1/144,1,1/144,1/12)): |
Line 41: | Line 41: |
html('<embed src="https:./test'+ lab +'.wav" width="200" height="100"></embed>') | html('<embed src="cell://test'+ lab +'.wav" width="200" height="100"></embed>') |
Line 49: | Line 49: |
{{{ | {{{#!sagecell |
Line 93: | Line 93: |
show(list_plot(s2f[0:2000],plotjoined=True), figsize = [6,4]) | show(list_plot(s2f[0:2000],plotjoined=True), figsize = [7,3.5]) |
Line 95: | Line 95: |
show(list_plot(s2f[20000:22000],plotjoined=True), figsize = [6,4]) | show(list_plot(s2f[20000:22000],plotjoined=True), figsize = [7,3.5]) |
Line 100: | Line 100: |
html('<embed src="https:./test'+ lab +'.wav" width="200" height="100"></embed>') | html('<embed src="cell://test'+ lab +'.wav" width="200" height="100"></embed>') |
Line 107: | Line 107: |
{{{ | {{{#!sagecell |
Line 163: | Line 163: |
{{{ | {{{#!sagecell |
Line 177: | Line 177: |
{{{ | {{{#!sagecell |
Line 184: | Line 184: |
print "<html>" # trick to avoid word wrap | |
Line 186: | Line 185: |
cProfile.run(cmd) | cProfile.runctx(cmd,globals(), locals()) |
Line 188: | Line 187: |
profile.run(cmd) print "</html>" |
profile.runctx(cmd,globals(), locals()) |
Line 197: | Line 195: |
{{{ | {{{#!sagecell |
Line 208: | Line 206: |
{{{ | {{{#!sagecell |
Line 254: | Line 252: |
by Pablo Angulo {{{ %cython |
by Pablo Angulo, Eviatar Bach {{{#!sagecell %python |
Line 259: | Line 258: |
def cellular(rule, int N): |
from random import randint def cellular(rule, N, initial='Single-cell'): |
Line 265: | Line 265: |
initial: starting condition; can be either single-cell or a random binary row | |
Line 266: | Line 267: |
cdef int j,k,l M=zeros( (N,2*N+1), dtype=int) M[0,N]=1 |
M=zeros( (N,2*N+2), dtype=int) if initial=='Single-cell': M[0,N]=1 else: M[0]=[randint(0,1) for a in range(0,2*N+2)] |
Line 271: | Line 274: |
for k in range(N-j,N+j+1): | for k in range(0,2*N): |
Line 274: | Line 277: |
return M }}} {{{ |
return M[:,:-1] |
Line 282: | Line 284: |
@interact def _( N=input_box(label='Number of iterations',default=100), |
}}} Put in separate cell: {{{#!sagecell @interact def _( initial=selector(['Single-cell', 'Random'], label='Starting condition'), N=input_box(label='Number of iterations',default=100), |
Line 286: | Line 290: |
size = slider(1, 11, step_size=1, default=6 ) ): | size = slider(1, 11, label= 'Size', step_size=1, default=6 ), auto_update=False): |
Line 288: | Line 292: |
M = cellular(rule, N) plot_M = matrix_plot(M) |
M = cellular(rule, N, initial) plot_M = matrix_plot(M, cmap='binary') |
Line 292: | Line 296: |
{{attachment:cellular.png}} | {{attachment:cellular2.png}} |
Sage Interactions - Miscellaneous
goto interact main page
Contents
Hearing a trigonometric identity
by Marshall Hampton. When the two frequencies are well separated, we hear the right hand side of the identity. When they start getting close, we hear the higher-pitched factor in the left-hand side modulated by the lower-pitched envelope.
Karplus-Strong algorithm for plucked and percussive sound generation
by Marshall Hampton
An Interactive Venn Diagram
Unreadable code
by Igor Tolkov
Profile a snippet of code
Evaluate a bit of code in a given system
by William Stein (there is no way yet to make the text box big):
Minkowski Sum
by Marshall Hampton
Cellular Automata
by Pablo Angulo, Eviatar Bach
Put in separate cell: