Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#6873 closed defect (duplicate)

*huge* bug in multivariate polynomial substitution

Reported by: was Owned by: malb
Priority: critical Milestone: sage-duplicate/invalid/wontfix
Component: commutative algebra Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by was)

Observe:

sage: R.<x,y> = QQ[]
sage: f = x + 2*y
sage: f.subs(x=y,y=x)
3*y
sage: var('x,y')
sage: f = x + 2*y
sage: f.subs(x=y,y=x)
2*x + y

This is really really bad. Notice in the first and second substitution that the semantics are completely wrong/inconsistent. The semantics should be as in the second one in both cases.

If you do f.subs in the first case above you'll see at the bottom code using I think libsingular that is really wrong. Probably the only way to do this right will be to construct a homomorphism and apply it (?), sort of like this:

sage: R.<x,y> = QQ[]
sage: f = x + 2*y
sage: R.hom([y,x])(f)
2*x + y

Change History (4)

comment:1 Changed 12 years ago by was

  • Description modified (diff)

comment:2 Changed 12 years ago by malb

This is a dupe of #6482.

I think the fix is to not check whether b in a=b is a monomial but whether it is constant. If it isn't a constant we should just fall back to fast_map.

comment:3 Changed 12 years ago by malb

  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of #6482

comment:4 Changed 12 years ago by mvngu

  • Milestone changed from sage-4.1.2 to sage-duplicate/invalid/wontfix
Note: See TracTickets for help on using tickets.