How to separate a variable out of trigonomic expression
1 次查看(过去 30 天)
显示 更早的评论
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?
4 个评论
John D'Errico
2019-12-11
It looks like the answers we have tried to offer are all a bit off-base, given the comment.
But even so, you cannot use MATLAB to do that which is not mathematically possible. That is, you cannot write a term like sin(a+b) or cos(a+b) in a separable product form like f1(a)*f2(b). No solver applies here, because it is not possible to achieve.
I would suggest you need to reconsider the approach you wish to take.
回答(3 个)
Matt J
2019-12-11
编辑:Matt J
2019-12-11
These identities may help,
3 个评论
Matt J
2019-12-11
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
2019-12-11
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
2019-12-11
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
2019-12-11
编辑:John D'Errico
2019-12-11
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)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!