Question 1

x <- 1.1
a <- 2.2
b <- 3.3
 z <- c(1.1, 2.2, 3.3)
 print(z)
## [1] 1.1 2.2 3.3

a. \(x^{a^b}\)

z <- x^a^b
print(z)
## [1] 3.61714

b. \((x^a)^b\)

z <- (x^a)^b
print(z)
## [1] 1.997611

c. \(3x^3 + 2x^2 + 1\)

z <- 3*x^3 + 2*x^2 + 1
print(z)
## [1] 7.413

Question 2

a.(1,2,3,4,5,6,7,8,7,6,5,4,3,2,1)

seq(1,8)
## [1] 1 2 3 4 5 6 7 8
seq(7,1)
## [1] 7 6 5 4 3 2 1
a<- c(seq(1,8),seq(7,1))
print(a)
##  [1] 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1

b. (1,2,2,3,3,3,4,4,4,4,5,5,5,5,5)

y<- seq(1,5)
print(y)
## [1] 1 2 3 4 5
a<- rep(x=y,times=y)
print(a)
##  [1] 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

c. (5,4,4,3,3,3,2,2,2,2,1,1,1,1,1)

a<- seq(from=5,to=1)
z<- rep(x=a, times= seq(1,5))
print(z)
##  [1] 5 4 4 3 3 3 2 2 2 2 1 1 1 1 1
z<- runif(2)
print(z)
## [1] 0.5248310 0.1307431
# computing r using 
r <- sqrt(z[1]^2+z[2]^2)
print(r)
## [1] 0.5408709
# computing theta
atan(z[2]/r)
## [1] 0.2371773

Question 4

queue <- c("sheep","fox","owl","ant")
print(queue)
## [1] "sheep" "fox"   "owl"   "ant"
## a. the serpent arrives and gets in line;
queue <- c(queue,"serpent")
print(queue)
## [1] "sheep"   "fox"     "owl"     "ant"     "serpent"
## b. the sheep enters the ark;
queue <- queue[-1]
print(queue)
## [1] "fox"     "owl"     "ant"     "serpent"
## c. the donkey arrives and talks his way to the front of the line;
queue<- c("donkey", queue)
print(queue)
## [1] "donkey"  "fox"     "owl"     "ant"     "serpent"
## d. the serpent gets impatient and leaves;
queue <- queue[-5]
print(queue)
## [1] "donkey" "fox"    "owl"    "ant"
## e. the owl gets bored and leaves;
queue <- queue[-3]
print(queue)
## [1] "donkey" "fox"    "ant"
## f. the aphid arrives and the ant invites him to cut in line.
queue <- c(queue,"aphid")
print(queue)
## [1] "donkey" "fox"    "ant"    "aphid"
## g. Finally, determine the position of the aphid in the line.

which(queue=="aphid")
## [1] 4

Question 5

z <- c(1:100)
print(z)
##   [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
##  [19]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36
##  [37]  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54
##  [55]  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72
##  [73]  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
##  [91]  91  92  93  94  95  96  97  98  99 100
# finding values of z not divisible 2,3, or 7
x <- which(z %% 2 & z %% 3 & z %% 7)
print(x)
##  [1]  1  5 11 13 17 19 23 25 29 31 37 41 43 47 53 55 59 61 65 67 71 73 79 83 85
## [26] 89 95 97