Created
May 12, 2018 16:02
-
-
Save cls/d233b7bf6e538a7bd47fa600676e6972 to your computer and use it in GitHub Desktop.
Derivative of a function in Standard ML, using Real.nextAfter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun derivative (f : real -> real) (x : real) : real = | |
let val pos = Real.nextAfter (x, Real.posInf) | |
val neg = Real.nextAfter (x, Real.negInf) | |
in | |
(f pos - f neg) / (pos - neg) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm unsure if Standard ML guarantees that
pos - neg
here be non-zero.