Published
Edited
Nov 20, 2020
Importers
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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more