4 views (last 30 days)

I have two trigonomic expressions ( cos(a+b) / sin(a+b) ).

Is there a possibility to separate one of the variables so that I have terms with an isolated sin(a) or cos(a) so that I can pull these terms out of the expressions?

Matt J
on 11 Dec 2019

Edited: Matt J
on 11 Dec 2019

These identities may help,

Matt J
on 11 Dec 2019

I've answered your question. Using the identities I posted, you can write instead

Fx = F*( sin(a)*cos(b) + cos(a)*sin(b) );

Fz = F*( cos(a)*cos(b) - sin(a)*sin(b) );

Matt J
on 11 Dec 2019

Thom replied:

Thank you for your answer,

I was already at this point but what I need is an expression which contains only "sin(a)" or "cos(a)" expressions so that I can pull it out of both terms.

If there is a combination of sin and cos in it I can't pull it out of the term.

Alex Mcaulley
on 11 Dec 2019

It is not a Matlab question, but you can do:

cos(a+b)/sin(a+b) = 1/tg(a+b) = (1-tg(a)*tg(b))/(tg(a)+tg(b))

John D'Errico
on 11 Dec 2019

Edited: John D'Errico
on 11 Dec 2019

As has been pointed out, this is not remotely a question about MATLAB, but you have gotten two answers already, so let me point out some things.

Fiirst, you don't really have two expressions, but one expression, with a numerator and a denominator. And, you need to explain what it is that you want to do with this, because such an expression does not exist in a vacuum. For example, are you hoping to be able to write it in a form like

f1(a)*f2(b)

or perhaps

f1(a) + f2(b)

by using only simple algebraic operations? If so, then the answer is no, you cannot do so. MATLAB cannot help you there.

If, perhaps you have something of the form

U = cos(a+b)/sin(a+b)

and you want to solv e for a as a function of b and U? Then you can do something, although even that has limits.

U = 1/tan(a+b) = (1 - tan(a)*tan(b))/(tan(a) + tan(b))

or...

(tan(a) + tan(b)) * U = 1 - tan(a)*tan(b)

so we can write it as

tan(a)*(U + tan(b)) = 1 - tan(b)*U

therefore,

tan(a) = (1 - tan(b)*U)/(U + tan(b))

Honestly, I don't think that is what you intended by your question.

Or, perhaps if you have

U = 1/(tan(a+ b)

then we can trivially solve for a as

a = atan(1/U) - b

Again, I don't think this is what you are looking for, based on how you phrased your question.

There might be other thigns you could do. For example, if a is known to be relatively small, then you could expand the expression

cos(a + b)/sin(a + b)

in the form of a truncated Taylor series, expanded around b. That is,

syms a b

U = cos(a + b)/sin(a+b);

taylor(U,a,'expansion',b)

ans =

cos(2*b)/sin(2*b) + (a - b)^4*((5*cos(2*b))/(24*sin(2*b)) + (cos(2*b)*(cos(2*b)^2/(3*sin(2*b)^2) + (cos(2*b)*(cos(2*b)/(3*sin(2*b)) + (cos(2*b)*(cos(2*b)^2/sin(2*b)^2 + 1/2))/sin(2*b)))/sin(2*b) + 5/24))/sin(2*b) + (cos(2*b)*(cos(2*b)^2/sin(2*b)^2 + 1/2))/(2*sin(2*b))) - (a - b)^5*((5*cos(2*b)^2)/(24*sin(2*b)^2) + (cos(2*b)*(cos(2*b)/(3*sin(2*b)) + (cos(2*b)*(cos(2*b)^2/sin(2*b)^2 + 1/2))/sin(2*b)))/(2*sin(2*b)) + (cos(2*b)*((2*cos(2*b))/(15*sin(2*b)) + (cos(2*b)*(cos(2*b)^2/(3*sin(2*b)^2) + (cos(2*b)*(cos(2*b)/(3*sin(2*b)) + (cos(2*b)*(cos(2*b)^2/sin(2*b)^2 + 1/2))/sin(2*b)))/sin(2*b) + 5/24))/sin(2*b) + (cos(2*b)*(cos(2*b)^2/sin(2*b)^2 + 1/2))/(3*sin(2*b))))/sin(2*b) + 2/15) - (a - b)^3*(cos(2*b)^2/(2*sin(2*b)^2) + (cos(2*b)*(cos(2*b)/(3*sin(2*b)) + (cos(2*b)*(cos(2*b)^2/sin(2*b)^2 + 1/2))/sin(2*b)))/sin(2*b) + 1/3) + (cos(2*b)/(2*sin(2*b)) + (cos(2*b)*(cos(2*b)^2/sin(2*b)^2 + 1/2))/sin(2*b))*(a - b)^2 - (a - b)*(cos(2*b)^2/sin(2*b)^2 + 1)

The result will be essentially a low order polynomial in a. As long as a is relatively small, we can truncate the polynomial, throwing away any high order terms in a. a might need to be very small however for the result to have any value.

taylor(U,a,'expansion',b,'order',2)

ans =

cos(2*b)/sin(2*b) - (a - b)*(cos(2*b)^2/sin(2*b)^2 + 1)

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 4 Comments

## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/496154-how-to-separate-a-variable-out-of-trigonomic-expression#comment_777060

⋮## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/496154-how-to-separate-a-variable-out-of-trigonomic-expression#comment_777060

## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/496154-how-to-separate-a-variable-out-of-trigonomic-expression#comment_777141

⋮## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/496154-how-to-separate-a-variable-out-of-trigonomic-expression#comment_777141

## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/496154-how-to-separate-a-variable-out-of-trigonomic-expression#comment_777151

⋮## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/496154-how-to-separate-a-variable-out-of-trigonomic-expression#comment_777151

## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/496154-how-to-separate-a-variable-out-of-trigonomic-expression#comment_777155

⋮## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/496154-how-to-separate-a-variable-out-of-trigonomic-expression#comment_777155

Sign in to comment.