Ask Your Question

Larousir's profile - activity

2022-09-29 09:32:39 +0200 received badge  Notable Question (source)
2020-09-08 15:44:44 +0200 commented answer Solve a system of polynomial equations - getting different results using Symbolic Math Toolbox of MATLAB and Sage

I just edited my initial question with the raw eqautions.

2020-09-05 19:26:29 +0200 received badge  Popular Question (source)
2020-09-04 12:21:49 +0200 received badge  Nice Question (source)
2020-09-04 10:10:17 +0200 received badge  Editor (source)
2020-09-04 10:07:09 +0200 answered a question Solve a system of polynomial equations - getting different results using Symbolic Math Toolbox of MATLAB and Sage

Waw...Thanks a lot Emmanual for all the efforts you are spending to help on this issue.

I have been trying your proposed solution but I am getting :

J.dimension()
1

I am probably doing something wrong but I will be posting the equations with the original quantities if this can be helpful to debug.

Thanks again for your support.

2020-08-27 22:57:57 +0200 received badge  Student (source)
2020-08-26 19:09:14 +0200 commented question Solve a system of polynomial equations - getting different results using Symbolic Math Toolbox of MATLAB and Sage

Thanks Emmanuel and SLelievre for your quick answer.

Really sorry for the formatting issue. I am new to sage and this is the first time I post a question here.

So after taking a quick look on the proposed solution by SLelievre, I guess we need to transform these equations to ploynomials and then use groebner_basis() to solve it rather than roots(). Am I right?

Thanks,

2020-08-26 13:43:26 +0200 asked a question Solve a system of polynomial equations - getting different results using Symbolic Math Toolbox of MATLAB and Sage

I am trying to solve the following system of equations:

eq1 = 0.8 - 1.8352657742116e-5*sqrt(x1*(3071.1916*x2 + (2.19736842105263e-5 *x3 - 0.378721571752863)*(3069.38078875823*x1 - 802.539479414006*x2 - 802.539479414006*x3 + 1187113.71566341))/(2.19736842105263e-5*x3 - 0.378721571752863))

eq2 = (-0.00117574932506308*x2*sqrt(-(0.039945461792316*x2 + 0.039945461792316*x3 - 71.5306505072653)*(3071.1916*x2 + 32.9605263157895*x3 - 568082.357629294)/(2.19736842105263e-5*x3 - 0.378721571752863)) + 1.8352657742116e-5*sqrt(x1*(3071.1916*x2 + (2.19736842105263e-5*x3 - 0.378721571752863)*(3069.38078875823*x1 - 802.539479414006*x2 - 802.539479414006*x3 + 1187113.71566341))/(2.19736842105263e-5*x3 - 0.378721571752863))*(x2 + x3))/(x2 + x3)

eq3 = (0.007585843252*x2*(x2 + x3) - 0.00117574932506308*x3*sqrt(-(0.039945461792316*x2 + 0.039945461792316*x3 - 71.5306505072653)*(3071.1916*x2 + 32.9605263157895*x3 - 568082.357629294)/(2.19736842105263e-5*x3 - 0.378721571752863))*(2.19736842105263e-5*x3 - 0.378721571752863) + (x2 + x3)*(2.19736842105263e-5*x3 - 0.378721571752863)*(-0.00198227251415259*x2 - 0.00198227251415259*x3 + 42.4521708776886))/((x2 + x3)*(2.19736842105263e-5*x3 - 0.378721571752863))

When I use Symbolic Math Toolbox in Matlab through the following command:

[x1_bar,x2_bar,x3_bar] = solve(eqs,[x1,x2,x3], 'MaxDegree',4);

we get the following results:

x1_bar
ans =

1.0e+04 *

-0.0116 + 0.0000i
 0.5338 + 0.0000i
-0.0232 + 0.0000i
 0.2669 + 0.0000i
-0.0047 + 0.0000i
 1.3191 + 0.0000i
-0.0321 - 0.5445i
 0.0007 - 0.0113i
-0.0321 + 0.5445i
 0.0007 + 0.0113i
-0.0012 + 0.0000i
 5.1569 + 0.0000i

