Ask Your Question
1

SageMath cannot solve this system of equations?

asked 2023-01-10 18:07:27 +0100

lijr07 gravatar image

updated 2023-01-10 21:48:54 +0100

slelievre gravatar image

I am trying to use sagemath to solve a system of equations. But it doesn't give a solution. The equations has a solution when I checked using other software. My codes are:

x = {(i, j): var(f'x_{i}_{j}', latex_name=f'x_{{{i},{j}}}')
     for i in (1 .. 3) for j in (1 .. 3)}

y = {(i, j): var(f'y_{i}_{j}', latex_name=f'y_{{{i},{j}}}')
     for i in (1 .. 3) for j in (1 .. 3)}

va = list(x.values())

r1 = [-y_1_1 + x_2_1/x_2_2,
      -y_1_2 + x_2_2/x_2_3,
      -y_1_3 + x_1_1/x_1_2,
      -y_2_1 + x_1_2/x_1_3,
      x_3_1 - y_2_2,
      x_1_2*x_2_2*x_3_2 - y_2_3,
      x_1_3*x_2_3*x_3_3/x_1_1 - y_3_1,
      x_2_3*x_3_3 - y_3_2,
      x_1_3*x_2_3*x_3_2 - y_3_3]

solve(r1, va, solution_dict=True)

Is there some way to find solutions to these equations in SageMath? Thank you very much.

edit retag flag offensive close merge delete

Comments

I am curious :

  • What is the point of defining 80200 symbolic variables to use 18 of them ?

  • What is your "other software", and what code did you use in it ?

  • How did you check the answers ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-01-10 20:28:25 +0100 )edit

Sage ca solve the system composed of the 7 first equations of your system :

sage: solve(r1[:7], [v for v in va if v in list(set(flatten([u.variables() for u in r1[:7]])))], solution_dict=True)
[{x_1_1: y_1_1*y_1_3*y_2_3/(r32*r33),
  x_1_2: y_1_1*y_2_3/(r32*r33),
  x_1_3: y_1_1*y_2_3/(r32*r33*y_2_1),
  x_2_1: r32,
  x_2_2: r32/y_1_1,
  x_2_3: r32/(y_1_1*y_1_2),
  x_3_1: y_2_2,
  x_3_2: r33,
  x_3_3: y_1_1*y_1_2*y_1_3*y_2_1*y_3_1/r32}]

But both the 8th and 9th fail :

sage: solve(r1[:8], [v for v in va if v in list(set(flatten([u.variables() for u in r1[:8]])))], solution_dict=True)
[]
sage: solve(r1[:7]+r1[8:9], [v for v in va if v in list(set(flatten([u.variables() for u in r1[:7]+r1[8:9]])))], solution_dict=True)

HTH,

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-01-10 21:11:22 +0100 )edit

I edited the question to address Emmanuel's first point.

slelievre gravatar imageslelievre ( 2023-01-10 21:50:14 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-10 22:43:03 +0100

Emmanuel Charpentier gravatar image

updated 2023-01-10 22:48:02 +0100

As stated, the nine equations of r1 (with implicit zero right-had side) are mutually incompatible.

A brute-force search of the subsets of mutually incompatible equations can be done as follows :

# Search for all incompatible sets of equations in r1
DIS={}
for k in (1..len(r1)-1):
    IS=[]
    for s in Combinations(r1,k):
        v=[w for w in va if w in list(set(flatten([u.variables() for u in s])))]
        S=solve(s, v, solution_dict=True)
        if len(S)==0 : IS.append(s)
    if len(IS)>0: DIS.update({k:IS})
# End of search

Running this code shows that these incompatibilities may be quite specific :

sage: {u:(len(DIS[u]),binomial(9,u)) for u in DIS.keys()}
{4: (1, 126), 5: (7, 126), 6: (18, 84), 7: (20, 36), 8: (9, 9)}

For example, the four equations :

sage: DIS[4]
[[-y_1_2 + x_2_2/x_2_3,
  -y_2_1 + x_1_2/x_1_3,
  x_1_2*x_2_2*x_3_2 - y_2_3,
  x_1_3*x_2_3*x_3_2 - y_3_3]]

are mutually incompatible.

HTH,

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-01-10 18:07:27 +0100

Seen: 269 times

Last updated: Jan 10 '23