summaryrefslogtreecommitdiff
path: root/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R
diff options
context:
space:
mode:
Diffstat (limited to 'Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R')
-rw-r--r--Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R40
1 files changed, 40 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R
new file mode 100644
index 00000000..22d907da
--- /dev/null
+++ b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R
@@ -0,0 +1,40 @@
+# Example 4 Chapter 13 Page no.: 420
+# Euler Method
+
+#for the first solution
+cat("Case A:")
+h <- 0.5
+x <- 1
+y <- 2
+cat("h=",h)
+#Creating algorithm and displaying
+for (i in 1:2) {
+
+ dy <- (3 * (x *x)) + 1
+ y <- y + (h * dy)
+ x <- x + h
+ cat("y(",x,")= ",y,"\n")
+}
+
+#for the second solution
+cat("Case B:")
+h <- 0.25
+x <- 1
+y <- 2
+cat("h=",h)
+
+print(x)
+print(y)
+
+#Creating algorithm and displaying
+for (i in 1:5) {
+
+ cat("y(",x,")= ",y,"\n")
+ x <- x + h
+ dy <- (3 * ((x-h)^2)) + 1
+ y <- y + (h * dy)
+
+
+}
+
+#For Case B, textbook answer is false. \ No newline at end of file