summaryrefslogtreecommitdiff
path: root/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R
diff options
context:
space:
mode:
Diffstat (limited to 'Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R')
-rw-r--r--Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R22
1 files changed, 22 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R
new file mode 100644
index 00000000..30ce157f
--- /dev/null
+++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R
@@ -0,0 +1,22 @@
+# Example 10 Chapter 12 Page no.: 400
+#Gauss-Legendre Three point formula
+
+# Installing and attaching 'pracma' library
+install.packages("pracma")
+library("pracma")
+
+#Gauss-Legendre nodes and weights
+f <- function(x) {
+ (x^4)+1
+}
+
+# Given values
+n1 = 3
+a1 = 2
+b1 = 4
+
+cc <- gaussLegendre(n1, a1, b1)
+Q <- sum(cc$w * f(cc$x))
+cat("The Gauss-Legendre Three point integral of (x^4)+1 is", Q)
+
+# The value in the textbook and the calculated value vary slightly due to approximations assumed in textbook. \ No newline at end of file