Matrix Algebra Solution
Matrix Algebra Solution
a1 v1 + · · · + ai vi + · · · + aj vj + · · · + ak vk = 0,
Now let
xi yi
ai = and bi = ,
kxkp kykq
and so
xi yi 1 |xi |p 1 |yi |q
≤ p + .
kxkp kykq p kxkp q kykqq
Now, summing these equations over i, we have
and
sign(xi ) = sign(yi )
for all i.
We note a special case by letting y = 1:
x̄ ≤ kxkp,
nx̄2 ≤ kxk22,
n n
! q1 n
! p1
X X X
p−1 (p−1)q p
|xi + yi | |xi | ≤ |xi + yi | |xi |
i=1 i=1 i=1
and
n n
! q1 n
! p1
X X X
p−1 (p−1)q p
|xi + yi | |xi | ≤ |xi + yi | |yi | ,
i=1 i=1 i=1
so
n n
! q1 n ! p1 n
! p1
X X X X
|xi +yi |p ≤ |xi + yi | (p−1)q |xi | p
+ |yi |p
i=1 i=1 i=1 i=1
3
1
or, because (p − 1)q = p and 1 − q = p1 ,
n
! p1 n
! p1 n
! p1
X X X
|xi + yi |p ≤ |xi |p + |yi |p ,
i=1 i=1 i=1
x <- c(1,2,3)
y <- c(-1,2,-3)
sum(x*y)
# [1] -6
2.26b.
2.26c.
2.27.
x <- c(1,2,3)
y <- c(-1,2,-3)
c(x[2]*y[3]-x[3]*y[2],
x[3]*y[1]-x[1]*y[3],
x[1]*y[2]-x[2]*y[1])
# [1] -12 0 4
2.28.
x <- c(1,2,3)
sum(abs(x))
# [1] 6
sqrt(sum(x*x))
# [1] 3.741657
max(abs(x))
# [1] 3
2.29.
x <- c(1,2,3)
y <- x/sum(x*x)
y
# [1] 0.07142857 0.14285714 0.21428571
sum(x*y)
# [1] 1
2.30a.
x <- c(1,2,3)
y <- c(-1,2,-3)
ypx <- sum(x*y)*x/sum(x*x)
ypx
# [1] -0.4285714 -0.8571429 -1.2857143
2.30b.
c(x[2]*ypx[3]-x[3]*ypx[2],
x[3]*ypx[1]-x[1]*ypx[3],
5
x[1]*ypx[2]-x[2]*ypx[1])
# [1] -4.440892e-16 2.220446e-16 0.000000e+00
The actual cross product is (0, 0, 0). In the solution above, two computed
zeroes are of order −16, which is essentially an additive zero.
2.31a.
x <- c(1,2,3)
y <- c(-1,2,-3)
z <- c(1,0,-3)
u1 <- x; u2 <- y; u3 <- z
u1 <- u1/sqrt(sum(u1*u1))
u2 <- u2 - sum(u1*u2)*u1
u3 <- u3 - sum(u1*u3)*u1
u2 <- u2/sqrt(sum(u2*u2))
u3 <- u3 - sum(u2*u3)*u2
u3 <- u3/sqrt(sum(u3*u3))
2.31b.
w <- c(5,4,3)
c1 <-sum(w*u1)
c2 <-sum(w*u2)
c3 <-sum(w*u3)
c1*u1 + c2*u2 + c3*u3
# [1] 5 4 3
2.32.
n <- 100
set.seed(12345)
u <- rnorm(n)
z <- rnorm(n)
v <- u+z
2.32a.
mu <- mean(u)
vu <- var(u)
mv <- mean(v)
vv <- var(v)
6
round(c(mu,vu,mv,vv),2)
# [1] 0.25 1.24 0.29 2.50
2.32b.
= kAk2F kBk2F .
3.40. Hints.
For inequality (3.325), use the Cauchy-Schwartz inequality.
For inequality (3.327), use Hölder’s inequality.
3.45a.
if (n<2){
print(’n must be at least 2’)
return()
}
perm <- FALSE
mult <- FALSE
axpy <- FALSE
if (p>0&q>0&a==0) perm <- TRUE
if (p>0&q==0) mult <- TRUE
if (p>0&q>0&a!=0) axpy <- TRUE
if (perm+mult+axpy==0){
print(’No valid elementary operator matrix’)
return()
}
# Set Epqa to the identity
Epqa <- matrix(c(1,rep(c(rep(0,n),1),n-1)),ncol=n)
if (perm){ # permute rows
Epqa[p,p] <- 0
Epqa[p,q] <- 1
Epqa[q,q] <- 0
Epqa[q,p] <- 1
} else
if (mult){ # multiply one row by a
Epqa[p,p]=a
} else
if (axpy){ # axpy
Epqa[p,q] <- a
}
return(Epqa)
}
n <- 5
p <- 2
q <- 4
E <- Epqa(n,p,q)
E%*%E
n <- 5
p <- 2
9
q <- 0
a <- 3
E1 <- Epqa(n,p,q,a)
E2 <- Epqa(n,p,q,1/a)
E1%*%E2
n <- 5
p <- 2
q <- 4
a <- 3
E1 <- Epqa(n,p,q,a)
E2 <- Epqa(n,p,q,-a)
E1%*%E2
|det(A)| = |det(R)|
Yn
= |rjj |
j=1
Yn
≤ krj k2
j=1
Yn
= kaj k2 ,
j=1
where rj is the vector whose elements are the same as the elements in
the j th column of R.
If equality holds, then either some aj is zero, or else rjj = krj k for
j = 1, . . . , n. In the latter case, R is diagonal, and hence AT A is diagonal,
and so the columns of A are orthogonal.
4.10. The R code that will produce the graph is
x<-c(0,1)
y<-c(0,1)
z<-matrix(c(0,0,1,1),nrow=2)
10
4.12a.
4.12b.
n <- 3
A <- matrix(c(1,3,2,2,3,1,2,1,2,4,2,1),nrow=n)
p <- 2
Gaus(n,p,A[,p])%*%A
4.12c.
m <- dim(A)[2]
A12 <- cbind(A,matrix(rep(0,n*n),nrow=n))
for (i in 1:n) A12[i,m+i]<-1
A12 <- Gaus(3,1,A12[,1])%*%A12
A12 <- Gaus(3,2,A12[,2])%*%A12
A12 <- Gaus(3,3,A12[,3])%*%A12
A12 <- rbind(A12[,5:7],c(0,0,0))
A%*%A12%*%A
A
A12%*%A%*%A12
A12
11
A12%*%A
t(A12%*%A)
A%*%A12
t(A%*%A12)
A <- matrix(c(1,3,2,2,3,1,2,1,2,4,2,1),nrow=3)
SVDA <- svd(A)
SVDA$u%*%diag(SVDA$d)%*%t(SVDA$v)
A
4.13b.
[2,] 16 14 11
[3,] 18 11 21
> sqrtF
[,1] [,2] [,3]
[1,] 4 2 2
[2,] 2 3 1
[3,] 2 1 4
e + L)
5.2e. ρ((D e −1 U
e ) = 0.9045.
5.2g. Some R code for this is
X T (y − XX + y) = X T y − X T XX + y
= X T y − X T (XX + )T y because of symmetry
= X T y − X T (X + )T X T y
= X T y − X T (X T )+ X T y property of Moore-Penrose inverses and transposes
= X T y − X T y property of Moore-Penrose inverses
= 0
8.10b. Define
p(c)
f(c) = 1 − .
cm
This is a monotone decreasing continuous function in c, with f(c) → ∞
as c → 0+ and f(c) → 0 as c → ∞. Therefore, there is a unique value
c∗ for which f(c∗ ) = 1. The uniqueness also follows from Descartes’ rule
of signs, which states that the maximum number of positive roots of a
polynomial is the number of sign changes of the coefficients, and in the
case of the polynomial p(c), this is one.
16
Fn <- function(n){
# Function to create a Fourier matrix
rts <- omegajn(n)
Fn <- matrix(c(rep(1,n),rts),nrow=n)
if (n>=3) for (j in 3:n) Fn <- cbind(Fn,rts^(j-1))
Fn <- Fn/sqrt(n)
return(Fn)
}
8.19. (−1)bn/2c nn , where b·c is the floor function (the greatest integer func-
tion). For n = 1, 2, 3, 4, the determinants are 1, −4, −27, 256.
βbW,C = (X T W X)−1 X T W y +
9.8. Let X = [Xi | Xo ] and Z = XoT Xo − XoT Xi (XiT Xi )−1 XiT Xo . Note that
XoT Xi = XiT Xo . We have
17
= XiT ,
10.17c.
a = x1
b = y1
s=0
for i = 2, n
{
d = (xi − a)/i
e = (yi − b)/i
a= d+a
b= e+b
s = i(i − 1)de + s
}.
10.20. 1. No; 2. Yes; 3. No; 4. No.
10.21. A very simple example is
1 1+
,
1 1
where < b−p , because in this case the matrix stored in the computer
would be singular. Another example is
1 a(1 + )
,
a(1 + ) a2 (1 + 2)
> 1/0
[1] Inf
> -5*(1/0)
[1] -Inf
> (1/0)*(1/0)
[1] Inf
> 1/0==5*(1/0)
[1] TRUE
10.23b.
> 0/0
[1] NaN
> -5*(0/0)
[1] NaN
> 0/0==NaN
[1] NA
21
10.23c.
> x<-NA
> x==NA
[1] NA
> is.nan(x)
[1] FALSE
> is.na(x)
[1] TRUE
For comparison,
real a(4,3)
data a/3.,6.,8.,2.,5.,1.,6.,3.,6.,2.,7.,1./
n = 4
m = 3
x1 = a(2,2) ! Temporary variables must be used because of
x2 = a(4,2) ! the side effects of srotg.
call srotg(x1, x2,, c, s)
call srot(m, a(2,1), n, a(4,1), n, c, s)
print *, c, s
print *, a
end
This yields 0.3162278 and 0.9486833 for c and s. The transformed matrix
is
3.000000 5.000000 6.000000
3.794733 3.162278 1.581139
.
8.000000 6.000000 7.000000
−5.059644 −0.00000002980232 −1.581139
12.7b. Using the Matrix package in R, after initializing rho and sig2, this is
Vinv <- sparseMatrix(i=c(1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,
9,9,10,10),
j=c(1,2,1:3,2:4,3:5,4:6,5:7,6:8,7:9,8:10,9,10),
x=c(1,-rho,rep(c(-rho,1+rho^2,-rho),8),-rho,1))/
(1-rho^2)*sig2