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:
how to solve trigonometric equation

Subject: how to solve trigonometric equation

From: Philippe

Date: 8 Jun, 2011 01:36:05

Message: 1 of 12

Dear all,

I would like to solve the following equation between 0 and 2 pi.

A*sin(w*t-p)+2*B*sin(2*w*t-q)=0

where A, B, w, p, q are constants.

t=?

Is there any way in Matlab to solve this equation?

Thanks

Subject: how to solve trigonometric equation

From: reza

Date: 8 Jun, 2011 02:16:21

Message: 2 of 12

On Jun 7, 9:36 pm, "Philippe " <philipp...@hotmail.com> wrote:
> Dear all,
>
> I would like to solve the following equation between 0 and 2 pi.
>
> A*sin(w*t-p)+2*B*sin(2*w*t-q)=0
>
> where A, B, w, p, q are constants.
>
> t=?
>
> Is there any way in Matlab to solve this equation?
>
> Thanks


You need the Symbolic Toolbox

>> syms A w t B q p
>> t = solve(A*sin(w*t-p)+2*B*sin(2*w*t-q))

/reza

Subject: how to solve trigonometric equation

From: John D'Errico

Date: 8 Jun, 2011 02:20:06

Message: 3 of 12

"Philippe " <philippeb3@hotmail.com> wrote in message <ismjm4$qe6$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I would like to solve the following equation between 0 and 2 pi.
>
> A*sin(w*t-p)+2*B*sin(2*w*t-q)=0
>
> where A, B, w, p, q are constants.
>
> t=?
>
> Is there any way in Matlab to solve this equation?

You can do it by hand. Start with the sin of a sum
identity to get rid of those p and q terms.

sin(x+y) = ...

Then reduce sin(2*x) using a similar identity.

In the end, you reduce this to a polynomial in
sin(w*t). Solve for the roots of that polynomial.
Once you know all possible solutions, then
compute t using an asin.

You do the work though, not me.

John

Subject: how to solve trigonometric equation

From: Philippe

Date: 8 Jun, 2011 14:36:05

Message: 4 of 12

> You can do it by hand. Start with the sin of a sum
> identity to get rid of those p and q terms.
>
> sin(x+y) = ...
>
> Then reduce sin(2*x) using a similar identity.
>
> In the end, you reduce this to a polynomial in
> sin(w*t). Solve for the roots of that polynomial.
> Once you know all possible solutions, then
> compute t using an asin.
>
> You do the work though, not me.
>
> John

Following your instruction, this is where I'm stuck

A*sin(wt) - B*cos(wt) + C*sin(wt)*cos(wt) + D*sin(wt)^2-D=0

where A, B, C, D are known numbers.

Any idea?

Subject: how to solve trigonometric equation

From: John D'Errico

Date: 8 Jun, 2011 14:58:04

Message: 5 of 12

"Philippe " <philippeb3@hotmail.com> wrote in message <iso1cl$nsr$1@newscl01ah.mathworks.com>...
> > You can do it by hand. Start with the sin of a sum
> > identity to get rid of those p and q terms.
> >
> > sin(x+y) = ...
> >
> > Then reduce sin(2*x) using a similar identity.
> >
> > In the end, you reduce this to a polynomial in
> > sin(w*t). Solve for the roots of that polynomial.
> > Once you know all possible solutions, then
> > compute t using an asin.
> >
> > You do the work though, not me.
> >
> > John
>
> Following your instruction, this is where I'm stuck
>
> A*sin(wt) - B*cos(wt) + C*sin(wt)*cos(wt) + D*sin(wt)^2-D=0
>
> where A, B, C, D are known numbers.
>
> Any idea?

Sure. Just follow my instructions. I told you exactly
what needed to be done.

Let Z = sin(w*t).

A*Z - B*cos(wt) + C*Z*cos(wt) + D*Z^2 - D = 0

Of course, we can get the cos in terms of the sin.

cos(w*t) = sqrt(1-Z^2)

A bit more algebra will rid you of the square roots.
(Hint isolate the square root term, and square.)

In the end, you have a 4th degree polynomial in Z.