x2_bar = 
1.0e+03 *

 1.9653 + 0.0000i
 1.9653 + 0.0000i
 0.2480 + 0.0000i
 0.2480 + 0.0000i
-0.6495 + 0.0000i
-0.6495 + 0.0000i
-0.1794 + 0.2236i
-0.1794 + 0.2236i
-0.1794 - 0.2236i
-0.1794 - 0.2236i
-0.0393 + 0.0000i
-0.0393 + 0.0000i

x3_bar = 
1.0e+04 *

-0.0174 + 0.0000i
-0.0174 + 0.0000i
 0.6522 + 0.0000i
 0.6522 + 0.0000i
 4.8817 + 0.0000i
 4.8817 + 0.0000i
 0.2382 + 2.1159i
 0.2382 + 2.1159i
 0.2382 - 2.1159i
 0.2382 - 2.1159i
 1.7273 + 0.0000i
 1.7273 + 0.0000i

When I try to solve this problem with Sage using:

S = solve([eq1,eq2,eq3],x1,x2,x3)

I obtain the following results:

[{x1: -321.3551367159828 - 5445.311876550251*I,
  x2: -179.359654094372 - 223.5730259195566*I,
  x3: 2381.999033439763 - 21159.38999334523*I},
 {x1: 6.685918535164614 - 113.2918302698741*I,
  x2: -179.359654094372 - 223.5730259195566*I,
  x3: 2381.999033439763 - 21159.38999334523*I},
 {x1: 6.685918535164623 + 113.2918302698741*I,
  x2: -179.359654094372 + 223.5730259195566*I,
  x3: 2381.999033439763 + 21159.38999334523*I},
 {x1: -321.3551367159836 + 5445.311876550251*I,
  x2: -179.359654094372 + 223.5730259195566*I,
  x3: 2381.999033439763 + 21159.38999334523*I}]

I tried also to use the PolynomialRing but it is failing to solve the problem.

EDIT : Here are the raw equations with the original quantities:

eq1 =w_G_a_in - K_a*sqrt((x1*(R*T_a + g*L_a*M_G_a)*((g*L_a*x1)/V_a - 
    (g*L_r*(x2 + x3 - L_bh*S_bh*rho_L))/V_r - F_riser + (R*T_a*x1)/(V_a*M_G_a)
    + (R*T_r*rho_L*x2)/(M_G_r_t*(x3 - V_r*rho_L + L_bh*S_bh*rho_L))))/(R*T_a*V_a))



eq2 =K_a*sqrt((M_G_a*((g*L_a*x1)/V_a + (R*T_a*x1)/(V_a*M_G_a))*((g*L_a*x1)/
    V_a - (g*L_r*(x2 + x3 - L_bh*S_bh*rho_L))/V_r - F_riser + (R*T_a*x1)/(V_a*M_G_a)
    + (R*T_r*x2)/(M_G_r_t*(L_bh*S_bh - V_r + x3/rho_L))))/(R*T_a))-(GOR*PI*(2*F_riser - P_r + g*L_bh*rho_L + (g*L_r*(x2 + x3 - L_bh*S_bh*rho_L))/V_r 
 - (R*T_r*x2)/(M_G_r_t*(L_bh*S_bh - V_r + x3/rho_L))))/(GOR + 1) - (K_r*u1*x2*
 sqrt(-((P0 + (R*T_r*x2)/(M_G_r_t*(L_bh*S_bh - V_r + x3/rho_L)))*(x2 + x3 - L_bh*S_bh*rho_L))/V_r))/(x2 + x3)



eq3 =PI*(GOR/(GOR + 1) - 1)*(2*F_riser - P_r + g*L_bh*rho_L + (g*L_r*(x2 + x3
     - L_bh*S_bh*rho_L))/V_r - (R*T_r*x2)/(M_G_r_t*(L_bh*S_bh - V_r + x3/rho_L)))
- (K_r*u1*x3*sqrt(-((P0 + (R*T_r*x2)/(M_G_r_t*(L_bh*S_bh - V_r + x3/rho_L)))*(x2 + x3 - L_bh*S_bh*rho_L))/V_r))/(x2 + x3)