-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
278 additions
and
166 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Sobre | ||
|
||
Os cálculos apresentados nos quatro exemplos construidos em **R** na primeira aula é, além de introduzir os alunos ao úniverso do **R** explicando as operações aritméticas, atribuição de valores para variáveis, mostrar que, a depender do computador ou calculadora, principalmente dos critérios de arredondamento e capacidade de armazenamento cálculos que, analiticamente devem ser iguais, apresentarão resultados diferentes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# | ||
# Exemplo 1 | ||
# | ||
(0.003815 + 1234567890) - 1234567890 | ||
0.003815 + (1234567890 - 1234567890) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Exemplo 2 | ||
# | ||
|
||
# Atribuição de valores para variáveis x1 e x2 | ||
x1 <- 0.003815 | ||
x2 <- 1234567890 | ||
# Realiza o mesmo cálculo do Exemplo 1 atribuindo o | ||
# valor do resultado para a variável resultado1 | ||
resultado1 <- (x1 + x2) - x2 | ||
resultado1 | ||
# Realize o segundo cálculo do Exemplo 1 atribuindo | ||
# o valor do resultado para a variável resultado2 | ||
resultado2 <- x1 + (x2 - x2) | ||
resultado2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# Exemplo 3 | ||
# | ||
|
||
# atribui valores para x1 e x2 | ||
x1 <- 0.3815 | ||
x2 <- 123456789015 | ||
# cálculo 1 | ||
resultado1 <- (x1 + x2) - x2 | ||
resultado1 | ||
# cálculo 2 | ||
resultado2 <- x1 + (x2 - x2) | ||
resultado2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# Exemplo 4 | ||
# | ||
|
||
# Atribui valores as variáveis x1 e x2 | ||
x1 <- 0.00000003815 | ||
x2 <- 1234567890 | ||
# faz o cálculo 1 | ||
resultado1 <- (x1 + x2) - x2 | ||
resultado1 | ||
# cálculo 2 | ||
resultado2 <- x1 + (x2 - x2) | ||
resultado2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Sobre | ||
|
||
Na segunda aula utilizando o **R** foram utilizados os exemplos da primeira aula para a introdução a criação de funções e, no último exemplo, foi iniciado o estudo de laços de repetição (`for`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# Exemplo 1 | ||
# | ||
|
||
# Construindo uma função no R | ||
funcao1 <- function(x1, x2) { | ||
resultado <- (x1 + x2) - x2 | ||
# mostra o resultado na tela | ||
print(resultado) | ||
} | ||
# Utilizando a função para determinados valores | ||
funcao1(0.3815, 1234567890) | ||
funcao1(0.003815, 1234567890) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# Exemplo 2 | ||
# | ||
|
||
# Construindo uma função no R | ||
funcao2 <- function(x1, x2) { | ||
resultado <- x1 + (x2 - x2) | ||
print(resultado) | ||
} | ||
# Calculando a função para alguns valores | ||
funcao2(0.3815, 1234567890) | ||
funcao2(0.003815, 1234567890) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Exemplo 3 | ||
# | ||
|
||
# função do exemplo 1 | ||
funcao1 <- function(x1, x2) { | ||
resultado <- (x1 + x2) - x2 | ||
# mostra o resultado na tela | ||
print(resultado) | ||
} | ||
# função do exemplo 2 | ||
funcao2 <- function(x1, x2) { | ||
resultado <- x1 + (x2 - x2) | ||
print(resultado) | ||
} | ||
# atribui valores para x1 e x2 | ||
x1 <- 0.003815 | ||
x2 <- 1234567890 | ||
# calcula as duas funções para x1 e x2 | ||
funcao1(x1, x2) | ||
funcao2(x1, x2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# Exemplo 4 | ||
# | ||
|
||
# definindo uma função quadrática | ||
funcaoquadratica <- function(x) { | ||
valor <- x^2 | ||
print(valor) | ||
} | ||
# calculando | ||
funcaoquadratica(2) | ||
funcaoquadratica(pi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# | ||
# Exemplo 5 | ||
# | ||
|
||
# laco de repeticao: for | ||
x <- seq(-100, 100, 1) | ||
# observação: | ||
# a função seq_len cujo argumento é length de x | ||
# anteriormente era 1:length(x) e foi trocado | ||
# devido ao linter de R. | ||
for (i in seq_len(length(x))) { | ||
valores <- x^2 | ||
} | ||
valores |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Sobre | ||
|
||
Na terceira aula, são apresentadas a condicional `if` e o laço `while`. No terceiro exemplo, por sinal, é apresentado um exemplo de somátorio (de `i=1` até `n` cuja cada interação, soma-se `1`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Exemplo 1 | ||
# | ||
|
||
# Condicao if | ||
x <- c(-2, -1, 0, 1, 2) | ||
for (i in seq_len(length(x))) { | ||
valor <- x[i]^2 | ||
# se o valor for igual a zero | ||
if (valor == 0) { | ||
# atribui o valor para raiz | ||
raiz <- x[i] | ||
} | ||
} | ||
raiz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# | ||
# Exemplo 2 | ||
# | ||
|
||
# While - loop | ||
x <- -2 | ||
valor <- 2 | ||
# enquanto o valor for diferente de 0 | ||
while (valor != 0) { | ||
valor <- x^2 | ||
raiz <- x | ||
x <- x + 1 | ||
} | ||
cat("A raiz da funcao e x = ", raiz, "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# Exemplo 3 | ||
# | ||
|
||
# somatorio | ||
valor <- 0 | ||
n <- 10 | ||
# percorra de 1 até n | ||
for (i in 1:n) { | ||
valor <- valor + 1 | ||
} | ||
|
||
cat("A soma e ", valor, "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Sobre | ||
|
||
Na quarta aula de **R**, foram apresentadas formas de desenvolver as séries de **Taylor** e **MacLaurin** na linguagem. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Exemplo 1 | ||
# | ||
|
||
# Serie de Taylor para a exponencial de x | ||
# em x=3 em volta do ponto x=2 até n=4 | ||
x <- 3 | ||
taylor <- exp(2) + exp(2) * (x - 2) | ||
taylor <- taylor + exp(2) * (x - 2)^2 / factorial(2) | ||
taylor <- taylor + exp(2) * (x - 2)^3 / factorial(3) | ||
taylor <- taylor + exp(2) * (x - 2)^4 / factorial(4) | ||
|
||
taylor | ||
# valor real da exponencial de x | ||
exp(x) |
Oops, something went wrong.