From 35200c0f123497e9bc0167f01086348b4b865d72 Mon Sep 17 00:00:00 2001 From: Eduardo Date: Fri, 11 Oct 2019 16:08:29 -0300 Subject: [PATCH] =?UTF-8?q?Adicionado=20arquivo=20feito=20em=20aula=20de?= =?UTF-8?q?=20s=C3=A9ries=20(R)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/r/Aula 4 - Series.R | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/r/Aula 4 - Series.R diff --git a/src/r/Aula 4 - Series.R b/src/r/Aula 4 - Series.R new file mode 100644 index 0000000..75ba75f --- /dev/null +++ b/src/r/Aula 4 - Series.R @@ -0,0 +1,27 @@ +# Serie de Taylor e MacLaurim + +x <- 3 +taylor <- exp(2) + exp(2) * (x - 2) + exp(2)*(x-2)^2/factorial(2) + exp(2)*(x-2)^3/factorial(3) + exp(2)*(x-2)^4/factorial(4) +maclaurim <- 1 + x + x^2/factorial(2) + x^3/factorial(3) + x^4 / factorial(4) + +taylor +maclaurim +exp(x) + + + +# Serie de Taylor generica + +N <- 100 +a <- 2 +f <- exp(a) +x <- -1 +taylor <- 0 + +for(n in 0:N) { + termo <- (f * ((x - a)^n)) / factorial(n) + taylor <- taylor + termo +} + +taylor +exp(x) \ No newline at end of file