Symbolically solve multi-variable with substitution

조회 수: 7 (최근 30일)
JBird7
JBird7 2017년 7월 21일
답변: Walter Roberson 2017년 7월 21일
(simplified version) I have two equations that describe the same curve:
a*x^2 + b*x*y + c*y^2 = 1;
d*x^2 + e*x*y + f*y^2 = 1;
How do I symbolically solve for g,h in terms of p,q?
syms x y;
syms g h p q;
syms a b c d e f ;
%for example, not strictly true:
a = g/(g+h);
b = g/(g-h);
c = h/(g+h);
d = p/(p+2*q);
e = p/(3*p-q);
f = 4*q/(p+q);
expression1 = a*x^2 + b*x*y + c*y^2;
expression2 = d*x^2 + e*x*y + f*y^2;
[C1,T] = coeffs(expression1, [x, y]);
[C2,T] = coeffs(expression2, [x, y]);
%equating coefficients gives 3 equations, want to symbolically solve 2 variables
[g, h] = solve(C1 == C2, [g, h]);
I am looking for equations for g and h, that are functions of p,q such as g = p/(q+p). The above expressions are highly simplified, I'm looking for general procedure for using solve() in this way, with a,b,c,d,e,f as middleman variables. Please would you comment on this method. Thank you.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 7월 21일
Solving more equations than variables can only work when all of the equations are redundant except for the same number as the number of variables to solve for. If that is known to be the case, then select a subset of the equations (though you might need extra steps as you might not know at the beginning which of the equations are redundant.)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by