MATLAB Answers

How to separate a variable out of trigonomic expression

1 view (last 30 days)
Thom Gold
Thom Gold on 11 Dec 2019
Commented: Thom Gold on 11 Dec 2019
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 Comments

Show 1 older comment
Thom Gold
Thom Gold on 11 Dec 2019
Sorry for describing the problem a bit lazy.
My Problem is a mathematical one but I hoped that there would be a solver or function in MATLAB which could help me.
I have a control path with two Inputs. The Inputs are described by U1 = Fx / (m*g) and U2 = (Fz / (m*g)) - 1 . I want to transform the system into a single input system. For this transformation I wanted to use the (given) Equations Fx = F * sin (a+b) and Fz = cos(a+b).
My Input parameter should be an "a" or an trigonomic combination of "a". So I wanted to pull it out of the expression so that I have a vector of two terms which I can multiplicate with "a" or "sin(a)" or "cos(a)" such like: [Term1 ; Term 2] * "a" or [Term1 ; Term2] * "sin(a)" or [Term1 ; Term2] * "cos(a)".
My problem is, that I can't transform it to an expression where I can pull the Input variable out of it.
For this problem I hoped that there is MATLAB function which could help.
I'm not sure but I hope this will describe my problem a bit better.
Thank you very much
John D'Errico
John D'Errico on 11 Dec 2019
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.
Thom Gold
Thom Gold on 11 Dec 2019
already thought that there is no possibility.
I will try it another way.
Thank you very much for anyway trying to help :-)

Sign in to comment.

Answers (3)

Matt J
Matt J on 11 Dec 2019
Edited: Matt J on 11 Dec 2019
These identities may help,

  3 Comments

Thom Gold
Thom Gold on 11 Dec 2019
Sorry for describing the problem a bit lazy.
My Problem is a mathematical one but I hoped that there would be a solver or function in MATLAB which could help me.
I have a control path with two Inputs. The Inputs are described by U1 = Fx / (m*g) and U2 = (Fz / (m*g)) - 1 . I want to transform the system into a single input system. For this transformation I wanted to use the (given) Equations Fx = F * sin (a+b) and Fz = cos(a+b).
My Input parameter should be an "a" or an trigonomic combination of "a". So I wanted to pull it out of the expression so that I have a vector of two terms which I can multiplicate with "a" or "sin(a)" or "cos(a)" such like: [Term1 ; Term 2] * "a" or [Term1 ; Term2] * "sin(a)" or [Term1 ; Term2] * "cos(a)".
My problem is, that I can't transform it to an expression where I can pull the Input variable out of it.
For this problem I hoped that there is MATLAB function which could help.
I'm not sure but I hope this will describe my problem a bit better.
Thank you very much
Matt J
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
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.

Sign in to comment.


Alex Mcaulley
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))

  1 Comment

Thom Gold
Thom Gold on 11 Dec 2019
Sorry for describing the problem a bit lazy.
My Problem is a mathematical one but I hoped that there would be a solver or function in MATLAB which could help me.
I have a control path with two Inputs. The Inputs are described by U1 = Fx / (m*g) and U2 = (Fz / (m*g)) - 1 . I want to transform the system into a single input system. For this transformation I wanted to use the (given) Equations Fx = F * sin (a+b) and Fz = cos(a+b).
My Input parameter should be an "a" or an trigonomic combination of "a". So I wanted to pull it out of the expression so that I have a vector of two terms which I can multiplicate with "a" or "sin(a)" or "cos(a)" such like: [Term1 ; Term 2] * "a" or [Term1 ; Term2] * "sin(a)" or [Term1 ; Term2] * "cos(a)".
My problem is, that I can't transform it to an expression where I can pull the Input variable out of it.
For this problem I hoped that there is MATLAB function which could help.
I'm not sure but I hope this will describe my problem a bit better.
Thank you very much

Sign in to comment.


John D'Errico
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)

  1 Comment

Thom Gold
Thom Gold on 11 Dec 2019
Sorry for describing the problem a bit lazy.
My Problem is a mathematical one but I hoped that there would be a solver or function in MATLAB which could help me.
I have a control path with two Inputs. The Inputs are described by U1 = Fx / (m*g) and U2 = (Fz / (m*g)) - 1 . I want to transform the system into a single input system. For this transformation I wanted to use the (given) Equations Fx = F * sin (a+b) and Fz = cos(a+b).
My Input parameter should be an "a" or an trigonomic combination of "a". So I wanted to pull it out of the expression so that I have a vector of two terms which I can multiplicate with "a" or "sin(a)" or "cos(a)" such like: [Term1 ; Term 2] * "a" or [Term1 ; Term2] * "sin(a)" or [Term1 ; Term2] * "cos(a)".
My problem is, that I can't transform it to an expression where I can pull the Input variable out of it.
For this problem I hoped that there is MATLAB function which could help.
I'm not sure but I hope this will describe my problem a bit better.
Thank you very much

Sign in to comment.

Sign in to answer this question.