The set of interactive pages with the following structure:
Example of Computations
Click the
@interact
def _(N=(47,0,-1)):
var('x,y')
p=implicit_plot(sin(x)-cos(x),(0,4*pi),(-1,1),linestyle=':')
p+=sum([plot((sin(x),cos(x)),(pi*n/12,pi*(n+1)/12),
thickness=12,alpha=.7,
color=colormaps.jet(6*n)[:3])
for n in [0..N]])
p.show(aspect_ratio=4,gridlines=True,figsize=7)
Type your own SageMath code lines below and click the
xxxxxxxxxx
var('x,y,z')
f1=x^2/9+y^2/16-z^2/25-1; f2=x^2/4+y^2/9-z^2/16
implicit_plot3d(f1,(x,-7,7),(y,-7,7),(z,-7,7),contour=0,
color='#ff3636',opacity=.3,
plot_points=20,mesh=True)+\
implicit_plot3d(f2,(x,-7,7),(y,-7,7),(z,-7,7),contour=0,
color='#3636ff',opacity=.5,frame=False)
This code cell was evaluated automatically.
xxxxxxxxxx
def _(N=(1,12,1)):
p=sum(plot(sin(x-2*k)-x^2,x,hue=sin(k/N))
for k in [-1.4,-1.3,..,1.5])
p.show(figsize=(7,5),gridlines=True)
xxxxxxxxxx
bc=Words(alphabet=[0,1],length=10); c=0
def lf(x):
eq1=(x[0] | (not x[1])) & (x[2] | (not x[3]))
eq2=(x[2] | (not x[3])) & (x[4] | (not x[5]))
eq3=(x[4] | (not x[5])) & (x[6] | (not x[7]))
eq4=(x[6] | (not x[7])) & (x[8] | (not x[9]))
return (eq1 & eq2 & eq3 & eq4)
for el in bc: c+=int(lf(el))
pretty_print(html('<p>true values: %d</p>'%c))
table([[(bc[i*10+j],lf(bc[i*5+j]))
for j in range(5)] for i in range(10)])
xxxxxxxxxx
# 1000 data points, 4 clusters
import pylab; from sklearn import datasets,mixture
from sklearn.model_selection import train_test_split
bd=datasets.make_blobs(
n_samples=1000,cluster_std=.5,
centers=[[1,1],[-1,-1],[1,-1],[-1,1]])
X_train,X_test,y_train,y_test=\
train_test_split(bd[0],bd[1],test_size=float(.2),random_state=1)
usl=mixture.BayesianGaussianMixture(n_components=4,n_init=4)
usl.fit(X_train,y_train); y_predict=usl.predict(X_test)
pylab.figure(figsize=(7,5)); pylab.grid()
pylab.scatter(X_test[:,0],X_test[:,1],c=y_test,
s=70,alpha=.5,cmap=pylab.cm.summer)
pylab.scatter(X_test[:,0]+.03,X_test[:,1]+.03,c=y_predict,
s=50,alpha=.5,cmap=pylab.cm.winter)
pylab.scatter([1,-1,1,-1],[1,-1,-1,1],c='#3636ff',
marker='*',s=500,alpha=.7)
pylab.show()
xxxxxxxxxx
%%r
A<-matrix(rexp(25,rate=.1),nrow=5,ncol=5);
norm_type<-c('O','I','F','M','2')
for (t in norm_type) {cat(t,norm(A,type=t),'\n')}; A
xxxxxxxxxx
%%html
<style>
import 'https://fonts.googleapis.com/css?family=Sancreek&effect=3d';
</style>
<p style='font-family:Sancreek; font-size:300%;' class='font-effect-3d'>
<text style='color:#ff3636;'>Sancreek Font</text> &
<text style='color:#3636ff;'>3D Effect</text></p>