Created
January 20, 2017 09:04
-
-
Save mio991/d499dab203d700319d363d4ce500c8c9 to your computer and use it in GitHub Desktop.
Haskell implementation des Newtown Algorithmus
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
-- 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