<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359</link>
    <title>MATLAB Central Newsreader - how to solve simultaneous trigonometric equation</title>
    <description>Feed for thread: how to solve simultaneous trigonometric equation</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2013 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.nl/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 25 Sep 2010 11:35:25 +0000</pubDate>
      <title>how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782475</link>
      <author>rohit </author>
      <description>Dear all,&lt;br&gt;
&lt;br&gt;
I have two trigonometric equations of the form&lt;br&gt;
&lt;br&gt;
a*sin(X) + b*sin(Y) = constant1&lt;br&gt;
&lt;br&gt;
a*cos(X) + b*cos(Y) = constant2 &lt;br&gt;
&lt;br&gt;
Is there any way in Matlab to solve these two &lt;br&gt;
&lt;br&gt;
thanks&lt;br&gt;
&lt;br&gt;
Rohit</description>
    </item>
    <item>
      <pubDate>Sat, 25 Sep 2010 15:08:12 +0000</pubDate>
      <title>Re: how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782511</link>
      <author>Walter Roberson</author>
      <description>On 25/09/10 6:35 AM, rohit wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; I have two trigonometric equations of the form&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; a*sin(X) + b*sin(Y) = constant1&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; a*cos(X) + b*cos(Y) = constant2&lt;br&gt;
&amp;gt; Is there any way in Matlab to solve these two&lt;br&gt;
&amp;gt; thanks&lt;br&gt;
&lt;br&gt;
The symbolic toolbox could probably solve this, but you need to define &lt;br&gt;
which variables you are solving _for_ . Are you trying to find a and b, &lt;br&gt;
or X and Y ? a and b are trivial to solve for, X and Y have messier &lt;br&gt;
solutions.</description>
    </item>
    <item>
      <pubDate>Sat, 25 Sep 2010 18:55:10 +0000</pubDate>
      <title>Re: how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782536</link>
      <author>Roger Stafford</author>
      <description>"rohit " &amp;lt;rohitnarula19@gmail.com&amp;gt; wrote in message &amp;lt;i7kmps$b78$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Dear all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have two trigonometric equations of the form&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a*sin(X) + b*sin(Y) = constant1&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a*cos(X) + b*cos(Y) = constant2 &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is there any way in Matlab to solve these two &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Rohit&lt;br&gt;
- - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;As Walter suggests, the symbolic toolbox can provide you with a solution.  However, it comes in a complicated form that is not very intuitive which is caused by having to give the solution as a single expression.  I much prefer to do this kind of problem by hand if possible, and the solution in this case is much easier (at least for me) to comprehend.  I will give you only an outline of the reasoning involved.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;You are trying to solve&lt;br&gt;
&lt;br&gt;
&amp;nbsp;a*sin(x) + b*sin(y) = c&lt;br&gt;
&amp;nbsp;a*cos(x) + b*cos(y) = d&lt;br&gt;
&lt;br&gt;
(where I have renamed the two constants on the right hand side.)&lt;br&gt;
&lt;br&gt;
Define u = (x+y)/2 and v = (x-y)/2, so that x = u+v and y = u-v.  Hence&lt;br&gt;
&lt;br&gt;
&amp;nbsp;a*sin(u+v) + b*sin(u-v) = c&lt;br&gt;
&amp;nbsp;a*cos(u+v) + b*cos(u-v) = d&lt;br&gt;
&lt;br&gt;
which can be expanded and combined to&lt;br&gt;
&lt;br&gt;
&amp;nbsp;(a+b)*sin(u)*cos(v) + (a-b)*cos(u)*sin(v) = c&lt;br&gt;
&amp;nbsp;(a+b)*cos(u)*cos(v) - (a-b)*sin(u)*sin(v) = d&lt;br&gt;
&lt;br&gt;
By combining these as indicated by the right hand sides of the following we get&lt;br&gt;
&lt;br&gt;
&amp;nbsp;(a+b)*cos(v) = c*sin(u) + d*cos(u)&lt;br&gt;
&amp;nbsp;(a-b)*sin(v) = c*cos(u) - d*sin(u)&lt;br&gt;
&lt;br&gt;
The angle t = atan2(c,d) satisfies the equations&lt;br&gt;
&lt;br&gt;
&amp;nbsp;c = r*sin(t)&lt;br&gt;
&amp;nbsp;d = r*cos(t)&lt;br&gt;
&lt;br&gt;
where r = sqrt(c^2+d^2) and this gives us the equations&lt;br&gt;
&lt;br&gt;
&amp;nbsp;(a+b)*cos(v) = r*cos(t-u)&lt;br&gt;
&amp;nbsp;(a-b)*sin(v) = r*sin(t-u)&lt;br&gt;
&lt;br&gt;
If we square both sides and add, this eliminates t-u and we have an equation containing only v:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;4*a*b*cos(v)^2 + (a-b)^2 = r^2&lt;br&gt;
&lt;br&gt;
which can be solved for v.  There will in general be four different solutions within the range from -pi to +pi.  By substituting each of these into the above pair of equations, we can use atan2 to find corresponding solutions for t-u.  From there you can find your way back to solutions for x and y.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;This reasoning can actually be used to give steps in matlab for the solution that will very likely be more efficient, as well as easier to understand, than trying to reproduce the symbolic toolbox's awful single-expression answer.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Sat, 25 Sep 2010 19:32:37 +0000</pubDate>
      <title>Re: how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782541</link>
      <author>Walter Roberson</author>
      <description>On 25/09/10 1:55 PM, Roger Stafford wrote:&lt;br&gt;
