I want to check if something algebraically simplifies to 0 when i sub in values
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
joshua payne
am 27 Jan. 2023
Bearbeitet: John D'Errico
am 27 Jan. 2023
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 Kommentare
Akzeptierte Antwort
John D'Errico
am 27 Jan. 2023
Bearbeitet: John D'Errico
am 27 Jan. 2023
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 Kommentare
Weitere Antworten (1)
Torsten
am 27 Jan. 2023
Bearbeitet: Torsten
am 27 Jan. 2023
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]))
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!