Symbolically solve multi-variable with substitution

6 vues (au cours des 30 derniers jours)
JBird7
JBird7 le 21 Juil 2017
(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.

Réponses (1)

Walter Roberson
Walter Roberson le 21 Juil 2017
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.)

Community Treasure Hunt

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

Start Hunting!

Translated by