&amp;gt; "rohit " &amp;lt;rohitnarula19@gmail.com&amp;gt; wrote in message&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; a*sin(X) + b*sin(Y) = constant1&lt;br&gt;
&amp;gt;&amp;gt; a*cos(X) + b*cos(Y) = constant2&lt;br&gt;
&lt;br&gt;
&amp;gt; If we square both sides and add, this eliminates t-u and we have an&lt;br&gt;
&amp;gt; equation containing only v:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 4*a*b*cos(v)^2 + (a-b)^2 = r^2&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; which can be solved for v. There will in general be four different&lt;br&gt;
&amp;gt; solutions within the range from -pi to +pi.&lt;br&gt;
&lt;br&gt;
Maple's direct solution for X and Y is indeed rather messy in detail &lt;br&gt;
(though not in form.) Maple only finds two solution forms, though.</description>
    </item>
    <item>
      <pubDate>Sat, 25 Sep 2010 19:47:22 +0000</pubDate>
      <title>Re: how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782547</link>
      <author>Roger Stafford</author>
      <description>"Roger Stafford" &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in message &amp;lt;i7lgie$a4$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; ........&lt;br&gt;
&amp;gt;  4*a*b*cos(v)^2 + (a-b)^2 = r^2&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; which can be solved for v.  There will in general be four different solutions within the range from -pi to +pi.  &lt;br&gt;
&amp;gt; .......&lt;br&gt;
- - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;I should have added a bit more detail to the solution for v.  The equation for v can be put in the two forms&lt;br&gt;
&lt;br&gt;
&amp;nbsp;cos(v)^2 = (c^2+d^2-(a-b)^2)/(4*a*b)&lt;br&gt;
&amp;nbsp;sin(v)^2 = ((a+b)^2-c^2-d^2)/(4*a*b)&lt;br&gt;
&lt;br&gt;
which means the two right hand sides must each be non-negative, and this puts two constraints on the four constants, a, b, c, and d.  If this is the case, we can say&lt;br&gt;
&lt;br&gt;
&amp;nbsp;v = atan2(sqrt(((a+b)^2-c^2-d^2)/(4*a*b)), ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sqrt((c^2+d^2-(a-b)^2)/(4*a*b)));&lt;br&gt;
&lt;br&gt;
which gives a solution in the first quadrant and then append to this the values in the other three quadrants which would also be valid:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;pi-v, v-pi, and -v,  (2nd, 3rd, &amp; 4th quadrants, resp.)&lt;br&gt;
&lt;br&gt;
to make a total of four solutions in the range -pi to +pi.  Each of these will lead to a unique t-u value within the -pi to +pi range again via the atan2 function.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Sat, 25 Sep 2010 20:27:08 +0000</pubDate>
      <title>Re: how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782554</link>
      <author>Roger Stafford</author>
      <description>Walter Roberson &amp;lt;roberson@hushmail.com&amp;gt; wrote in message &amp;lt;p7sno.4474$ez6.2031@newsfe02.iad&amp;gt;...&lt;br&gt;
