Thread Subject: Problem with Symbolic Math

Subject: Problem with Symbolic Math

From: Good

Date: 23 May, 2009 22:26:01

Message: 1 of 3

Hi Friends,
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:

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:

syms N x y w t real
A = N*cos(x-y)*cos(w*t-y);
B = int(A, x, -pi/2, pi/2);

The expected solution is:

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:

B = N*(sin(pi/2-y) - sin(-pi/2-y))*cos(w*t-y) = 2*N*cos(y)*cos(w*t-y).

Symbolic toolbox gives me:

B = N*cos(-w*t+2*y)+N*cos(w*t)

I cannot see how this solution is correct.

Please I need this clarified so as to continue using this wonderful tool.

Subject: Problem with Symbolic Math

From: Sadik

Date: 23 May, 2009 22:57:01

Message: 2 of 3

They are exactly the same!!!

You know the following trigonometric identity right?

cos a * cos b = 0.5*(cos(a+b) + cos(a-b))

In your case, a = y and b = wt - y.








"Good " <modeebuo@yahoo.co.uk> wrote in message <gv9t5p$qk1$1@fred.mathworks.com>...
> Hi Friends,
> 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:
>
> 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:
>
> syms N x y w t real
> A = N*cos(x-y)*cos(w*t-y);
> B = int(A, x, -pi/2, pi/2);
>
> The expected solution is:
>
> 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:
>
> B = N*(sin(pi/2-y) - sin(-pi/2-y))*cos(w*t-y) = 2*N*cos(y)*cos(w*t-y).
>
> Symbolic toolbox gives me:
>
> B = N*cos(-w*t+2*y)+N*cos(w*t)
>
> I cannot see how this solution is correct.
>
> Please I need this clarified so as to continue using this wonderful tool.

Subject: Problem with Symbolic Math

From: Nasser Abbasi

Date: 24 May, 2009 01:42:29

Message: 3 of 3


"Good " <modeebuo@yahoo.co.uk> wrote in message
news:gv9t5p$qk1$1@fred.mathworks.com...
> Hi Friends,
> 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:
>
> 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:
>
> syms N x y w t real
> A = N*cos(x-y)*cos(w*t-y);
> B = int(A, x, -pi/2, pi/2);
>
> The expected solution is:
>
> 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:
>
> B = N*(sin(pi/2-y) - sin(-pi/2-y))*cos(w*t-y) = 2*N*cos(y)*cos(w*t-y).
>
> Symbolic toolbox gives me:
>
> B = N*cos(-w*t+2*y)+N*cos(w*t)
>
> I cannot see how this solution is correct.
>
> Please I need this clarified so as to continue using this wonderful tool.

EDU>> syms N x y w t real
EDU>> B1 = 2*N*cos(y)*cos(w*t-y)
EDU>> B2 = N*cos(-w*t+2*y)+N*cos(w*t)

EDU>> simplify(B1-B2)

ans =

0

--Nasser

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com