Public
Edited
Dec 26, 2021
1 fork
Insert cell
Insert cell
viewof x = Inputs.number({value: 4, label: "Enter the number:"})
Insert cell
jazr(x)
Insert cell
function averageDamp(f){
let average = (q, w) => (q + w) / 2;
return x => average(x, f(x));
}
Insert cell
function fixedPoint(f, current){
let threshold = current / 1e6;
let next = f(current);
if (Math.abs(next - current) < threshold) return current;
else return fixedPoint(f, next);
}
Insert cell
function jazr(x){
if (x == 0.0) return 0.0
else return fixedPoint(averageDamp(y => x / y), 1.0);
}
Insert cell
Insert cell
range = [...Array(11).keys()];
Insert cell
a1 = range.map(jazr)
Insert cell
a2 = range.map(Math.sqrt)
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