Trigonometric approximation on symbolic variables

Hi,
I would like to know how to perform or represent trigonometric approximations in Matlab. For example, let's say I have the set of symbolic equations
cos(x) + sin(y) = Tp;
1 + x + sin(x) = Tw;
When making the assumption that x and y are small, I want to transform the equations into the form
1 + y = Tp;
1 + x + x = Tw;
Using the subs function to replace all the sines and cosines does not seem to be feasible when I have many variables.
Thank you

댓글 수: 2

Is it the case that some of the sin() and cos() arguments will be small but others will not? For example in cos(x1x2x3) should it be assumed that x1*x2*x3 will be "small", or is there the possibility that even though x1 and x2 are "small" that when multiplied by x3 that the result might be large enough to count ? Does it all need to be made conditional, something like
piecewise(x < small & y < small & 0 <= small + x & 0 <= small + y, y - Tp + 1, x < small & 0 <= small + x, sin(y) - Tp + 1, y < small & 0 <= small + y, y - Tp + cos(x), cos(x) - Tp + sin(y))
Here -small < x < small was used for the test on x being small enough for the substitution to be valid, with the case where it is not small preserved.
Aik Ann Seng
Aik Ann Seng 2019년 10월 6일
편집: Aik Ann Seng 2019년 10월 6일
No need, it can be assumed that all the variables within the sines and cosines are small, so any combination and powers of them can be considered small as well. I'm basically looking for a way to change all sines into their arguments and change all cosines into 1, without having to explicitly state every possible combination of sines and cosines and substituting them.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2019년 10월 6일
syms x y Tp Tw
eqn(1) = cos(x) + sin(y) - Tp;
eqn(2) = 1 + x + sin(x) - Tw;
for i = 1:2
eqn(i) = mapSymType( mapSymType(eqn(i), 'sin', @(x)children(x)), 'cos', @(x)1 );
end
This requires R2019a or later.

추가 답변 (1개)

darova
darova 2019년 10월 5일
subs works ok for me
syms x y Tp Tw
eqn{1} = cos(x) + sin(y) - Tp;
eqn{2} = 1 + x + sin(x) - Tw;
for i = 1:2
eqn{i} = subs(eqn{i},{'sin(y)' 'sin(x)' 'cos(x)'},{y,x,1})
end

댓글 수: 1

For this case, subs work due to the simple equations. But my actual model has multiple other variables, and therefore can have many combinations of sines and cosines. Hard substitution for each combination will therefore not be feasible in my case.
For example, if I have 3 variables
syms x1 x2 x3
I will then have the combinations
sin(x1)
sin(x2)
sin(x3)
sin(x1x2)
sin(x1x3)
sin(x2x3)
sin(x1x2x3)
cos(x1)
cos(x2)
cos(x3)
cos(x1x2)
cos(x1x3)
cos(x2x3)
cos(x1x2x3)
And you can see how subs will no longer be practical when I have more and more variables

댓글을 달려면 로그인하십시오.

카테고리

제품

릴리스

R2019b

질문:

2019년 10월 5일

댓글:

2019년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by