# Help with subs

This minimal non-working example returns an output of 'z'. I want 'z^3'! Any help?

```
B = FunctionField(QQ,'z')
B.inject_variables()
g = z
g.subs(z=z^3)
```

Help with subs

This minimal non-working example returns an output of 'z'. I want 'z^3'! Any help?

```
B = FunctionField(QQ,'z')
B.inject_variables()
g = z
g.subs(z=z^3)
```

0

Edit: this is not an answer to the question, but together with the comments below, it may be useful, so I will leave it here.

```
sage: B = FunctionField(QQ,'z')
sage: B.inject_variables()
Defining z
sage: g = z
sage: g.subs(z=z^3)
z
sage: g(z) = z
sage: g.subs(z=z^3)
z |--> z^3
sage: g = z
sage: g.subs(z=z^3)
z^3
```

This also "works":

```
sage: B = FunctionField(QQ,'z')
sage: B.inject_variables()
Defining z
sage: h(z) = z
sage: g = z
sage: g.subs(z=z^3)
z^3
```

1

@eric_g: you're right, `h(z) = z`

completely destroys the old meaning of `z`

. I think I might prefer `g(z) = ...`

to raise an error unless I explicitly do `var('z')`

first, but that's not the default behavior.

The problem is similar to the one in this question, and amenable to similar answers.

@emmanuel-charpentier: it's too bad that `subs`

works with generators of a polynomial ring but not apparently with the named generator of a function field.

Please start posting anonymously - your entry will be published after you log in or create a new account.

Asked: ** 2023-03-03 15:24:48 +0200 **

Seen: **59 times**

Last updated: **Mar 04**

Substitution using Dictionary with Matrix as Value

Evaluating a symbolic expression for a Graph

subs() function gives KeyError when keyword is a list member

How can I get back an expression for free variables in solve function.

Sage subs() function include product condition

Direct substitution vs "subs" method

subs: why it accepts one form but not the other?

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

The minimal non-working example would probably skip the line defining

`g`

and just do`z.subs(z=z^3)`

.