4 ms·
That's a sort of function, yes, but it's numerical analysis. In a Lisp you can pass in the equivalent of "4x^3 + (x^2)/2 -5X + 6" and get back "12x^2 + x - 5" -
by stan_rogers 8y ago
That's a sort of function, yes, but it's numerical analysis. In a Lisp you can pass in the equivalent of "4x^3 + (x^2)/2 -5X + 6" and get back "12x^2 + x - 5" - a function that is the derivative of the function you put in, rather than a function that approximates the value of the derivative at a value. You'd be manipulating the function rather than its return value.
- QuadrupleA 8y agoLisp is definitely not doing symbolic algebra and finding a pure analytical answer like that under the hood - symbolic math, differentiation rules etc. are a whole other beast (see SymPy for example). Maybe that's the misunderstanding in the original article that made it seem so mindblowing? Evaluating (f(5.0001) - f(5.0)) / 0.0001 just gives an approximation of the derivative at a certain point in the function (aka the "finite difference method").
- taeric 8y agoSymbolic derivatives are one of the very next sections in the famous lisp lectures that this was watching.
- QuadrupleA 8y agoInteresting - for symbolic differentiation I imagine it's about code-manipulation rules for e.g. calculus' product rule, chain rule etc.?
- taeric 8y agoEssentially, yes. And if you want it to be pretty, it gets complicated quickly. https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-16.html#%_sec_2.3.2 https://mitpress.mit.edu/sites/default/files/sicp/full-text/... is the chapter. Turns out it wasn't the "very next" one. But it is in my head.
- yen223 8y agoHere's symbolic differentiation done in ~20 lines of Haskell: https://www.quora.com/What-are-20-lines-of-code-that-capture-the-essence-of-Haskell-Try-to-follow-standard-Haskell-style-Comments-and-spaces-between-code-do-not-count-as-lines-They-can-also-consist-of-individual-snippets-of-code-but-have-to-add-up-to-20-lines https://www.quora.com/What-are-20-lines-of-code-that-capture...