Public
Edited
Dec 25, 2022
Fork of MathCell
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// https://paulmasson.github.io/mathcell/docs/examples/jacobi-sn-complex-lines.html
jacobi = createMathCell({
visibility,
style: "height: 6in",
inputs: [
{ type: "slider", max: 3, default: 0.9, name: "a", label: "a" },
{ type: "slider", max: 3, default: 1, name: "b", label: "b" },
{ type: "slider", max: 1, default: 0.5, name: "m", label: "m" },
{ type: "checkbox", name: "three", label: "Show in three dimensions:" }
],
config: (lib, { id }) => ({
type: lib.getVariable(id, "three") ? "threejs" : "svg"
}),
data: (lib, { id }) => {
var a = lib.getVariable(id, "a");
var b = lib.getVariable(id, "b");
var m = lib.getVariable(id, "m");

var rate = 0.1;

function vectorFunction(x) {
var z = math.sn(math.mul(math.complex(a, b), x), m);
return [z.re, z.im, rate * x];
}

var curve = lib.parametric(vectorFunction, [0, 100, 5000]);

curve[0].points.forEach((p) => {
if (Math.hypot(p[0], p[1]) > 50)
console.log(
`JacobiSN[${lib.roundTo(
p[2] / rate,
2,
false
)}*(${a}+${b}I),${m}] = ${p[0]} ${p[1] > 0 ? "+" : ""}${p[1]}i`
);
});

return [curve];
}
})
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