<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252055</link>
    <title>MATLAB Central Newsreader - Problem with Symbolic Math</title>
    <description>Feed for thread: Problem with Symbolic Math</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 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.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 23 May 2009 22:26:01 -0400</pubDate>
      <title>Problem with Symbolic Math</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252055#651948</link>
      <author>Good </author>
      <description>Hi Friends,&lt;br&gt;
This problem is to be solved by symbolic math but the solution it gives me does not tally with what the actual solution should be:&lt;br&gt;
&lt;br&gt;
The problem is to integrate a symbolic function of x, y, w and t with respect to x and evaluate the integrand from -pi/2 to pi/2. So the code below was written:&lt;br&gt;
&lt;br&gt;
syms N x y w t real&lt;br&gt;
A = N*cos(x-y)*cos(w*t-y);&lt;br&gt;
B = int(A, x, -pi/2, pi/2);&lt;br&gt;
&lt;br&gt;
The expected solution is:&lt;br&gt;
&lt;br&gt;
B should equal    N*sin(x-y)*cos(w*t-y) evaluated at (x=pi/2) minus  same expression evaluated at (x=-pi/2). Naturally, the final solution should be:&lt;br&gt;
&lt;br&gt;
B = N*(sin(pi/2-y) - sin(-pi/2-y))*cos(w*t-y) = 2*N*cos(y)*cos(w*t-y).&lt;br&gt;
&lt;br&gt;
Symbolic toolbox gives me:&lt;br&gt;
&lt;br&gt;
B = N*cos(-w*t+2*y)+N*cos(w*t)&lt;br&gt;
&lt;br&gt;
I cannot see how this solution is correct.&lt;br&gt;
&lt;br&gt;
Please I need this clarified so as to continue using this wonderful tool.</description>
    </item>
    <item>
      <pubDate>Sat, 23 May 2009 22:57:01 -0400</pubDate>
      <title>Re: Problem with Symbolic Math</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252055#651950</link>
      <author>Sadik </author>
      <description>They are exactly the same!!!&lt;br&gt;
&lt;br&gt;
You know the following trigonometric identity right?&lt;br&gt;
&lt;br&gt;
cos a * cos b = 0.5*(cos(a+b) + cos(a-b))&lt;br&gt;
&lt;br&gt;
In your case, a = y and b = wt - y.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Good &quot; &amp;lt;modeebuo@yahoo.co.uk&amp;gt; wrote in message &amp;lt;gv9t5p$qk1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi Friends,&lt;br&gt;
&amp;gt; This problem is to be solved by symbolic math but the solution it gives me does not tally with what the actual solution should be:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The problem is to integrate a symbolic function of x, y, w and t with respect to x and evaluate the integrand from -pi/2 to pi/2. So the code below was written:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; syms N x y w t real&lt;br&gt;
&amp;gt; A = N*cos(x-y)*cos(w*t-y);&lt;br&gt;
&amp;gt; B = int(A, x, -pi/2, pi/2);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The expected solution is:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; B should equal    N*sin(x-y)*cos(w*t-y) evaluated at (x=pi/2) minus  same expression evaluated at (x=-pi/2). Naturally, the final solution should be:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; B = N*(sin(pi/2-y) - sin(-pi/2-y))*cos(w*t-y) = 2*N*cos(y)*cos(w*t-y).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Symbolic toolbox gives me:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; B = N*cos(-w*t+2*y)+N*cos(w*t)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I cannot see how this solution is correct.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Please I need this clarified so as to continue using this wonderful tool.</description>
    </item>
    <item>
      <pubDate>Sun, 24 May 2009 01:42:29 -0400</pubDate>
      <title>Re: Problem with Symbolic Math</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252055#651955</link>
      <author>Nasser Abbasi</author>
      <description>&lt;br&gt;
&quot;Good &quot; &amp;lt;modeebuo@yahoo.co.uk&amp;gt; wrote in message &lt;br&gt;
news:gv9t5p$qk1$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi Friends,&lt;br&gt;
&amp;gt; This problem is to be solved by symbolic math but the solution it gives me &lt;br&gt;
&amp;gt; does not tally with what the actual solution should be:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The problem is to integrate a symbolic function of x, y, w and t with &lt;br&gt;
&amp;gt; respect to x and evaluate the integrand from -pi/2 to pi/2. So the code &lt;br&gt;
&amp;gt; below was written:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; syms N x y w t real&lt;br&gt;
&amp;gt; A = N*cos(x-y)*cos(w*t-y);&lt;br&gt;
&amp;gt; B = int(A, x, -pi/2, pi/2);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The expected solution is:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; B should equal    N*sin(x-y)*cos(w*t-y) evaluated at (x=pi/2) minus  same &lt;br&gt;
&amp;gt; expression evaluated at (x=-pi/2). Naturally, the final solution should &lt;br&gt;
&amp;gt; be:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; B = N*(sin(pi/2-y) - sin(-pi/2-y))*cos(w*t-y) = 2*N*cos(y)*cos(w*t-y).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Symbolic toolbox gives me:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; B = N*cos(-w*t+2*y)+N*cos(w*t)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I cannot see how this solution is correct.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Please I need this clarified so as to continue using this wonderful tool.&lt;br&gt;
&lt;br&gt;
EDU&amp;gt;&amp;gt; syms N x y w t real&lt;br&gt;
EDU&amp;gt;&amp;gt; B1 =  2*N*cos(y)*cos(w*t-y)&lt;br&gt;
EDU&amp;gt;&amp;gt; B2 = N*cos(-w*t+2*y)+N*cos(w*t)&lt;br&gt;
&lt;br&gt;
EDU&amp;gt;&amp;gt; simplify(B1-B2)&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
0&lt;br&gt;
&lt;br&gt;
--Nasser</description>
    </item>
  </channel>
</rss>

