Ask Your Question
1

Why, in any system of equations, does Sage give repeated solutions only once?

asked 2022-07-23 16:52:53 +0200

georgeafr gravatar image

updated 2022-07-23 18:54:41 +0200

slelievre gravatar image

For example, the following system of equations has two roots equal to one:

var('a,b,c,d,e,f,g,x')
sols = solve([(a - g) + 2,  - (a*g - b) - 1, - (b*g - c), - (c*g - d) + 10, - (d*g - e) - 22, - f*g - 2, - (e*g - f) + 14], a,b,c,d,e,f,g, solution_dict=true)
[{g: sol[Eg]} for sol in sols]

Six, instead of seven, solutions are provided by Sage, because repeated root 1 is presented only once:

[{g: -1.825113562621674},
 {g: -0.04961250951921104 - 1.781741795058668*I},
 {g: -0.04961250951921104 + 1.781741795058668*I},
 {g: 0.2000320307495195},
 {g: 1.724306472919419},
 {g: 1}]

If you don't know which is the repeated root and you want to know which is it, how to do it, because with the use of multiplicities, or f.root, you cannot know

edit retag flag offensive close merge delete

Comments

Solving via SR's solve isn't exact : given :

var('a,b,c,d,e,f,g,x')
Sys=[(a - g) + 2,  - (a*g - b) - 1, - (b*g - c), - (c*g - d) + 10, - (d*g - e) - 22, - f*g - 2, - (e*g - f) + 14]
vars=list(set(flatten([u.variables() for u in Sys])))
sols=solve(Sys, vars, solution_dict=True)

The solutions do not check :

sage: [[u.subs(s).is_zero() for u in Sys] for s in sols]
[[False, False, False, False, False, False, False],
 [False, False, False, False, False, False, False],
 [False, False, False, False, False, False, False],
 [False, False, False, False, False, False, False],
 [False, False, False, False, False, False, False],
 [True, True, True, True, True, True, True]]
Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-07-23 21:27:40 +0200 )edit

A better (checkable) solution is to use the ring of polynomials of QQbar :

Vars=[str(u).upper() for u in vars]   #  My damn laziness...
R1=PolynomialRing(QQbar, Vars)
R1.inject_variables()
DD=dict(zip(vars, R1.gens()))
PSys=[R1(u.subs(DD)) for u in Sys]  # Even worse laziness...
J1=R1.ideal(*PSys)
V1=J1.variety()

Then the results can be checked :

sage: [[u.subs(s).is_zero() for u in PSys] for s in V1]
[[True, True, True, True, True, True, True],
 [True, True, True, True, True, True, True],
 [True, True, True, True, True, True, True],
 [True, True, True, True, True, True, True],
 [True, True, True, True, True, True, True],
 [True, True, True, True, True, True, True]]

But I have no idea about your multiplicity problem for now...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-07-23 21:31:45 +0200 )edit

Thank you Emmanuel, this is a good response to my question, but really what I am looking for is a solution like that of the answer below

georgeafr gravatar imagegeorgeafr ( 2022-07-23 22:19:08 +0200 )edit

@georgeafr : @rburing is right. He was faster|smarter than me... My remark was not (even tentatively) an answer to your question...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-07-23 22:47:00 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-07-23 20:47:10 +0200

rburing gravatar image

updated 2022-07-23 20:49:00 +0200

Here are the roots with multiplicities, using a different solution method:

sage: R.<a,b,c,d,e,f,g,x> = QQ[]
sage: I = R.ideal([(a - g) + 2,  - (a*g - b) - 1, - (b*g - c), - (c*g - d) + 10, - (d*g - e) - 22, - f*g - 2, - (e*g - f) + 14])
sage: F_g = I.elimination_ideal([a,b,c,d,e,f,x]).gen(0).polynomial(g); F_g
g^7 - 2*g^6 + g^5 - 10*g^3 + 22*g^2 - 14*g + 2
sage: F_g.roots(QQbar)
[(-1.825113480833768?, 1),
 (0.2000320256287094?, 1),
 (1, 2),
 (1.724306474243468?, 1),
 (-0.04961250951920454? - 1.781741795058673?*I, 1),
 (-0.04961250951920454? + 1.781741795058673?*I, 1)]

Indeed, the root 1 has multiplicity two.

edit flag offensive delete link more

Comments

With the same question: is it possible obtain a solution something like previous one if I starts directly from g^7 - 2g^6 + g^5 - 10g^3 + 22g^2 - 14g + 2?

georgeafr gravatar imagegeorgeafr ( 2022-07-23 21:59:57 +0200 )edit

Thanks a lot @rburing, good response. It satisfies my search.

georgeafr gravatar imagegeorgeafr ( 2022-07-24 00:38:49 +0200 )edit

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: 2022-07-23 16:52:53 +0200

Seen: 84 times

Last updated: Jul 23