Multiplicity of solutions

74 views
Skip to first unread message

Michael Friedman

unread,
Jun 5, 2009, 12:26:33 PM6/5/09
to sage-support
Hi all

I'm pretty new to Sage, so I'm sorry in advance for the trivial
question.
I have a set of (non-linear) equations, and I need to find the
multiplicity
of each solution. How do I do it?

thanks alot,
Michael

simon...@uni-jena.de

unread,
Jun 5, 2009, 2:05:13 PM6/5/09
to sage-support
Hi Michael,

On 5 Jun., 18:26, Michael Friedman <ois3...@gmail.com> wrote:
> I'm pretty new to Sage, so I'm sorry in advance for the trivial
> question.
> I have a set of (non-linear) equations, and I need to find the
> multiplicity of each solution. How do I do it?

First of all, solving a nonlinear eqution is not a trivial question
IMHO.

There are various useful ways of getting help from Sage. One is
"search_def". When I did
sage: search_def('multiplicities')
I got three replies, two of them in the module
sage.symbolic.expression: There is a multiplicity option for the
methods "roots" and "solve".

So, you could define some symbolic expression and apply the solve
method, e.g.:
sage: z = var('z')
sage: E=(z^3-1)^3
sage: E.solve(z, multiplicities=True)
([z == (sqrt(3)*I - 1)/2, z == (-sqrt(3)*I - 1)/2, z == 1], [1, 1,
3])
sage: E.roots(z, multiplicities=True)
[((sqrt(3)*I - 1)/2, 1), ((-sqrt(3)*I - 1)/2, 1), (1, 3)]

Apparently the "multiplicities" parameter is also available in the
"solve" function:
sage: solve(E==0,multiplicities=True)
([z == (sqrt(3)*I - 1)/2, z == (-sqrt(3)*I - 1)/2, z == 1], [1, 1,
3])

I hope the multiplicities 1, 1 and 3 are correct (didn't think about
it, but it seems a bit odd to me).

Unfortunately that option seems to be not documented in the "solve"
function. But, if you want to see the documentation, do
sage: solve?

Best regards,
Simon

simon...@uni-jena.de

unread,
Jun 5, 2009, 2:23:39 PM6/5/09
to sage-support
Hi Michael,

I am sorry for my previous reply. I think I missed one word in your
question:

On 5 Jun., 18:26, Michael Friedman <ois3...@gmail.com> wrote:
> I'm pretty new to Sage, so I'm sorry in advance for the trivial
> question.
> I have a set of (non-linear) equations, and I need to find the multiplicity
^^^

Unfortunately it seems that the multiplicities option of the "solve"
function is not available for (simultaneous solutions of) sets of
equations:
sage: E=[(z^3-1)^3,(z^4-1)^3]
sage: solve(E,z,multiplicities=True)
[[z == 1]]

I hope other people know a better answer to your question.

Best regards,
Simon

Marshall Hampton

unread,
Jun 5, 2009, 3:07:25 PM6/5/09
to sage-support
That's pretty disturbing because those complex roots should have
multiplicity 3.

Is this a known bug?

-Marshall Hampton

simon...@uni-jena.de

unread,
Jun 5, 2009, 3:20:26 PM6/5/09
to sage-support
Dear Marshall

On 5 Jun., 21:07, Marshall Hampton <hampto...@gmail.com> wrote:
> That's pretty disturbing because those complex roots should have
> multiplicity 3.

So, I was right that the multiplicities where a bit odd... :)

> Is this a known bug?

I searched in trac. There used to be two open tickets mentioning
multiplicit*, but they do not seem related with the present problem.
So, I opened #6228.

I am afraid that symbolics isn't my field of expertise at all, so, I
hope other people can provide a patch.

Cheers,
Simon

simon...@uni-jena.de

unread,
Jun 5, 2009, 3:32:01 PM6/5/09
to sage-support
Hi!

I should add that the bug occurs for sage 4.0.
Is it still there in 4.0.1?

It seems that the problem is in maxima. Looking at the code, solve
does the following:
sage: E=(z^3-1)^3
sage: e = E==0
sage: m=e._maxima_()
sage: m.solve(z).str()
'[z=(sqrt(3)*%i-1)/2,z=-(sqrt(3)*%i+1)/2,z=1]'
sage: P.get('multiplicities')
'[1,1,3]'

So, there is where the wrong answer comes from. Note that the
multiplicities are fine when solving (z^4-1)^3.

Cheers,
Simon

simon...@uni-jena.de

unread,
Jun 5, 2009, 3:37:11 PM6/5/09
to sage-support
Oops.

