Ask Your Question
1

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

asked 2 years ago

georgeafr gravatar image

updated 2 years ago

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

Preview: (hide)

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 ( 2 years ago )

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 ( 2 years ago )

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 ( 2 years ago )

@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 ( 2 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 2 years ago

rburing gravatar image

updated 2 years ago

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.

Preview: (hide)
link

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 ( 2 years ago )

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

georgeafr gravatar imagegeorgeafr ( 2 years ago )

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: 2 years ago

Seen: 264 times

Last updated: Jul 23 '22