substitution problem

12 views
Skip to first unread message

Enrique Artal

unread,
5:47 AM (14 hours ago) 5:47 AM
to sage-support
I think that this code has been successful once:
R.<x, y> = QQ[]
T.<t> = QQ[]
sb = {x: t, y: t^2}
X = vector(R.gens())
X.subs(sb)

This one works:

R.<x, y, z> = QQ[]
T.<t, t0, t1> = QQ[]
F = (y * z - x^2)^2 - x^3 * z
sb = {x:t^2, y:t^3 + t^4, z:1}
X = vector(R.gens())
X.subs(sb)

But the result is (x^2, x^4 + x^3, 1)

What am I doing wrong

David Joyner

unread,
8:53 AM (11 hours ago) 8:53 AM
to sage-s...@googlegroups.com
Do you need the ring T?


R.<x, y, z, t> = QQ[]

sb = {x:t^2, y:t^3 + t^4, z:1}

X = vector([x,y,z])

X.subs(x=t^2, y=t^3 + t^4, z=1)

works for me.
 

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sage-support/3820340c-b09a-45bb-958b-f8403f094269n%40googlegroups.com.

Enrique Artal

unread,
11:14 AM (9 hours ago) 11:14 AM
to sage-support
Not really, but it may help. I do not see why it idoes not work.

Dima Pasechnik

unread,
12:47 PM (7 hours ago) 12:47 PM
to sage-s...@googlegroups.com
Do you want the result of subs to live in a different ring?
Then you should create a ring map and apply it.

Nils Bruin

unread,
4:44 PM (3 hours ago) 4:44 PM
to sage-support
If you look at the code, you'll see it's a one-liner:

        return self.parent()([a.subs(in_dict, **kwds) for a in self.list()])

So it does the substitution on the elements and then forces the result back into the parent, which is FreeModule(R,3). Your ring T has a conversion back into R because both are polynomial rings in 3 variables over QQ. If you change your codomain to `T.<t,t0,t1,t2>` you'll see an error that shows what's going on.

So the code is definitely doing what it is programmed to do. I think it's more designed to work with modules over the Symbolic ring, though. You could look into the revision history with "blame" to see if it ever did anything else. I suspect you recall it working according to your intent when used over SR (where it would work).

The problem with giving the result back that you probably intend is that `subs` would somehow have to figure out you want the answer to lie in `FreeModule(T,3)` and construct that parent.
Reply all
Reply to author
Forward
0 new messages