How to solve simultaneous equation?

조회 수: 3 (최근 30일)
jaejin kim
jaejin kim 2020년 10월 7일
댓글: Walter Roberson 2021년 6월 9일
I hope to solve this simultaneous equation for y.
but I have some errors.
So i input the following code in Matlab R2018b:
clear all
>> syms A R B C y w t;
>> p1 = y - C*( (sin(w*t) )^2 / (A + sqrt(R*y + B^2)));
>> sol = solve([p1 == 0], y, 'ReturnConditions', true);
>> sol = solve([p1 == 0], y);
Warning: Solutions are parameterized by the symbols: z1. To include parameters and conditions in the
solution, specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 475)
In solve (line 357)
Warning: Solutions are valid under the following conditions: (signIm(A*1i - (C*sin(t*w)^2*1i)/z1) == -1 |
A*z1 == C*sin(t*w)^2 & z1 ~= 0) & C^2*sin(t*w)^4 + A^2*z1^2 == R*z1^3 + B^2*z1^2 + 2*A*C*z1*sin(t*w)^2.
To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 482)
In solve (line 357)
No matter what i do i can't make this to work. It's very strange. Any help will be greatly appreciated. Thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2020년 10월 7일
syms A R B C y w t;
eqn = y == C*( (sin(w*t) )^2 / (A + sqrt(R*y + B^2)));
[n,d] = numden(rhs(eqn));
ysol = solve(eqn * d, y, 'maxdegree', 3)
  댓글 수: 2
jaejin kim
jaejin kim 2020년 10월 7일
편집: jaejin kim 2020년 10월 7일
As you know, the solution is very complicated. I hope to get simple solution or approximation. I want to remove meaningless or really small terms.
I expect the solution is about a*sin(wt) + b*(sin(wt)^2) .
For example, A = 2.213, R = 0.736, B^2 = 0.182, C = 10, w = 2000
Isn't there a way to simply change the solution I got?
Walter Roberson
Walter Roberson 2021년 6월 9일
syms A R B C y sinwt
eqn = y == C*( (sinwt )^2 / (A + sqrt(R*y + B^2)));
[n,d] = numden(rhs(eqn));
ysol = solve(eqn * d, y, 'maxdegree', 3)
ysol = 
yt = simplify(arrayfun(@(X) taylor(X, sinwt, 0, 'Order', 3), ysol))
yt = 
ytn = combine(subs(yt, {A,R,B,C}, {sym('2.213'), sym('0.736'), sqrt(sym('0.182')), sym('10.')}))
ytn = 
ytn4 = vpa(ytn)
ytn4 = 
ytn4b = mapSymType(ytn4, 'number', @(v) piecewise(imag(v) > -1e-5 & imag(v) < 1e-5, real(v), v))
ytn4b = 
ytn4c = mapSymType(ytn4b, 'number', @(v) piecewise(real(v) > -1e-5 & real(v) < 1e-5, imag(v), v))
ytn4c = 
ytn4d = vpa(ytn4c,4)
ytn4d = 
The step of taking vpa(ytn) is crucial for combining various numeric expressions that individually use numbers large enough that they cannot reasonably be ignored, but which largely "cancel out"
The two steps using mapSymType() could be combined into one step, but it would be complicated to write, like "imaginary part is more negative than this or more positive than that but real part is less negative and less positive, then select the imaginary part without the real part". In my judgement, the result would be less clear than handling the two parts independently.
I use taylor order 3 here. If you use taylor order 4, you get exactly the same result -- the taylor output is exactly the same. If you use taylor order 5 or 6 then you get a sinwt^4 term, which you indicated that you do not expect.
Note that the fact that you do not expect sinwt^4 or higher order terms, does not mean that they are not significant.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Formula Manipulation and Simplification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by