From: naser on 14 Feb 2010 03:53 I have a equation AX=0; which A is parametric. First I solved det(A)=0 and then I use null(A) to give me X. But when I use subs() function and then use null(A), reply is 3 column and it is not true. Would you please help me. syms x A=[1 1 0 0;2 3 4 0;cos(x) cosh(x) 0 1;sin(x) sinh(x) 1 1]; y=det(A) reply: y=4*cos(x) - 4*cosh(x) - 4*sin(x) + 4*sinh(x) - 1 Now f=@(x) 4*cos(x) - 4*cosh(x) - 4*sin(x) + 4*sinh(x) - 1; [x1]=fzero(@f,[37:38]) A=[1 1 0 0;2 3 4 0;cos(x1) cosh(x1) 0 1;sin(x1) sinh(x1) 1 1]; null(A) reply: x1 = 37.4299477502371 ans = -0.453742676394043 -0.891132753083832 0 6.70505820727308e-017 9.34410358043419e-018 -1.11022302462514e-016 -0.891132753083832 0.453742676394043 9.4209430227917e-017 8.39531089254629e-017 -4.27468390131729e-017 1
From: John D'Errico on 14 Feb 2010 05:32 "naser " <naser.sepehry(a)gmail.com> wrote in message <hl8dlh$t5q$1(a)fred.mathworks.com>... > I have a equation AX=0; which A is parametric. First I solved det(A)=0 and then I use null(A) to give me X. But when I use subs() function and then use null(A), reply is 3 column and it is not true. > Would you please help me. > > syms x > A=[1 1 0 0;2 3 4 0;cos(x) cosh(x) 0 1;sin(x) sinh(x) 1 1]; > y=det(A) > reply: > y=4*cos(x) - 4*cosh(x) - 4*sin(x) + 4*sinh(x) - 1 > > Now > f=@(x) 4*cos(x) - 4*cosh(x) - 4*sin(x) + 4*sinh(x) - 1; > [x1]=fzero(@f,[37:38]) > A=[1 1 0 0;2 3 4 0;cos(x1) cosh(x1) 0 1;sin(x1) sinh(x1) 1 1]; > null(A) > > reply: > > x1 = > 37.4299477502371 > > ans = > -0.453742676394043 -0.891132753083832 0 > 6.70505820727308e-017 9.34410358043419e-018 -1.11022302462514e-016 > -0.891132753083832 0.453742676394043 9.4209430227917e-017 > 8.39531089254629e-017 -4.27468390131729e-017 1 First of all, be very careful here. You are running into numerical problems, computing sinh(x) and cosh(x) when x is as large as 37. x = 37.4299477502371; sinh(x) ans = 9.00719925474113e+15 cosh(x) ans = 9.00719925474113e+15 Worse, then you are applying null to the resulting matrix. The linear algebra is failing you here, as the result is garbage. Don't just throw big numbers at a computer and not think about what you are doing. You will numerical garbage. John
|
Pages: 1 Prev: Calculating the age of a person Next: building matrix with diffrent rows length |