diff options
Diffstat (limited to 'Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R')
-rw-r--r-- | Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R new file mode 100644 index 00000000..c6d4b401 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R @@ -0,0 +1,20 @@ +# Example 9 Chapter 12 Page no.: 398
+#Gaussian Two point formula
+
+# Installing and attaching 'pracma' library
+install.packages("pracma")
+library("pracma")
+
+#Gauss-Legendre nodes and weights
+f <- function(x) {
+ exp(-x/2)
+}
+
+# Given values
+n1 = 2
+a1 =-2
+b1 = 2
+
+cc <- gaussLegendre(n1, a1, b1)
+Q <- sum(cc$w * f(cc$x))
+cat("The Gaussian two point integral of exp(-x/2) is", signif(Q, digits = 9))
\ No newline at end of file |