Published
Edited
Dec 1, 2020
4 forks
16 stars
Insert cell
Insert cell
Insert cell
Insert cell
Algebra(0,1,()=>(3+2e1)*(1+4e1))
Insert cell
Insert cell
Algebra(0,1,()=>1e1)
Insert cell
Algebra(0,1,()=>1E1)
Insert cell
Insert cell
r = Algebra(0,0,1,()=>{
var f = (t)=>(t**2+4)*(t-6);
return f(3+1e0);
})
Insert cell
Insert cell
Insert cell
even = Algebra(()=>[1,2,3,4,5]*2)
Insert cell
Insert cell
Algebra(()=>[1,2,[3,4]]+[3,2,1]+1)
Insert cell
Insert cell
Algebra(0,1,()=>[3+2e1,3-2e1]*(1+4e1))
Insert cell
Insert cell
Algebra(()=>[2,0,1]*[1,1,0])
Insert cell
Insert cell
Algebra(0,1,()=>[[0,1e1],[1e1,0]]*[1e1,1])
Insert cell
Insert cell
RK4 = Algebra(3).inline((func,state,delta,steps)=>{
while(steps--){
var k1 = func(state),
k2 = func(state+0.5*delta*k1),
k3 = func(state+0.5*delta*k2),
k4 = func(state+delta*k3);
state = state+delta/6*(2*(k2+k3)+k1+k4);
}
return state;
})
Insert cell
Insert cell
RK4(x=>x,1,0.02,50)
Insert cell
Insert cell
RK4(x=>[x[1],-x[0]],[1,0],0.02,50)
Insert cell
Insert cell
RK4(x=>[x[0],[x[1][1],-x[1][0]]], [1,[1,0]], 0.02, 50)
Insert cell
Insert cell
Insert cell
Algebra(0,2,()=>{
var axis=(1e1+1e2+1e12).Normalized;
return this.graph((x,y)=>{
var xx= Math.atan2(y,x);
var c=1e2, rot=Math.E**(xx/2*axis);
return ((2-(x**2+y**2)**0.5)*(rot*c*rot.Conjugate)).slice(1);
});
})
Insert cell
Insert cell
Insert cell
Insert cell
Algebra(2,0,1,()=>this.graph([1e12,"origin",1e1,1e2]))
Insert cell
Insert cell
Algebra(2,0,1,()=>this.graph([
0x0000FF, 1e12, 1e1, 1e2,
0x000000, 1e12-1e02-1e01, "point",
0xff0000, [1e12+1e01,1e12+1e01+1e02], "segment",
0x007700, [1e12-1e01,1e12-1e01+1e02,1e12], 0x000000, "polygon"
]))
Insert cell
Insert cell
Algebra(2,0,1,()=>{
var pA = 1e12 - 0.5e02,
pB = 1e12 - 1e01;
return this.graph([
pA, "pA",
pB, "pB",
()=>pA&pB, "()=>pA & pB"
])
// the last element of the array above is a function, so that the line gets
// recalculated each time the graph updates (when you drag one of the points)

})
Insert cell
Insert cell
Algebra(3,1,()=>{
var eo = .5e3+.5e4,
ei = 1e4-1e3;
var point = (x)=> eo + x + x**2/2*ei;
var a = point(1.5e2),
b = point(-1e1 - 0.4e2),
c = point(1e1 + 0.3e2);
return this.graph([a,"a",b,"b",c,"c",()=>a^b^c],{conformal:true})
})
Insert cell
Insert cell
Algebra(4,1,()=>{
var eo = .5e5-.5e4,
ei = 1e5+1e4;
var point = (x)=> eo + x + x**2/2*ei;
var a = point(1.5e2+.5e3),
b = point(-1e1 - 0.4e2 +1e3),
c = point(1e1 + 0.3e3),
d = point(1e3);
return this.graph(
[0x8800ff,a,"a",b,"b",c,"c",d,"d",()=>a^b^c^d],
{conformal:true, height:'400px', width:'50%', gl:true}
)
})
Insert cell
Insert cell
Algebra(3,0,1,()=>{
// circle is a function of two parameters, radius and bivector, that returns
// a function of one parameter, 0<t<1, that returns a motor describing the
// motion around a circle.
var circle = (r,biv)=>(t)=>Math.E**(Math.PI*t*biv) * Math.E**(r*1e03);

var c1 = circle(0.3, 1e23),
c2 = circle(0.05, 1e13),
c3 = circle(0.1, 1e23),
torus = (x,y)=>c1(x)*c2(y);
//return this.graph([],{gl:1})
// rendering a 1-parameter function produces a curve
// rendering a 2-parameter function produces a surface
return this.graph([0x0000ff,torus,0xff0000,c3],{gl:true, width:'100%', height:'400px'})
})
Insert cell
Algebra = require('ganja.js')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more