Skip to content

Instantly share code, notes, and snippets.



Created May 12, 2018
What would you like to do?
Derivative of a function in Standard ML, using Real.nextAfter
fun derivative (f : real -> real) (x : real) : real =
let val pos = Real.nextAfter (x, Real.posInf)
val neg = Real.nextAfter (x, Real.negInf)
(f pos - f neg) / (pos - neg)

This comment has been minimized.

Copy link
Owner Author

@cls cls commented May 12, 2018

I'm unsure if Standard ML guarantees that pos - neg here be non-zero.

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