The set of interactive pages with the following structure:
Example of Computations
Click the
@interact
def _(a=[3,2,1],b=[3,2,1],c=[3,2,1]):
s='$x(t)=sin(%s*t)^2; y(t)=cos(%s*t)^3; '+\
'z(t)=sin(%s*t)*ln(t+1)$'
pretty_print(html('<p style=%s>'%'font-size:140%;'+\
s%(a,b,c)+'</p>'))
f=lambda p:(sin(a*p)^2,cos(b*p)^3,sin(c*p)*ln(p+1))
t=Tachyon(xres=700,yres=700,camera_center=(-4,-6,1))
t.texture('t1',color=(0,0,.3),opacity=.5)
t.texture('t2',color=(.9,.9,.9),texfunc=2)
t.parametric_plot(f,0,6*pi,'t1',r=.03)
t.plane((7,7,-7),(0,-1,1),'t2')
t.light((-8,-6,4),1,(1,1,1)); t.show()
Type your own SageMath code lines below and click the
xxxxxxxxxx
t=Tachyon(camera_center=(2,6,2.5),look_at=(2,0,0),raydepth=10)
t.texture('mirror',ambient=.01,diffuse=.01,
specular=.9,opacity=.9,color=(.3,.3,.3))
t.texture('t1',texfunc=1)
t.texture('t2',color=(0,.1,.6),texfunc=2)
t.plane((0,0,0),(0,0,1),'t1'); t.plane((0,0,3),(0,0,4),'t2')
t.sphere((4,-1,1),1,'mirror'); t.sphere((0,-1,1),1,'mirror')
t.sphere((2,-1,1),.5,'mirror'); t.sphere((2,2,1),.5,'mirror')
t.light((7,7,1),1,(2,2,1)); show(t)
This code cell was evaluated automatically.
xxxxxxxxxx
def _(proj=['perspective','fisheye','perspective_dof'],
cm=['hsv','jet','cool','hot','prism']):
k=1; e=[[[k,-k,k],[0,0,0]],[[0,0,0],[k,k,k]],
[[k,k,k],[-k,k,k]],[[-k,k,k],[-k,-k,k]],
[[-k,-k,k],[k,-k,k]],[[k,-k,k],[k,k,k]],
[[k,k,k],[k,k,-k]],[[k,k,-k],[-k,k,-k]],
[[-k,k,-k],[-k,-k,-k]],[[-k,-k,-k],[k,-k,-k]],
[[k,-k,-k],[k,k,-k]],[[k,k,-k],[0,0,0]],
[[0,0,0],[k,-k,-k]],[[k,-k,-k],[k,-k,k]]]
if proj=='perspective_dof':
t=Tachyon(xres=500,yres=500,projection=proj,
camera_center=(-3.5,0.,0.),
antialiasing=3,raydepth=5,
focallength='2.',aperture='.003')
else: t=Tachyon(xres=500,yres=500,projection=proj,
camera_center=(-3.5,0.,0.))
for i in [0..13]:
t.texture('t%s'%str(i),opacity=.3,
color=colormaps[cm](.077*i)[:3])
t.fcylinder(e[i][0],e[i][1],.06,'t%s'%str(i))
t.light((-5,-5,5),.1,(1,1,1)); t.show()
xxxxxxxxxx
y(k,x)=x^2*k^2-12*x^2+k^2*x-3*sqrt(3)*k*x+6*x+k^2-sqrt(3)*k-6
pretty_print(html('<p>$y=%s$</p>'%latex(y(k,x))))
n=31; k=[.12*i for i in [0..n]]
c=[colormaps.hsv(.03*i)[:3] for i in [0..n]]
p=sum([plot(y(k[i],x),(x,-2,2),color=c[i],
legend_label='%.2f'%k[i]) for i in [0..n]])
p.set_legend_options(loc=(1.1,-.1))
p.show(ymin=-8,ymax=2,figsize=(7,5),gridlines=True)
xxxxxxxxxx
import numpy,pylab,time
from sklearn import manifold,datasets
X,y=datasets.load_digits(return_X_y=True)
tsne=manifold.TSNE(n_components=2,learning_rate=700.)
t0=time.time(); X_emb=tsne.fit_transform(X)
t=time.time()-t0
x_min,x_max=numpy.min(X_emb,0),numpy.max(X_emb,0)
X_emb=(X_emb-x_min)/(x_max-x_min)
f,ax=pylab.subplots(1,figsize=(7,7))
for i in range(X_emb.shape[0]):
pylab.text(X_emb[i,0],X_emb[i,1],str(y[i]),
color=pylab.cm.hsv(.1*y[i]))
pylab.title('t-SNE embedding %f s'%t)
pylab.axis('off'); pylab.show()
xxxxxxxxxx
%%r
library('MASS'); library('nnet'); data(Boston); n<-dim(Boston)[1];
svg(filename='Rplots.svg',width=7,height=4,pointsize=12,
onefile=T,family='courier',bg='white',
antialias=c('default','none','gray','subpixel'))
model<-nnet(as.matrix(Boston[1:430,-14]),as.matrix(Boston[1:430,14]),
size=42,trace=F,maxit=1.5*10^3,linout=T,decay=5*.1^4)
predictions<-predict(model,as.matrix(Boston[431:n,-14]),type='raw')
plot(as.matrix(Boston[431:n,14]),col='#3636ff',type='o',
xlab='',ylab='',yaxt='n'); par(new=T)
plot(predictions,col='#ff3636',type='o',
cex=1.3,ylab='Targets & Predictions'); dev.off()
<script src='https://d3js.org/d3.v4.min.js'></script> was added in the page head.
xxxxxxxxxx
%%html
<style>#svg1 {background-color:silver;}
text {fill:#fff; font-size:135%;}
.line {fill:none; stroke:#3636ff; stroke-width:2;}
.grid line,.grid path {stroke:#fff; stroke-opacity:.9;
shape-rendering:crispEdges;}
</style><svg id='svg1'/><script>
var n=630,m=35,margin={top:m,right:m,bottom:m,left:m},
width=500-margin.left-margin.right,
height=500-margin.top-margin.bottom;
var xScale=d3.scaleLinear().domain([-2,2]).range([0,width]),
yScale=d3.scaleLinear().domain([-2,2]).range([height,0]);
function make_x_gridlines() {return d3.axisBottom(xScale).ticks(11)};
function make_y_gridlines() {return d3.axisLeft(yScale).ticks(11)};
var data=d3.range(0,n).map(function(i){return {
'x':Math.cos(.01*i)+Math.cos(.11*i)/2+Math.sin(.3*i)/3,
'y':Math.sin(.01*i)+Math.sin(.11*i)/2+Math.cos(.3*i)/3}});
var tt1='translate('+margin.left+','+margin.top+')',
tt2='translate(0,'+height+')';
var lineColor=d3.scaleSequential().domain([0,n])
.interpolator(d3.interpolateCool);
var svg=d3.select('#svg1')
.attr('width',width+margin.left+margin.right)
.attr('height',height+margin.top+margin.bottom)
.append('g').attr('transform',tt1);
svg.append('g').attr('class','x axis')
.call(d3.axisBottom(xScale).tickSize(.5)).attr(tt2);
svg.append('g').attr('class','y axis')
.call(d3.axisLeft(yScale).tickSize(.5));
svg.append('g').attr('class','grid').attr('transform',tt2)
.call(make_x_gridlines()
.tickSize(-height).tickFormat(''));
svg.append('g').attr('class','grid').call(make_y_gridlines()
.tickSize(-width).tickFormat(''));
var line=d3.line().curve(d3.curveMonotoneX)
.x(function(d) {return xScale(d.x);})
.y(function(d) {return yScale(d.y);});
svg.append('path').datum(data).attr('class','line').attr('d',line);