Created
November 16, 2009 15:15
-
-
Save agustingianni/236051 to your computer and use it in GitHub Desktop.
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
-- Derivada numerica en x0 con paso h | |
-- http://en.wikipedia.org/wiki/Numerical_differentiation | |
derivada :: (Double -> Double) -> Double -> Double -> Double | |
derivada f x0 h = (f (x0 + h) - f x0) / (2*h) | |
newton :: (Double -> Double) -> Double -> Double | |
newton f x0 = do | |
let x1 = x0 - (f x0 / (derivada f x0 0.01)) | |
if abs (x1 - x0) < 0.001 then x1 else newton f x1 | |
function :: Double -> Double | |
function x = x^2-4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment