Skip to content

Instantly share code, notes, and snippets.

@mio991
Created January 20, 2017 09:04
Show Gist options
  • Save mio991/d499dab203d700319d363d4ce500c8c9 to your computer and use it in GitHub Desktop.
Save mio991/d499dab203d700319d363d4ce500c8c9 to your computer and use it in GitHub Desktop.
Haskell implementation des Newtown Algorithmus
-- Deklaration des Newtown Algorithmus wobei die Argumente bedeuten:
-- Startwert, Funktion, abgeleitete Funktion, Iterator (zählt nach 0 runter)
newtown :: Double -> (Double -> Double) -> (Double -> Double) -> Int -> Double
-- Abbruchbedingung
newtown x f g 0 = (x - ((f x)/(g x)))
-- Standardfall
newtown x f g itt_depth = newtown (x - ((f x) / (g x))) f g (itt_depth-1)
-- Deklaration von f und g in ghci
{-
-- Deklariere die Funktion
let {f :: Double -> Double ; f x = (x^5)-(x^3)+4}
-- Deklariere die Ableitung von f
let {g :: Double -> Double ; g x = 5*(x^4)-(3*(x^2))}
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment