I want to check if something algebraically simplifies to 0 when i sub in values
조회 수: 2 (최근 30일)
이전 댓글 표시
clc
clear
syms q1 q2 q3 g Y u a rho e
E=[q2,((q2^2)/q1)*(1-(g-1)*.5)+(g-1)*q3,((q3*q2)/q1)+(g-1)*((q3*q2)/q1)-.5*(g-1)*(q2^3/q1^2)]
Q=[q1,q2,q3]
J=jacobian(E,Q)
pretty((2*q2^3*(g/2 - 1/2))/q1^3 - (q2*q3)/q1^2 - (q2*q3*(g - 1))/q1^2)
pretty(q3/q1 - (3*q2^2*(g/2 - 1/2))/q1^2 + (q3*(g - 1))/q1)
pretty(q2/q1 + (q2*(g - 1))/q1)
C=det(J-Y*eye(3))
C2=simplify(C)
so i have Y= u, u-a and u+a
q1= rho, q2=rho*u, and q3=e
all of these are symbolic and have no values but i want to sub in all the q's and 1 by 1 the Y's to see if they simplify to 0.
how would i do this?
댓글 수: 0
채택된 답변
John D'Errico
2023년 1월 27일
편집: John D'Errico
2023년 1월 27일
syms q1 q2 q3 g Y u a rho e
E=[q2,((q2^2)/q1)*(1-(g-1)*.5)+(g-1)*q3,((q3*q2)/q1)+(g-1)*((q3*q2)/q1)-.5*(g-1)*(q2^3/q1^2)];
Q=[q1,q2,q3];
J=jacobian(E,Q);
pretty((2*q2^3*(g/2 - 1/2))/q1^3 - (q2*q3)/q1^2 - (q2*q3*(g - 1))/q1^2)
pretty(q3/q1 - (3*q2^2*(g/2 - 1/2))/q1^2 + (q3*(g - 1))/q1)
pretty(q2/q1 + (q2*(g - 1))/q1)
C=det(J-Y*eye(3))
C2=simplify(C)
Now, if you have q1,q2,q3
C2 = subs(C2,[q1,q2,q3],[rho,rho*u,e])
expand(C2)
So nothing special happening so far. Now you want t osub in those possible values for Y. Just do it.
simplify(expand(subs(C2,Y,[u,u+a,u-a])))
Simple enough. When Y == u, everything goes away, but not so in the other cases.
Another way of doing this is to see for which values of Y, C2 would be zero.
Ysol = solve(C2 == 0,Y)
It finds three solutions, one of which is the case you wanted. The other two are alternatives. I could check under which conditions they apply, but most likely it would just tell me that rho cannot be zero.
댓글 수: 0
추가 답변 (1개)
Torsten
2023년 1월 27일
편집: Torsten
2023년 1월 27일
Euler equations of gas dynamics ?
Eigenvalues and Eigenvectors of the Jacobian are well-studied. Why reinvent the wheel ?
syms q1 q2 q3 g Y u a rho e
E=[q2,((q2^2)/q1)*(1-(g-1)*.5)+(g-1)*q3,((q3*q2)/q1)+(g-1)*((q3*q2)/q1)-.5*(g-1)*(q2^3/q1^2)];
Q=[q1,q2,q3];
J=jacobian(E,Q);
[S,V] = eig(J)
S = simplify(subs(S,[q1 q2 q3],[rho rho*u e]))
V = simplify(subs(V,[q1 q2 q3],[rho rho*u e]))
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!