1 | initial version |

The issue here is that you want to make substitution not into `f`

but into each of its coefficients. Direct approach using `.map_coefficients()`

is given by @FrédéricC in the comments.

However, with the `i`

being the imaginary unit, you don't need define it over `RR`

but work in `CC`

where the imaginary unit is already defined as `I`

. So, you can go directly with

```
L.<a, b> = CC[]
f = a + I*b
f.map_coefficients(real)
```

Alternative general approach is to define all `a`

, `b`

, `i`

as polynomial variables and work in the quotient ring:

```
F.<I,A,B> = RR[]
K.<i,a,b> = F.quotient( [I^2 + 1] )
f = a + i*b
f.lift().subs({I:0})
```

Instead of `f.lift().subs({I:0})`

giving result in `F`

, you can use `f.lift().specialization({I:0})`

, which gives result in the polynomial ring of `A`

and `B`

only.

2 | No.2 Revision |

The issue here is that you want to make substitution not into `f`

but into each of its coefficients. Direct approach using `.map_coefficients()`

is given by @FrédéricC in the comments.

However, with the `i`

being the imaginary unit, ~~you don't ~~there is no need to define it over `RR`

~~ but ~~, since one can work in `CC`

where the imaginary unit is already defined as `I`

. So, you can go directly with

```
L.<a, b> = CC[]
f = a + I*b
f.map_coefficients(real)
```

Alternative general approach is to define all `a`

, `b`

, `i`

as polynomial variables and work in the quotient ring:

```
F.<I,A,B> = RR[]
K.<i,a,b> = F.quotient( [I^2 + 1] )
f = a + i*b
f.lift().subs({I:0})
```

Instead of `f.lift().subs({I:0})`

giving result in `F`

, you can use `f.lift().specialization({I:0})`

, which gives result in the polynomial ring of `A`

and `B`

only.

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.