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