Thursday, December 19, 2019

🏙 Thebe Experiments 01 with Live SageMath Coding.

🌐   thebe_01.html

✒️   Cell #1

    sage: var('t'); n=3; d={2*i+1:[2*i+2] for i in [0..6]}
    sage: c=[colormaps.ocean(24*k)[:3] for k in [0..10]]
    sage: p=polar_plot([(t+k/n)*log(t/n) for k in [0..10]],
    sage:              0,n*pi,color=c,fill=d,fillcolor=c)
    sage: ti=r'$f=(t+k/%d)'%n+' \cdot \log(t/%d)'%n+', k \in \{0,1,...,10\}$'
    sage: p.show(title=ti,fontsize=12,figsize=5)

✒️   Cell #2

    sage: @interact
    sage: def _(a=[7,9,..,17],b=[10,12,..,20]):
    sage:     x(t)=cos(t)+cos(a*t)/2+sin((a+b)*t)/3
    sage:     y(t)=sin(t)+sin(a*t)/2+cos((a+b)*t)/3
    sage:     def col(c): return colormaps.hsv(5*c)[:3]
    sage:     p=sum([parametric_plot((x,y),(t,(i-1)*pi/24,i*pi/24),
    sage:                            color=col(i)) for i in [1..48]])
    sage:     p.show(aspect_ratio=1,figsize=7,gridlines=True)

✒️   Cell #3

    sage: %%r
    sage: elements<-c('☜','☞','☝︎','☟')
    sage: n<-length(elements)
    sage: S<-unique(t(sapply(1:10^3,function(x) sample(elements,n)))) 
    sage: S<-apply(S,1,function(x) paste0(x,collapse=''))
    sage: print(length(S)==factorial(4)); S

No comments:

Post a Comment