News for hackers. Stuff that matters.
Re:Not Lisp again (2009) by thanatropism on Friday October 26, 2018 @05:00PM (#18312669)
In Python:

    def deriv(f): return lambda x: (f(x+dx) - f(x))/dx
or even:

    deriv = lambda f: lambda x: (f(x+dx) - f(x))/dx
Re:Not Lisp again (2009) by stan_rogers on Friday October 26, 2018 @06:08PM (#18313049)
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.
Re:Not Lisp again (2009) by QuadrupleA on Friday October 26, 2018 @06:15PM (#18313083)
Lisp 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").

Re:Not Lisp again (2009) by taeric on Friday October 26, 2018 @06:23PM (#18313127)
Symbolic derivatives are one of the very next sections in the famous lisp lectures that this was watching.
Re:Not Lisp again (2009) by QuadrupleA on Friday October 26, 2018 @06:30PM (#18313176)
Interesting - for symbolic differentiation I imagine it's about code-manipulation rules for e.g. calculus' product rule, chain rule etc.?
Re:Not Lisp again (2009) by taeric on Friday October 26, 2018 @06:37PM (#18313217)
Essentially, yes. And if you want it to be pretty, it gets complicated quickly.

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.

Re:Not Lisp again (2009) by yen223 on Friday October 26, 2018 @09:27PM (#18313871)
Here's symbolic differentiation done in ~20 lines of Haskell: https://www.quora.com/What-are-20-lines-of-code-that-capture...