Skip to content

Instantly share code, notes, and snippets.

@dannydenenberg
Created September 27, 2019 23:50
Show Gist options
  • Save dannydenenberg/3c5f3232d797ba63eae2cb1d8f2e00de to your computer and use it in GitHub Desktop.
Save dannydenenberg/3c5f3232d797ba63eae2cb1d8f2e00de to your computer and use it in GitHub Desktop.
function doIt() {
// gather variable data
const nth = parseInt(document.getElementById("nth").value);
const expr = document.getElementById("expr").value;
const respectTo = document.getElementById("respectTo").value;
const answer = `${math.format(
nthDerivative(expr, nth, respectTo),
14
)}`;
katex.render(answer, document.getElementById("nth-derivative"));
}
function nthDerivative(expr, n, respectTo) {
let ans = math.derivative(expr, respectTo);
for (let i = 0; i < n - 1; i++) {
ans = math.derivative(ans, respectTo);
}
return ans;
}
@justinaReyes
Copy link

Top up your balance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment