# Exercise 4.2 Problem 9,10,16. # # Pro 9. The given formula defines the inner product of U and V. # # Pro10. The given formula does not define the inner product of U and V. (d) fails. # # Pro16. The given formula defines the inner product of U and V. # # Exercise 4.3 Problem 14,20. # # Pro 14. # > with(stats): > fit [ leastsquare[[x,y]]]([[1,2,3,4,5], [5,4,1,1,-1]]); y = 13/2 - 3/2 x # Pro 20. # > with(linalg); [BlockDiagonal, GramSchmidt, JordanBlock, Wronskian, add, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, col, coldim, colspace, colspan, companion, concat, cond, copyinto, crossprod, curl, definite, delcols, delrows, det, diag, diverge, dotprod, eigenvals, eigenvects, entermatrix, equal, exponential, extend, ffgausselim, fibonacci, frobenius, gausselim, gaussjord, genmatrix, grad, hadamard, hermite, hessian, hilbert, htranspose, ihermite, indexfunc, innerprod, intbasis, inverse, ismith, iszero, jacobian, jordan, kernel, laplacian, leastsqrs, linsolve, matrix, minor, minpoly, mulcol, mulrow, multiply, norm, normalize, nullspace, orthog, permanent, pivot, potential, randmatrix, randvector, rank, ratform, row, rowdim, rowspace, rowspan, rref, scalarmul, singularvals, smith, stack, submatrix, subvector, sumbasis, swapcol, swaprow, sylvester, toeplitz, trace, transpose, vandermonde, vecpotent, vectdim, vector] > A := matrix(4,2,[1,2,1,1,-1,2,-1,0]); [ 1 2 ] [ ] [ 1 1 ] A := [ ] [ -1 2 ] [ ] [ -1 0 ] > AT := transpose(A); [ 1 1 -1 -1 ] AT := [ ] [ 2 1 2 0 ] > evalm(AT &* A); [ 4 1 ] [ ] [ 1 9 ] > AI := inverse("); [ 9/35 -1/35 ] AI := [ ] [ -1/35 4/35 ] > v := matrix(4,1,[1,1,2,-1]); [ 1 ] [ ] [ 1 ] v := [ ] [ 2 ] [ ] [ -1 ] > evalm(A &* AI &* AT); [ 3/5 2/5 1/5 -1/5 ] [ ] [ 11 ] [ 2/5 ---- -2/35 -8/35 ] [ 35 ] [ ] [ 29 11 ] [ 1/5 -2/35 ---- ---- ] [ 35 35 ] [ ] [ 11 ] [ -1/5 -8/35 ---- 9/35 ] [ 35 ] # This is the perpendicular projection function p. > evalm ( " &* v); [ 8/5 ] [ ] [ 29 ] [ ---- ] [ 35 ] [ ] [ 52 ] [ ---- ] [ 35 ] [ ] [ -2/35 ] # This is the perpendicular projection P. # # Using least square to find the function which fits insertion sort. # > n_values := [10,15,20,25,30,50]; n_values := [10, 15, 20, 25, 30, 50] > c_values := [29,77,137,191,225,657]; c_values := [29, 77, 137, 191, 225, 657] > fit [ leastsquare [[x,y], y=c0+c1*x+c2*x^2, {c0,c1,c2}]] ([n_values, c_values]); 9338 34246 9214 2 y = ---- + ----- x + ----- x 1529 38225 38225 > evalf("); 2 y = 6.107259647 + .8959058208 x + .2410464356 x # # So the values of c0, c1 and c2 are 6.1, .89, .24, and the number of comparisons taken for n = # 10000 is estimated as: # > subs(x = 10000, "); 8 y = .2411360873*10 >