On 5 Jun., 21:32, simon.k...@uni-jena.de wrote:
>   sage: E=(z^3-1)^3
>   sage: e = E==0
>   sage: m=e._maxima_()
>   sage: m.solve(z).str()
>   '[z=(sqrt(3)*%i-1)/2,z=-(sqrt(3)*%i+1)/2,z=1]'

Here I forgot to copy-and-paste the line
sage: P = m.parent()

>   sage: P.get('multiplicities')
>   '[1,1,3]'

Sorry, it seems that I am a bit distracted today.

Marshall Hampton

unread,
Jun 5, 2009, 7:21:22 PM6/5/09
to sage-support
Its a puzzling pattern as to which multiplicities are incorrect:

sage: z = var('z')
sage: f5 = (z^5-1)^2
sage: f5.roots()

[(e^(2/5*I*pi), 2),
(e^(4/5*I*pi), 2),
(e^(-4/5*I*pi), 1),
(e^(-2/5*I*pi), 1),
(1, 2)]

Odd, very odd. I guess one of us should write about this on the
maxima list.

-Marshall

Robert Dodier

unread,
Jun 5, 2009, 11:45:22 PM6/5/09
to sage-support
Marshall Hampton wrote:

> sage: z = var('z')
> sage: f5 = (z^5-1)^2
> sage: f5.roots()
>
> [(e^(2/5*I*pi), 2),
> (e^(4/5*I*pi), 2),
> (e^(-4/5*I*pi), 1),
> (e^(-2/5*I*pi), 1),
> (1, 2)]
>
> Odd, very odd. I guess one of us should write about this on the
> maxima list.

CVS log claims this bug was fixed recently (between 5.17 & 5.18).
Here's what I get with Maxima from CVS (5.18+).

(%i2) solve ((z^5 - 1)^2 = 0, z);
(%o2) [z = %e^(2*%i*%pi/5),z = %e^(4*%i*%pi/5),
z = %e^-(4*%i*%pi/5),z = %e^-(2*%i*%pi/5),z = 1]
(%i3) multiplicities;
(%o3) [2,2,2,2,2]

Another example which was cited:

(%i5) solve ((z^3 - 1)^3 = 0, z);
(%o5) [z = (sqrt(3)*%i-1)/2,z = -(sqrt(3)*%i+1)/2,z = 1]
(%i6) multiplicities;
(%o6) [3,3,3]

FWIW

Robert Dodier

simon...@uni-jena.de

unread,
Jun 6, 2009, 3:22:09 AM6/6/09
to sage-support
Hi!

On 6 Jun., 05:45, Robert Dodier <robert.dod...@gmail.com> wrote:
> CVS log claims this bug was fixed recently (between 5.17 & 5.18).
> Here's what I get with Maxima from CVS (5.18+).
>
> ...

Very good! So, ticket #6228 can be closed when the new maxima version
is in Sage.

But I think we should now come back to the original poster's question:
- Can Sage provide the multiplicities for the solutions of a *set* of
nonlinear equations?

Can it?
At least, "multiplicities=True" seems to have no effect in "solve":
sage: solve((x^2-1)^3==0, x, multiplicities=True)
([x == -1, x == 1], [3, 3])
sage: solve(((x^2-1)^3==0,(x^2-1)^3==0), x, multiplicities=True)
[[x == 1], [x == -1]]

This time, it is all Sage's fault, because maxima gives the right
answer:
sage: maxima.eval('solve(((z^2-1)^3,(z^2-1)^3),z)')
'[z=-1,z=1]'
sage: maxima.eval('multiplicities')
'[3,3]'

Hence, it is not the same as ticket #6228.
Therefore I opened a new one, namely http://trac.sagemath.org/sage_trac/ticket/6231

Cheers,
Simon

John Cremona

unread,
Jun 6, 2009, 6:34:51 AM6/6/09
to sage-support
Can the original poster provide a (simple) example of the kind of set
of equations he wants to solve? For example, are they polynomials in
several variables, or more exotic? In the case of polynomial
equations it is more likely that (perhaps via Singular) the
multiplicities can be obtained.

John Cremona

Michael Friedman

unread,
Jun 6, 2009, 8:12:59 AM6/6/09
to sage-support
Hi all

thanks for the answers. Here is simple example. It's in fact
intersection of two
projective curves:
a cuspidal cubic curve y^2*z-x^3=0 and its polar w.r.t. (2:1:1) :
2*y*z + y^2 - 2*3*x^2.
when substituting z=1 i used:
solve([y^2-x^3==0, 2*y +y^2 -2*3*x^2==0], x, y).

The general case will be also intersection of two homogenous
polynomials of degrees n,n-1 with
three variables.

Thanks
Michael
Reply all
Reply to author
Forward
0 new messages