Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

No tags are associated with this thread.

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.

Contact us