How do you solve this system of multivariate polynomials?
11 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I am currently working on a problem that involves finding the roots of three polynomial equations with three variables. I have tried to use Groebner bases in Maple but failed so I am trying to find a solution in Matlab. In the code I want to set [Abl_x6, Abl_x7, Abl_x8] equal to zero. They are not polynomials yet, I do not know whether there is some sort of '(numer(normal(fx)))' command that can do that. And then, of course, I want to find the roots of the system. I am only interested in finding the roots with:
- x7<x6<x8
- x6,x7,x8 in (0,1)
Does somebody have an idea what to do here?
Thanks in advance!
Here is the code:
syms x1 x2 x3 x4 x6 x7 x8
a1 = (x3-x1)/(2*x7)+x7/2
a2 = (x2-x3)/(2*(x6-x7))+(x7+x6)/2
a3 = (x4-x2)/(2*(x8-x6))+(x8+x6)/2
Prof_A = x1*a1+x2*(a3-a2)
Prof_B = x3*(a2-a1)+x4*(1-a3)
Abl_x1 = diff(Prof_A,x1)
Abl_x2 = diff(Prof_A,x2)
Abl_x3 = diff(Prof_B,x3)
Abl_x4 = diff(Prof_B,x4)
S = solve(Abl_x1 == 0, Abl_x2 == 0, Abl_x3 == 0, Abl_x4 == 0);
x1 = S.x1
x2 = S.x2
x3 = S.x3
x4 = S.x4
a1 = (x3-x1)/(2*x7)+x7/2
a2 = (x2-x3)/(2*(x6-x7))+(x7+x6)/2
a3 = (x4-x2)/(2*(x8-x6))+(x8+x6)/2
Prof_A = x1*a1+x2*(a3-a2)
Prof_B = x3*(a2-a1)+x4*(1-a3)
Abl_x6 = diff(Prof_A,x6)
Abl_x7 = diff(Prof_B,x7)
Abl_x8 = diff(Prof_B,x8)
%p = [Abl_x6, Abl_x7, Abl_x8]; they are not polynomials yet
% probably one has to convert them
%grobnerBasis = gbasis(P,'MonomialOrder','lexicographic')
0 个评论
回答(1 个)
Yash
2023-9-5
Hi Fabian,
From your code, I can understand that you have 7 variables, "x1", "x2", "x3", "x4", "x6", "x7" and "x8". You are first solving for "x1", "x2", "x3" and "x4" in terms of the other variables, and putting them back to solve for the rest 3 variables.
I tried to solve for "Abl_x6==0", "Abl_x7==0" and "Abl_x8==0" using your code, but with this approach, the runtime of the code is very high. This is because solving the first 4 variables in terms of rest 3 makes all these expressions very complex. Instead, you should put all the conditions together in one "solve()" statement. This lets MATLAB do internal optimizations for solving.
After putting all the equations together, it becomes a problem having 7 equations and 7 variables.
Note that "vpa()" only works if all the parameters are resolved in the equations. Otherwise, substitute the parameters with numbers by using "subs()" before calling "vpa()", or try using the "eval()" or the "simplify()" function.
Please refer to the following sample code:
syms x1 x2 x3 x4 x6 x7 x8
a1 = (x3-x1)/(2*x7)+x7/2;
a2 = (x2-x3)/(2*(x6-x7))+(x7+x6)/2;
a3 = (x4-x2)/(2*(x8-x6))+(x8+x6)/2;
Prof_A = x1*a1+x2*(a3-a2);
Prof_B = x3*(a2-a1)+x4*(1-a3);
Abl_x1 = diff(Prof_A,x1);
Abl_x2 = diff(Prof_A,x2);
Abl_x3 = diff(Prof_B,x3);
Abl_x4 = diff(Prof_B,x4);
Abl_x6 = diff(Prof_A,x6);
Abl_x7 = diff(Prof_B,x7);
Abl_x8 = diff(Prof_B,x8);
S = solve(Abl_x1 == 0, Abl_x2 == 0, Abl_x3 == 0, Abl_x4 == 0,Abl_x6 == 0, Abl_x7 == 0, Abl_x8 == 0);
ans_x6 = vpa(S.x6);
ans_x7 = vpa(S.x7);
ans_x8 = vpa(S.x8);
I hope this helps you address the issue.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!