Published
Edited
Jan 23, 2020
1 fork
Importers
4 stars
Insert cell
Insert cell
Insert cell
cadd = function cadd([x0, y0], [x1, y1]) {
return [x0 + x1, y0 + y1]; }
Insert cell
csub = function csub([x0, y0], [x1, y1]) {
return [x0 - x1, y0 - y1]; }
Insert cell
cmul = function cmul([x0, y0], [x1, y1]) {
return [x0*x1 - y0*y1, x0*y1 + y0*x1]; }
Insert cell
conj = function conj([x, y]){
return [x, -y]; }
Insert cell
cinv = function cinv([x, y]) {
const scale = 1 / (x*x + y*y);
return [scale * x, -scale * y]; }
Insert cell
cdiv = function cdiv(z0, z1) {
return cmul(z0, cinv(z1)); }
Insert cell
clerp = function clerp([x0, y0], [x1, y1], t) {
return [x0 * (1 - t) + x1 * t, y0 * (1 - t) + y1 * t]; }
Insert cell
imag = function imag([x, y]) {
return y; }
Insert cell
real = function real([x, y]) {
return x; }
Insert cell
clog = function clog([x, y]) {
return [0.5*Math.log(x*x + y*y), Math.atan2(y, x)]; }
Insert cell
cexp = function cexp([x, y]) {
const scale = Math.exp(x);
return [scale * Math.cos(y), scale * Math.sin(y)]; }
Insert cell
ccos = function ccos([x, y]) {
return [Math.cos(x) * Math.cosh(y), -Math.sin(x) * Math.sinh(y)]; }
Insert cell
csin = function ccos([x, y]) {
return [Math.sin(x) * Math.cosh(y), Math.cos(x) * Math.sinh(y)]; }
Insert cell
cpow = function cpow(z1, z2) {
return cexp(cmul(clog(z1), z2)); }
Insert cell
cabs = function cabs([x, y]) {
return Math.sqrt(x*x + y*y); }
Insert cell
phase = function phase([x, y]) {
return Math.atan2(y, x); }
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