Parcourir la source

exercise 2.5: sample function definitons

George C. Privon il y a 2 ans
Parent
commit
da09360d48
1 fichiers modifiés avec 35 ajouts et 0 suppressions
  1. 35 0
      02-basicfunctions/exercises/ex2.5.hs

+ 35 - 0
02-basicfunctions/exercises/ex2.5.hs

@@ -0,0 +1,35 @@
+-- Exercise 2.5
+-- George C. Privon
+-- 2023-09-05
+
+-- a) cube root of x
+cuberoot :: Double -> Double
+cuberoot x = x ** (1/3)
+
+-- b) e^y + 8^y
+exp8 :: Double -> Double
+exp8 x = exp x + 8**x
+
+-- c) 1/sqrt((x-5)^2 + 16)
+h :: Double -> Double
+h x = 1 / (sqrt $ (x-5)^2 + 16)
+
+-- d) 1 / sqrt(1-beta^2)
+gamma :: Double -> Double
+gamma x = 1 / (sqrt $ 1 - x^2)
+
+-- e)  1/(10+x) + 1 / (10-x)
+bigU :: Double -> Double
+bigU x = 1 / (10 + x) + 1 / (10-x)
+
+-- f) sqrt(l*(l+1)
+bigL :: Double -> Double
+bigL x = sqrt $ x * (x + x)
+
+-- g) 1 / abs(x)^3
+bigE :: Double -> Double
+bigE x = 1 / (abs x)^3
+
+-- h) 1/ (x^2 + 4)^3/2
+bigE2 :: Double -> Double
+bigE2 x = 1 / (x^2 + 4) ** 1.5