&amp;gt; Maple only finds two solution forms, though.&lt;br&gt;
- - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;Yes Walter, I think Maple is correct that there are only two solutions for x and y in the range -pi to +pi.  The 3rd and 4th quadrant solutions for v lead to the same answers for x=u+v and y = u-v in that range as those in the first two quadrants.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Sat, 25 Sep 2010 20:45:07 +0000</pubDate>
      <title>Re: how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782555</link>
      <author>Greg Heath</author>
      <description>On Sep 25, 7:35 am, "rohit " &amp;lt;rohitnarul...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Dear all,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have two trigonometric equations of the form&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; a*sin(X) + b*sin(Y) = constant1&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; a*cos(X) + b*cos(Y) = constant2&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Is there any way in Matlab to solve these two&lt;br&gt;
&lt;br&gt;
With the substitutions&lt;br&gt;
&lt;br&gt;
U = sin(X), V = cos(Y)&lt;br&gt;
&lt;br&gt;
You can obtain a linear relationship between&lt;br&gt;
U and V and a quadratic equation for either.&lt;br&gt;
&lt;br&gt;
The quadratic will give you two solutions&lt;br&gt;
and the inverse sin or cos will boost it&lt;br&gt;
up to four.&lt;br&gt;
&lt;br&gt;
I guess you'll have to go back to the original&lt;br&gt;
equations toget the right signs/quadrants.&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
    <item>
      <pubDate>Sat, 25 Sep 2010 21:20:28 +0000</pubDate>
      <title>Re: how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782559</link>
      <author>Bruno Luong</author>
      <description>&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a*sin(X) + b*sin(Y) = constant1 (eqt1)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a*cos(X) + b*cos(Y) = constant2 (eqt2)&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
(2)+i*(1) and (2)-i*(1) gives&lt;br&gt;
&lt;br&gt;
a*exp(iX) +  b*exp(iY)  = z1&lt;br&gt;
a*exp(-iX) +  b*exp(-iY)  = z2&lt;br&gt;
&lt;br&gt;
With z1 = constant2 + i*constant1, z2 = conj(z)&lt;br&gt;
&lt;br&gt;
Let's change the variable to u = exp(iX)  and v = = exp(iY), we get:&lt;br&gt;
&lt;br&gt;
a*u + b*v = z1 (eqt3)&lt;br&gt;
a/u + b/v = z2  (eqt4)&lt;br&gt;
&lt;br&gt;
Replace u = z1/a - b/a*v in (eqt4), this gives a second order polynomial equation in v that can be solved with two solutions of v. From that, just go back and find out what is u, then x and y.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Sat, 25 Sep 2010 23:13:04 +0000</pubDate>
      <title>Re: how to solve simultaneous trigonometric equation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/292359#782574</link>
      <author>Roger Stafford</author>
      <description>"Bruno Luong" &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in message &amp;lt;i7lp2s$2i9$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; a*sin(X) + b*sin(Y) = constant1 (eqt1)&lt;br&gt;
&amp;gt; &amp;gt; a*cos(X) + b*cos(Y) = constant2 (eqt2)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; (2)+i*(1) and (2)-i*(1) gives&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a*exp(iX) +  b*exp(iY)  = z1&lt;br&gt;
&amp;gt; a*exp(-iX) +  b*exp(-iY)  = z2&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; With z1 = constant2 + i*constant1, z2 = conj(z)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Let's change the variable to u = exp(iX)  and v = = exp(iY), we get:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a*u + b*v = z1 (eqt3)&lt;br&gt;
&amp;gt; a/u + b/v = z2  (eqt4)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Replace u = z1/a - b/a*v in (eqt4), this gives a second order polynomial equation in v that can be solved with two solutions of v. From that, just go back and find out what is u, then x and y.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Bruno&lt;br&gt;
- - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;That's a good method, Bruno, easier to understand than mine.  You would probably best use atan2 to go back from u and v to x and y.  Presumably in solving the second order polynomial you would arrive at the same two constraints on the constants that I did.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
  </channel>
</rss>
