Published
Edited
Feb 10, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Compile the function specified in the input
f = {
let f_compiled = math.compile(f_text);
return x => f_compiled.evaluate({ x: x });
}
Insert cell
// Maximum number of terms
N = 100
Insert cell
// Aproximate max for plotting purposes
fmax = d3.max(
d3
.range(0, L, L / 5)
.map(function(x) {
return minimize(x => -f(x), {
lowerBound: x,
upperBound: x + L / 5
});
})
.map(f)
)
Insert cell
// Aproximate min for plotting purposes
fmin = d3.min(
d3
.range(0, L, L / 5)
.map(function(x) {
return minimize(f, {
lowerBound: x,
upperBound: x + L / 5
});
})
.map(f)
)
Insert cell
Insert cell
bn = {
let bn_compiled = math.compile(bn_text);
return k => bn_compiled.evaluate({ n: k });
}
Insert cell
d3.range(1, 11).map(bn)
Insert cell
function fourier_series(x, n) {
return d3.sum(
d3.range(1, n).map(k => fc[k - 1] * Math.sin((k * Math.PI * x) / L))
);
}
Insert cell
fc = d3.range(1, n).map(bn)
Insert cell
Insert cell
d3 = require('d3-selection@2', 'd3-array@2')
Insert cell
import { adaptiveSimpson as int } from '@rreusser/integration'
Insert cell
import { text, radio, select } from "@jashkenas/inputs"
Insert cell
import { Range, Text } from "@observablehq/inputs"
Insert cell
functionPlot = require("function-plot@1/dist/function-plot")
Insert cell
math = require('mathjs@7')
Insert cell
minimize = require('https://bundle.run/minimize-golden-section-1d@3.0.0')
Insert cell
html`<style>
input[type='text'] {
width: 300px
}
</style>`
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