Public
Edited
Jul 24, 2024
Paused
Comments locked
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
r = (($_) => ($b === 10 && n < 0 ? $_.toFixed(Math.abs(n)) * 1 : $_))($b ** n)
Insert cell
Insert cell
Insert cell
Insert cell
Math.round(log(r) - n) /* tackle precision problem */ === 0
Insert cell
Insert cell
Insert cell
log($b ** x).toFixed(1) * 1 === x
Insert cell
Insert cell
($b ** log(x)).toFixed(1) * 1 === x
Insert cell
Insert cell
log(1) === 0
Insert cell
Insert cell
log($b) === 1
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
a = log(x * y)
Insert cell
b = log(x) + log(y)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
if (x < 0 || y < 0) {
throw new Error(`x and y must be positive numbers`);
}
yield a === b || Math.round(a - b) === 0; // expected output: true
}
Insert cell
Insert cell
display = (code, identifier = "JavaScript") =>
Object.assign(
md`> ~~~${identifier}
${code}
~~~`,
inline
)
Insert cell
inline = ({
style: [
["--gap", "1ch"],
["border-left", "1px solid var(--syntax-key)"],
["margin-left", "0"],
["padding-left", "var(--gap)"],
["padding-left", ".5rem"],
["max-width", "none"]
]
.map((declaration) => declaration.join(": "))
.join("; ")
})
Insert cell
Insert cell
Math.round(10 ** lg(42) - 42) === 0 // expected output: true
Insert cell
Math.round(lge - 1 / ln10) === 0 // expected output: true
Insert cell
Math.round(lgⅱe - 1 / ln2) === 0 // expected output: true
Insert cell
Math.exp(1) === e
Insert cell
10 ** lge === e
Insert cell
2 ** lgⅱe === e
Insert cell
ln(e) / ln(10) === 1 / ln10
Insert cell
ln(e) / ln(2) === 1 / ln2
Insert cell
lg(e) === lge
Insert cell
lgⅱ(e) === lgⅱe
Insert cell
Insert cell
lge = Math.LOG10E
Insert cell
lgⅱe = Math.LOG2E
Insert cell
ln10 = Math.LN10
Insert cell
ln2 = Math.LN2
Insert cell
e = Math.E
Insert cell
Insert cell
Insert cell
$q = ["Math.E", base + ""][+!!base]
Insert cell
$b = [e, base][+!!base]
Insert cell
log = table.get(base)
Insert cell
table = new Map([
["", ln],
[2, lgⅱ],
[10, lg]
])
Insert cell
lg = Math.log10
Insert cell
lgⅱ = Math.log2 /* thank you, Mathias Bynens! - mg */
Insert cell
ln = Math.log
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