%In response to questions in class, here %is how you could use Matlab to check that five functions are %linearly independent by taking the Wronskian. %My comments begin with %, all other lines are matlab input or output. >> syms t >> f = [cos(t) sin(t) cos(2*t) sin(t)^2 cos(t)^2] f = [ cos(t), sin(t), cos(2*t), sin(t)^2, cos(t)^2] % I check first if somehow matlab will do this for me, no luck >> help wronskian wronskian.m not found. >> W = [ f; diff(f); diff(diff(f)); diff(diff(diff(f))); diff(diff(diff(diff(f)))) ] W = [ cos(t), sin(t), cos(2*t), sin(t)^2, cos(t)^2] [ -sin(t), cos(t), -2*sin(2*t), 2*sin(t)*cos(t), -2*sin(t)*cos(t)] [ -cos(t), -sin(t), -4*cos(2*t), 2*cos(t)^2-2*sin(t)^2, -2*cos(t)^2+2*sin(t)^2] [ sin(t), -cos(t), 8*sin(2*t), -8*sin(t)*cos(t), 8*sin(t)*cos(t)] [ cos(t), sin(t), 16*cos(2*t), -8*cos(t)^2+8*sin(t)^2, 8*cos(t)^2-8*sin(t)^2] >> det(W) ans = 36*sin(2*t)*sin(t)^6-36*sin(t)^2*sin(2*t)*cos(t)^4+72*cos(2*t)*sin(t)^5*cos(t)+144*cos(2*t)*sin(t)^3*cos(t)^3+36*cos(t)^2*sin(2*t)*sin(t)^4-36*sin(2*t)*cos(t)^6+72*cos(2*t)*sin(t)*cos(t)^5 % All right, it can take the derivative symbolically % now plug in t=0 >> subs(ans,{t},{0}) ans = 0 % Hmm, it is singular at t=0, so try t=1 >> subs(det(W),{t},{1}) ans = -4.4409e-15 % close enough to zero that it probably is. % At this point I notice that I took the wrong five functions. % They are linearly dependent since cos(2*t) = cos(t)^2 - sin(t)^2 % So we should get zero for the Wronskian. % While I have these linearly dependent functions, let's use Matlab to find the dependence relation. % The null command finds a basis for the null space of a matrix >> null(W) ans = [ empty sym ] % Well, matlab found nothing in the nullspace of the symbolic matrix, % so let us evaluate the matrix at t=0 and find its null space. >> null(subs(W,{t},{0})) ans = -0.0000 -0.0000 0.5774 0.5774 -0.5774 % So a basis for the null space of W(0) is .5774 * [0 0 1 1 -1] % (The .5774 is 1/sqrt(3) to make the vector length one. % this is a strong hint that 1*cos(2t) + 1*sin^2(t) -1*cos^2(t) = 0. ------------ % okay, now let us use the right five functions. >> f = [cos(t) sin(t) sin(2*t) sin(t)^2, cos(t)^2] f = [ cos(t), sin(t), sin(2*t), sin(t)^2, cos(t)^2] >> W = [ f; diff(f); diff(diff(f)); diff(diff(diff(f))); diff(diff(diff(diff(f)))) ] W = [ cos(t), sin(t), sin(2*t), sin(t)^2, cos(t)^2] [ -sin(t), cos(t), 2*cos(2*t), 2*sin(t)*cos(t), -2*sin(t)*cos(t)] [ -cos(t), -sin(t), -4*sin(2*t), 2*cos(t)^2-2*sin(t)^2, -2*cos(t)^2+2*sin(t)^2] [ sin(t), -cos(t), -8*cos(2*t), -8*sin(t)*cos(t), 8*sin(t)*cos(t)] [ cos(t), sin(t), 16*sin(2*t), -8*cos(t)^2+8*sin(t)^2, 8*cos(t)^2-8*sin(t)^2] >> det(W) ans = -36*cos(2*t)*sin(t)^6+36*cos(2*t)*sin(t)^2*cos(t)^4+72*cos(t)*sin(2*t)*sin(t)^5+144*sin(2*t)*sin(t)^3*cos(t)^3-36*cos(2*t)*sin(t)^4*cos(t)^2+36*cos(2*t)*cos(t)^6+72*sin(t)*sin(2*t)*cos(t)^5 >> subs(det(W),{t},{0}) ans = 36 % So the Wronskian is nonzero at t=0 % In fact it is always 36 as the following shows: >> simplify(det(W)) ans = 36 % We could have used a loop to construct W as follows % First make a matrix of the right size with the right first row >> W = [f; f; f; f; f] W = [ cos(t), sin(t), sin(2*t), sin(t)^2, cos(t)^2] [ cos(t), sin(t), sin(2*t), sin(t)^2, cos(t)^2] [ cos(t), sin(t), sin(2*t), sin(t)^2, cos(t)^2] [ cos(t), sin(t), sin(2*t), sin(t)^2, cos(t)^2] [ cos(t), sin(t), sin(2*t), sin(t)^2, cos(t)^2] % Now make sure each row is the derivative of the preceeding row >> for n=2:5 W(n,:) = diff(W(n-1,:)); end >> W W = [ cos(t), sin(t), sin(2*t), sin(t)^2, cos(t)^2] [ -sin(t), cos(t), 2*cos(2*t), 2*sin(t)*cos(t), -2*sin(t)*cos(t)] [ -cos(t), -sin(t), -4*sin(2*t), 2*cos(t)^2-2*sin(t)^2, -2*cos(t)^2+2*sin(t)^2] [ sin(t), -cos(t), -8*cos(2*t), -8*sin(t)*cos(t), 8*sin(t)*cos(t)] [ cos(t), sin(t), 16*sin(2*t), -8*cos(t)^2+8*sin(t)^2, 8*cos(t)^2-8*sin(t)^2] % Matlab note: % W(n,:) is the n-th row. Likewise W(:,n) is the n-th column % The : tells you to take all entries. % If you wanted the 2x3 matrix of the third and fifth rows and columns 1,2, and 4 % you could write W([3 5],[1 2 4]) ---------- % Okay, let us show that 1, e^t, ln(t), and t^2 are linearly independent functions >> f = [1 exp(t) log(t) t^2] f = [ 1, exp(t), log(t), t^2] >> W = [f;f;f;f]; >> for n=2:4 W(n,:) = diff(W(n-1,:)); end >> W W = [ 1, exp(t), log(t), t^2] [ 0, exp(t), 1/t, 2*t] [ 0, exp(t), -1/t^2, 2] [ 0, exp(t), 2/t^3, 0] >> det(W) ans = 4*exp(t)*(-1+t+t^2)/t^3 % this is clearly nonzero for almost all t, for example at t=1 it is 4e % It is amusing to have matlab find all t where the Wronskian is zero >> solve(det(W)) ans = [ 1/2*5^(1/2)-1/2] [ -1/2-1/2*5^(1/2)] % So at (-1 +- sqrt(5) )/2 it is zero. % This has nothing to do with the linear independence of the functions however.