I am new to Haskell and functional programming in general, but I think that I have found a bug in Winhugs.
When I call "wurzel 5" in the "dos-mode"-hugs after loading the attached file I get "ERROR - C stack overflow", which is ok. Winhugs crashes in the same situation. In my German Win2k version it says "winhugs.exe hat Fehler verursacht und wird geschlossen. Starten Sie das Programm neu. Ein Fehlerprotokoll wird erstellt." which means something like "winhugs.exe has created an error and is going to be closed. Restart the program."
Is this a known issue?
Regards,
Jan Reineke
absolutevalue :: (Double -> Double)
absolutevalue x = if (x < 0)
then -x
else x
newtoniteration :: (Double -> Double) -> (Double -> Double) -> Double -> Double
newtoniteration g gprime x = if (absolutevalue(g x/gprime x) < 0.01)
then x
else newtoniteration g gprime x-(g x/gprime x)
wurzel a = newtoniteration (\x -> (x*x-a)) (\x -> x*x) 2
f a x = x*x-a
fprime x = x*x
wurzelalternative a = newtoniteration (f a) fprime 2
