How to solve 3 simultaneous algebraic equations with a equality constraint.
이전 댓글 표시
If someone could help me to plot x1 vs t from the information. Please if someone could give any idea.
%Initial conditions
x1=140; x2=140; x3=140;
%Equations
x1 =t*x1+x2+t*x3;
x2 = 2*t*x1+t*x2+x3;
x3 = t*x1+x2+x3;
% Equality constraint
x1+x2+x3=420;
댓글 수: 3
Alan Stevens
2021년 6월 23일
As you give "initial conditions" and want a plot of x1 as a function of t, should those equatios be the following differential equations (you have written algebraic equations):
dx1/dt =t*x1+x2+t*x3;
dx2/dt = 2*t*x1+t*x2+x3;
dx3/dt = t*x1+x2+x3;
MSM Farhan
2021년 7월 27일
N1=976:1:10000;
Q1=976:1:10000;
N=reshape (N1, 95, 95);
Q=reshape (q1, 95, 95);
Z0=4
Z1=1
f0=9.0336
f1=-0.3275
D1=10
D2=10
d1=10
d2=10
H1=10
H2=10
n1=10
K1=10
c11=N*Z1-f1/4-(3/4)*cos(2*q)*(2*f0+ f1)-2*(sin(q).^2-cos(q).^2)*D1+4*(cos(q).^2)*
(cos (q).^2-3*(sin(q).^2))*d1+H1*sin(q)+H2*cos (q)-2*n1+4*K1*sin(2*q)
c22=N*Z1-f1/4-(3/4 )*cos(2*q)*(2*f0+f1)-2*(sin(q).^2-cos(q).^2)*D2+4*(cos(q).^2)*(cos
(q).^2-3*(sin(q).^2))*d2+H1*sin(q)+H2*cos (q)-2*n1+4*K1*sin(2*q)
c21=-N*Z1+f1/4-(3/4 )*cos(2*q)*f1+2*n1
a1=-(3/4 )*sin(2*q)*(f0+f1)+D1*sin(2*q)+2*d1*(cos(q).^2)*sin(2*q)-H1*cos(q)+H2*sin(q)- 2*K1*cos(2*q)
a2=-(3/4 )*sin(2*q)*(f0+ f1)+D2*sin(2*q)+2*d2*(cos(q).^2 )*sin(2*q)-H1*cos(q)+H2*sin(q)- 2*K1*cos(2*q)
C11=(c21+c22)/(2*(c11*c22-c21.^2))
C21=(c11+c21)/(2*(c21.^2-c11*c22))
e1=(a2-a1)*C11
e2=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-e2).^4)-(2/3)*K1*sin (2*q)*(e1.^4+e2.^4)
R=E0+E1+E2+E3+E4;
Figure (1)
h=surf (R);
h=xlabel (‘J/\omega‘);
h=ylabel (‘angle \theta (radians)‘);
h=Zlabel (‘E(\theta) /\omega‘);
Walter Roberson
2021년 7월 27일
That does not appear to be related? please open a new question, and when you do please be more clear what you are asking for.
채택된 답변
추가 답변 (1개)
Ildeberto de los Santos Ruiz
2021년 7월 21일
You only need to express
in terms of t and plot that relationship:
syms x1 x2 x3 t
x3 = solve(x1+x2+x3 == 420,x3)
EQ1 = x1 == t*x1+x2+t*x3;
EQ2 = x2 == 2*t*x1+t*x2+x3;
[x1,x2] = solve(EQ1,EQ2)
ezplot(x1,[0,2])

댓글 수: 5
Walter Roberson
2021년 7월 21일
you missed x3 = t*x1+x2+x3;
There are four equations in four variables (including t). There is one solution that is all real and two that involve complex values. Because you have the same number of equations and variables and there are no redundant equations, you cannot end up with t as a free parameter.
Ildeberto de los Santos Ruiz
2021년 7월 21일
편집: Ildeberto de los Santos Ruiz
2021년 7월 21일
The original post (from Shiv) does not ask to find a unique solution for
, but only to plot
versus t. Due to the constraint,
is not a true variable, since it results from an affine combination of
and
.
Walter Roberson
2021년 7월 21일
The original post was created thinking that there would be a general solution to the system, that for each t value there would be an x1, x2, x3 value that would satisfy all of the equations and the constraint as well.
Your solution satisfies the constraint, and the first two equations, but not the third equation. You "pick and choose" which of the equations to use; you would have gotten a different answer if you had picked the second and third equations instead of the first and second.
Ildeberto de los Santos Ruiz
2021년 7월 21일
편집: Ildeberto de los Santos Ruiz
2021년 7월 21일
If someone could help me to plot x1 vs t from the information.
And the information given includes three equations plus one constraint equation.
syms x1 x2 x3 t
x3 = solve(x1+x2+x3 == 420,x3)
EQ1 = x1 == t*x1+x2+t*x3;
EQ2 = x2 == 2*t*x1+t*x2+x3;
EQ3 = x3 == t*x1+x2+x3;
[x1_12,x2_12] = solve(EQ1,EQ2)
[x1_13,x2_13] = solve(EQ1,EQ3)
[x1_23,x2_23] = solve(EQ2,EQ3)
ezplot(x1_12,[-2,5])
hold on
ezplot(x1_13,[-2 5])
ezplot(x1_23,[-2 5])
hold off
legend({'EQ1,EQ2', 'EQ1,EQ3', 'EQ2,EQ3'}, 'location', 'southwest');
Three very different pairwise answers. It looks like there might be a common answer near t = 3; let us see:
ezplot(x1_12,[2.5,3.5])
hold on
ezplot(x1_13,[2.5,3.5])
ezplot(x1_23,[2.5,3.5])
hold off
legend({'EQ1,EQ2', 'EQ1,EQ3', 'EQ2,EQ3'}, 'location', 'southwest');
tsol = vpasolve(x1_12 == x1_13, 3)
X1 = subs([x1_12, x1_13, x1_23], t, tsol(2))
X2 = subs([x2_12, x2_13, x2_23], t, tsol(2))
So far, so good, the pairs of equation seem to check out.
X3 = subs(x3, [x1, x2], [X1(1), X2(1)])
... which is the solution from the first row of solutions I posted in https://www.mathworks.com/matlabcentral/answers/862790-how-to-solve-3-simultaneous-algebraic-equations-with-a-equality-constraint#answer_731385
That is, there is only one real-valued solution to all of the equations simultaneously.
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





















