Solve for y in function z = f(x, y)
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tim Fulcher
am 7 Okt. 2023
Kommentiert: Sam Chak
am 9 Okt. 2023
Hi All,
I have a polynomial which is a function of x (2nd order) and y (fifth order) and I wish to solve for y. My equation is:
p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p21*x^2*y + p12*x*y^2 + p03*y^3 + p22*x^2*y^2 + p13*x*y^3 + p04*y^4 + p23*x^2*y^3 + p14*x*y^4 + p05*y^5
I have tried:
syms x y z p00 p10 p01 p20 p11 p02 p21 p12 p03 p22 p13 p04 p23 p14 p05
eqn = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p21*x^2*y + p12*x*y^2 + p03*y^3 + p22*x^2*y^2 + p13*x*y^3 + p04*y^4 + p23*x^2*y^3 + p14*x*y^4 + p05*y^5 == z
soly = solve(eqn,y)
and this has returned:
soly = root(p05*z1^5 + p14*x*z1^4 + p04*z1^4 + p23*x^2*z1^3 + p13*x*z1^3 + p03*z1^3 + p22*x^2*z1^2 + p12*x*z1^2 + p02*z1^2 + p11*x*z1 + p21*x^2*z1 + p01*z1 - z + p20*x^2 + p10*x + p00, z1, 1)
I'm afraid i don't recognize this format. Where did z1 come from and I assume the the 1 (before the closing parenthisis) implies that it is the first and only solution? Nor am I sure about the root.
I have tried something similar in the past:
syms x y z p00 p10 p01 p20 p11 p02 p30 p21 p12
eqn = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2 == z
soly = solve(eqn,y)
and this yielded a more familiar format:
-(p01 + p11*x + p21*x^2 + (p11^2*x^2 + p21^2*x^4 - 4*p00*p02 + 4*p02*z + p01^2 + 2*p01*p21*x^2 - 4*p02*p20*x^2 - 4*p10*p12*x^2 - 4*p02*p30*x^3 + 2*p11*p21*x^3 - 4*p12*p20*x^3 - 4*p12*p30*x^4 - 4*p00*p12*x + 2*p01*p11*x - 4*p02*p10*x + 4*p12*x*z)^(1/2))/(2*(p02 + p12*x))
-(p01 + p11*x + p21*x^2 - (p11^2*x^2 + p21^2*x^4 - 4*p00*p02 + 4*p02*z + p01^2 + 2*p01*p21*x^2 - 4*p02*p20*x^2 - 4*p10*p12*x^2 - 4*p02*p30*x^3 + 2*p11*p21*x^3 - 4*p12*p20*x^3 - 4*p12*p30*x^4 - 4*p00*p12*x + 2*p01*p11*x - 4*p02*p10*x + 4*p12*x*z)^(1/2))/(2*(p02 + p12*x))
Regards and thanks in advance.
Tim
1 Kommentar
Walter Roberson
am 7 Okt. 2023
syms x y z p00 p10 p01 p20 p11 p02 p30 p21 p12
eqn = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2 == z
soly = solve(eqn,y)
In eqn, the maximum power that y apears is y^2 so that eqn can be rephrased as a quadratic,
(p02 + p12*x)*y^2 + (p01 + p11*x + p21*x^2)*y + (p00 + p10*x + p20*x^2 + p30*x^3 - z) == 0
which can easily be solved.
But your original equation has y^5 and that gives you problems.
Akzeptierte Antwort
Sam Chak
am 7 Okt. 2023
Hi @Tim Fulcher
If the values for x and z are known, then you can numerically solve for y.
syms y
x = 1;
z = 0;
p00 = 1;
p10 = 1;
p01 = 1;
p20 = 1;
p11 = 1;
p02 = 1;
p21 = 1;
p12 = 1;
p03 = 1;
p22 = 1;
p13 = 1;
p04 = 1;
p23 = 1;
p14 = 1;
p05 = 1;
eqn = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p21*x^2*y + p12*x*y^2 + p03*y^3 + p22*x^2*y^2 + p13*x*y^3 + p04*y^4 + p23*x^2*y^3 + p14*x*y^4 + p05*y^5 == z
soly = vpasolve(eqn, y)
8 Kommentare
Sam Chak
am 9 Okt. 2023
Good to hear that, @Tim Fulcher. If you find the guidance helpful, please consider clicking 'Accept' ✔ on the answer to close the issue when the problem is solved.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Applications 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!