Published
Edited
May 28, 2021
3 stars
Insert cell
Insert cell
0.1*0.2
Insert cell
Insert cell
// QQ is the class for rational numbers
x=(new QQ(1,10)).mult(new QQ(2,10))
Insert cell
tex`${x.tex}=${x.value}`
Insert cell
Insert cell
Insert cell
Insert cell
exp = {
let exp=new QQt()
exp.a=(n)=>new QQ(1, ZZ.factorial(n))
return exp
}
Insert cell
exp.TeX(8) // print the first few terms
Insert cell
Insert cell
Insert cell
exp.mult(exp).TeX(8)
Insert cell
Insert cell
Insert cell
{
let exp=new QQt((arr)=>{
let n=arr.length
return (n==0) ? new QQ(1n) : arr[n-1].div(n)})
return exp.TeX(8)
}
Insert cell
Insert cell
{
let Fib=(new QQt([1,-1,-1])).inverse()
return Fib.TeX(15)
}
Insert cell
Insert cell
Bernoulli={
const foo=new QQt(undefined, 0)
foo.a=(n)=>new QQ(1n, ZZ.factorial(n+1n))
return foo.inverse()
}
Insert cell
Bernoulli.TeX(13)
Insert cell
Insert cell
Bernoulli_numbers = {
let foo=new QQt()
foo.a=(n)=>Bernoulli.a(n).mult(ZZ.factorial(n))
return foo
}
Insert cell
Bernoulli_numbers.TeX(36)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bin24 = {
// let's save binomial coefficients
let bin=[1,1]
for (let i=1; i<24; i++) {
for (let j=i; j>0; j--)
bin[j]+=bin[j-1]
bin.push(1)
}
for (let i=1; i<24; i+=2) bin[i]*=-1
return new QQt(bin)
}
Insert cell
Delta = {
let foo=new QQt(undefined, 1)
foo.a=(n)=>{
n=BigInt(n)
let bar=new QQt([0,1])
for (let i=1; i<n; i++) {
bar=bar.mult(bin24.sub(i))
}
return bar.a(n)
}
return foo
}
Insert cell
Delta.TeX(10, 'q')
Insert cell
Insert cell
Eisenstein = function(k) { // Eisenstein series
k=BigInt(k)
let Ek=new QQt(undefined, 0)
Ek.a=(n)=>{
if (Ek.arr[n] != undefined) return Ek.arr[n]
let foo=new QQt([Bernoulli.a(k).div(-2n*k)])
let num=[0,1], den=[1,-1]
for (let i=1n; i<=n; i++) {
foo=foo.add((new QQt(num)).div(new QQt(den)))
num[i]=0; num.push((i+1n)**(k-1n));
den[i]=0; den.push(-1);
}
Ek.arr[n]=foo.a(n)
return foo.a(n)
}
return Ek
}
Insert cell
Eisenstein(4).TeX(3, 'q')
Insert cell
Insert cell
Insert cell
Insert cell
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