Once you have the roots of this poly in Z, can you
solve for t? (Yes.)

Just a bit of simple algebra.

John

Subject: how to solve trigonometric equation

From: Philippe

Date: 8 Jun, 2011 16:35:23

Message: 6 of 12

> Sure. Just follow my instructions. I told you exactly
> what needed to be done.
>
> Let Z = sin(w*t).
>
> A*Z - B*cos(wt) + C*Z*cos(wt) + D*Z^2 - D = 0
>
> Of course, we can get the cos in terms of the sin.
>
> cos(w*t) = sqrt(1-Z^2)
>
> A bit more algebra will rid you of the square roots.
> (Hint isolate the square root term, and square.)
>
> In the end, you have a 4th degree polynomial in Z.
>
> Once you have the roots of this poly in Z, can you
> solve for t? (Yes.)
>
> Just a bit of simple algebra.
>
> John

Again, following your advice I got

(D+C^2)*Z^4+(2*A*D-2*B*C)*Z^3+(-2*D^2+A^2-C^2+B^2)*Z^2+(-2*B*C)*Z+B^2 = 0

The roots are...no idea...

Subject: how to solve trigonometric equation

From: John D'Errico

Date: 8 Jun, 2011 17:12:02

Message: 7 of 12

"Philippe " <philippeb3@hotmail.com> wrote in message <iso8cb$fqo$1@newscl01ah.mathworks.com>...
> > Sure. Just follow my instructions. I told you exactly
> > what needed to be done.
> >
> > Let Z = sin(w*t).
> >
> > A*Z - B*cos(wt) + C*Z*cos(wt) + D*Z^2 - D = 0
> >
> > Of course, we can get the cos in terms of the sin.
> >
> > cos(w*t) = sqrt(1-Z^2)
> >
> > A bit more algebra will rid you of the square roots.
> > (Hint isolate the square root term, and square.)
> >
> > In the end, you have a 4th degree polynomial in Z.
> >
> > Once you have the roots of this poly in Z, can you
> > solve for t? (Yes.)
> >
> > Just a bit of simple algebra.
> >
> > John
>
> Again, following your advice I got
>
> (D+C^2)*Z^4+(2*A*D-2*B*C)*Z^3+(-2*D^2+A^2-C^2+B^2)*Z^2+(-2*B*C)*Z+B^2 = 0
>
> The roots are...no idea...

Since all of these numbers but Z are given as constants
according to you, you have two choices. The first is
a trivial one.

help roots

If you need this to be a symbolic solution, then there IS
an analytical solution for the roots of a 4th degree
polynomial.

Or, simply throw it (at this point) at the symbolic toolbox.

John

Subject: how to solve trigonometric equation

From: Philippe

Date: 8 Jun, 2011 17:19:05

Message: 8 of 12

I actually need the symbolic solution, but Mathlab gives me a >6k caractere solution which is too long for the other software I need to use it with.

Thank you for your help

Philippe

Subject: how to solve trigonometric equation

From: Roger Stafford

Date: 8 Jun, 2011 19:35:05

Message: 9 of 12

"Philippe " <philippeb3@hotmail.com> wrote in message <isoau9$nel$1@newscl01ah.mathworks.com>...
> I actually need the symbolic solution, but Mathlab gives me a >6k caractere solution which is too long for the other software I need to use it with.
- - - - - - - - - -
  You can make things a little easier if you redefine your variables and parameters appropriately. First define

 x = w*t-q/2

which gives

 A*sin(x+q/2-p)+2*B*sin(2*x) = 0

Then define K = 4*B, L = A*sin(q/2-p), and M = A*cos(q/2-p) which gives

 (K*sin(x)+L)*cos(x) = -M*sin(x)

Squaring both sides and simplifying gives you the quartic equation:

 K^2*s^4 + 2*K*L*s^3 + (L^2+M^2-K^2)*s^2 - 2*K*L*s - L^2 = 0

where s = sin(x). For any root s = sin(x), you can solve for cos(x) using

 cos(x) = -M*s/(K*s+L)

