Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: "Explicit solution could not be found" in solving system of equations Date: Sat, 4 Apr 2009 21:42:02 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 26 Message-ID: <gr8k7a$q2h$1@fred.mathworks.com> References: <gr4h6q$rd9$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1238881322 26705 172.30.248.35 (4 Apr 2009 21:42:02 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sat, 4 Apr 2009 21:42:02 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:530353 "haunteagle iœ" <haunteagle@gmail.com> wrote in message <gr4h6q$rd9$1@fred.mathworks.com>... > >> solve('(a * cos(b) - 0.000)^2 + (a * sin(b) - 0.450)^2 = (a + c * t1)^2', '(a * cos(b) - 0.300)^2 + (a * sin(b) - 0.450)^2 = (a + c * t2)^2','(a * cos(b) - 0.300)^2 + (a * sin(b) - 0.000)^2 = (a + c * t4)^2','a','b','c') > ...... I finally got around to finishing that problem for you, Haunteagle. Here is the complete solution. We are given t1, t2, and t4. Define p = 0.450 and q = 0.300 . (We assume that your 0.000 is exactly zero.) Then, as I said before, c is a root of a quadratic in c^2: k2 = t4^2*(t1-t2)^2*(t1-t4+t2)^2*p^2+t1^2*(t4-t2)^2*(t4-t1+t2)^2*q^2; k1 = -(t1^2+t4^2+t2^2-2*t1*t2)*(t1^2+t4^2+t2^2-2*t4*t2)*p^2*q^2; k0 = (t1+t4-t2)^2*(p^2+q^2)*p^2*q^2; c = sqrt(roots([k2,k1,k0])); c = [c;-c]; % Get all four roots For those roots in c that are real, the quantities a and b can be determined as follows: a = (t4^2+t1^2-t2^2)*c/(t2-t1-t4)/2; sb = ((t2-t1-t4)*p^2+t1*(t2-t4)*(t2+t4-t1)*c^2)/(t1^2+t4^2-t2^2)/p/c; cb = ((t2-t1-t4)*q^2+t4*(t2-t1)*(t2+t1-t4)*c^2)/(t1^2+t4^2-t2^2)/q/c; b = atan2(sb,cb); These equations were determined using the reasoning I described in my first article above. The quantity a is first eliminated from the three original equations, yielding two equations in b and c. Then sb = sin(b) and cb = cos(b) are obtained in terms of c, solving the two equations which are linear in sb and cb. Then the condition sb^2+cb^2 = 1 is applied to this, with a resulting quartic equation in c. Next the equations for sb and cb are evaluated in terms of c, getting values for sb and cb. Using atan2 on these gives b lying in [-pi,pi]. Finally the expression for a is obtained from one of the original equations using these expressions for sb and cb in terms of c. As you have seem from Walter's results, it is better in this case not to use 'solve' to find all three unknowns in only one step, since that results in a very messy answer. Roger Stafford