• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

edvinsav Sep 19th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. # 1.a
2. a = sample(-20:20, 100, replace = TRUE)
3. A = matrix(a, nr = 10, nc = 10)
4. # 1.b
5. s = sample(3:8, 1)
6. b = sample(-20:20, 10*s, replace = TRUE)
7. B = matrix(b, nr= s, nc= 10 )
8. # 1.c
9. c = sample(-20:20, 10*s, replace = TRUE)
10. C = matrix(c, nr= 10, nc= s)
11.
12. #2a
13. B + t(C)
14. #2b
15. 3*A -5*C %*% B
16. #2c
17. Ainv=solve(A)
18. Ainv %*% A
19. round(Ainv %*% A)
20.
21. #3a - pabaigti kitus
22. det(t(B) %*% B )
23.
24. #4
25.
26. D = C%*%t(C)
27. v = matrix(sample(-20:20, 10), 10, 1)
28. solve(A, v)
29. solve(D, v) # det=0, negali spresti
30.
31. matrix.rank(D)
32. DD = cbind(D, v) #prijungti stulpeli v
33. DD
35. z = matrix(sample(0, 11, replace=TRUE), 1, 11) #sukuriama nuline eilute, kad nepakeisti ranko
36. DDD = rbind(DD, z) #prijungia nuline eilute
37. matrix.rank(DDD) #isplestines matricos rank ligus 7, originalios 6. rankai nesutampa, reiskia nera sprendimu
38.
39. #5
40. E = t(B) %*% B
41. a = E %*% v
42. solve(E, a) #nemoka skaiciuoti tokia
43. matrix.rank(E)
44. EE = cbind(E,a)
45. EEE = rbind(EE,z)
46. matrix.rank(EEE) #rankE = rankEEE, be galo sprendimu
47.
48. x1 = solveSLE(E,a) #sukurta funkcija
49. x2 = solveSLE(E,a)
50. round(E %*% x1)
51. round(a)
52.
53. #6
54. Lambda = eigen(E) # ieskome tikriniu reiksmiu
55. TR = Lambda\$values
56. TV = Lambda\$vectors #vektoriai normuoti - (isvada)
57. TV1 = TV[1:10, 1]
58. TV2 = TV[1:10, 10]
59. norm(TV1, "2") #tikriname norma "2" - saknies is kvadratu sumos, jeigu = 1, reiskia normuoti
60. norm(TV1, "2")
61.
62. #vektorius yra tikrinis jeigu tenkinama salyga: Ex=lambda * x
63. E%*%TV1
64. TR[1]*TV1
65.
66. E%*%TV2
67. TR[10]*TV2
68. #tikrinti
69. (E%*%v)/v #nevienodi, tai netikrinis
70.
71. (E%*%TV2)/TV2 #vienodi, tai tikrinis
72. #pedsakos lygus tikriniai reiksmiu sumai
73. matrix.trace(E)
74. sum(TR)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top