and solve for x using the 'atan2' function.

  As John says, you can solve your problem using matlab's 'roots' function, or look up the analytic solution for quartics (a rather ambitious undertaking.)

  Here is the way matlab could be used to solve it:

 K = 4*B;
 L = A*sin(q/2-p);
 M = A*cos(q/2-p);
 s = roots([K^2,2*K*L,L^2+M^2-K^2,-2*K*L,-L^2]);
 s = s(imag(s)==0);
 x = atan2(s,-M*s./(K*s+L));
 wt = mod(x+q/2,2*pi);

The variable wt, which is w*t of your original equation, will have from two to four real values in the range 0 to 2*pi.

Roger Stafford

Subject: how to solve trigonometric equation

From: Roger Stafford

Date: 8 Jun, 2011 21:54:04

Message: 10 of 12

"Roger Stafford" wrote in message <isoit9$ipt$1@newscl01ah.mathworks.com>...
> "Philippe " <philippeb3@hotmail.com> wrote in message <isoau9$nel$1@newscl01ah.mathworks.com>...
> > I actually need the symbolic solution, but Mathlab gives me a >6k caractere solution which is too long for the other software I need to use it with.
> - - - - - - - - - -
> You can make things a little easier if you redefine your variables and parameters appropriately. First define
>
> x = w*t-q/2
>
> which gives
>
> A*sin(x+q/2-p)+2*B*sin(2*x) = 0
>
> Then define K = 4*B, L = A*sin(q/2-p), and M = A*cos(q/2-p) which gives
>
> (K*sin(x)+L)*cos(x) = -M*sin(x)
> ........
- - - - - - - -
  In that equation I gave earlier

 (K*sin(x)+L)*cos(x) + M*sin(x) = 0,

if you substitute y = x/2 (an idea I got from my own Symbolic Toolbox solution) it becomes

 (2*K*sin(y)*cos(y)+L)*(cos(y)^2-sin(y)^2)+2*M*sin(y)*cos(y) = 0

Upon dividing by cos(y)^4, and remembering that sec(y)^2 = tan(y)^2 + 1, we get the comparatively simple quartic equation:

 L*t^4 + 2*(K-M)*t^3 - 2*(K+M)*t - L = 0

where t = tan(y).

  Therefore as an alternative we can use the matlab code:

 K = 4*B;
 L = A*sin(q/2-p);
 M = A*cos(q/2-p);
 t = roots([L,2*(K-M),0,-2*(K+M),-L]);
 t = t(imag(t)==0);
 wt = mod(2*atan(t)+q/2,2*pi);

Roger Stafford

Subject: how to solve trigonometric equation

From: istanbul shipyard

Date: 22 May, 2013 16:47:08

Message: 11 of 12

Hi people, I am new here. It is good to see there are some people that I can ask question.
Here is my question. I am using Matlab R2008a 32 bit.
In my question a, B and L are constants.
I want to find B*L values.

Function is:

2+2*cos(B*L)*cosh(B*L)+2*cos(B*L)*a*B*L*sinh(B*L)-2*sin(B*L)*a*B*L*cosh(B*L)=0

It is very important and urgent for me. thank you in advance.

Subject: how to solve trigonometric equation

From: Nasser M. Abbasi

Date: 22 May, 2013 19:07:35

Message: 12 of 12

On 5/22/2013 11:47 AM, istanbul shipyard wrote:
> Hi people, I am new here. It is good to see there are some people that I can ask question.
> Here is my question. I am using Matlab R2008a 32 bit.
> In my question a, B and L are constants.
> I want to find B*L values.
>
> Function is:
>
> 2+2*cos(B*L)*cosh(B*L)+2*cos(B*L)*a*B*L*sinh(B*L)-2*sin(B*L)*a*B*L*cosh(B*L)=0
>
> It is very important and urgent for me. thank you in advance.
>

No analytical solution

EDU>> syms a x;
solve(2+2*cos(x)*cosh(x)+2*cos(x)*a*x*sinh(x)-2*sin(x)*a*x*cosh(x))
Warning: Explicit solution could not be found.
> In solve at 179
  
ans =
  
[ empty sym ]
  

Try numerical.

--Nasser

Tags for 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