#---------------------------# # Loesungen Blatt1 # #---------------------------# ### Aufgabe 1 ### v1 = c(1.1,3.3,4.56,-7.77) v1 v2 = 1:100 v2 v3 = 2*v2 v3 v4 = v3 - 3 v4 v5 = rep(1,100) v5 v6 = rep(1:4,25) v6 v7 = seq(500,5,by=-5) v7 v8 = v2^2 v8 v9 = 1/v8 v9 x = seq(from=0,to=2*pi,length=100) x ### Aufgabe 2 ### # 2a) n = 1:1000 an = (-1)^(n-1) * 1/n an sn = cumsum(an) sn plot(sn) limit = rep(log(2),1000) points(limit,col="red") # 2b) n = 1:1000 an = 1/n^2 an sn = cumsum(an) sn plot(sn) limit = rep(pi^2/6,1000) points(limit,col="red") ### Aufgabe 3 ### # 3a) a1 = seq(2,16,by=2) a1 A1 = matrix(a1,nrow=2,ncol=4,byrow=TRUE) A1 a2 = rev(a1) a2 A2 = matrix(a2,nrow=4,ncol=2) A2 a1 = c(-2.2,3.3,1.1) a2 = c(4.56,-7.89,1.23) a3 = c(800,400,200) A3 = rbind(a1,a2,a3) A3 # 3b) B1 = diag( 100:1 ) B1 head(B1) B2 = outer( 1:100 , rep(1,100) ) B2 head(B2) # 3c) C1 = outer( 1:10 , 1:10 , FUN="+" ) C1 = 1/C1 C1 C2 = outer( 1:10 , 1:10 ) C2 = sin(2*pi*C2/10) C2 ### Aufgabe 4 ### # 4a) n = 1000 x = rnorm(n^2) # 4b) A = matrix(x,n,n) A head(A) # 4c) B = t(A) %*% A head(B) # 4d) res = eigen(B) names(res) # just for info evals = res\$values plot(evals)