# Pullback of ideals

Hi. I have the the following question and I hope that somebody of you has a good idea for the implementation and an explanation of the error.

**Offset**:

A number field K (in general non Galois)

L the Galois closure of K

phi: K --> L an arbitrary embedding of K into L

I a fractional ideal in K and IL = phi(I)

**Question**:
How to compute the pullback of IL for (general) fractional ideals of K?

**My approach**:

Let V, W be two QQ vector spaces and f: V --> W a linear map (morphism). Let further V' and W' be subspaces of V and W.

The aim is to identify the subspace V' = f^(-1)(W') as the preimage of W' under f.

Let p: V x W' --> W be a linear map definied by (v,w')|--> f(v) - w' with

ker(p):={(v,w')in V x W'| f(v)-w' = 0_W} = {(v,w'): f(v) = w'}.

Such vectors v are the vectors in the preimage of W'.

```
def inverseImage(IL, K, phi):
ZK = K.maximal_order()
dK = K.degree()
BZK = ZK.basis()
M = Matrix(QQ, [ list(phi(b)) for b in BZK ])
BJ = IL.basis()
N = Matrix(QQ, [ list(b) for b in BJ ])
vs = M.stack(N).integer_kernel().basis()
BI = [ sum([ v[i]*BZK[i] for i in [0..(dK - 1)] ]) for v in vs ]
IK = ZK.fractional_ideal([num_IL/denom_IL, BI])
return IK
```

**EXAMPLE 1**:

```
sage: K = NumberField(x^6 - 2*x^5 - 6*x^3 + 151*x^2 + 76*x + 861, 'a')
sage: L.<b> = K.galois_closure()
sage: phi = K.embeddings(L)[1]
sage: I = K.fractional_ideal([129, x - 54])
sage: I_ = inverseImage(IL, K, phi)
sage: I_ == I
TRUE
```

**EXAMPLE 2 (and the first problem, loosing the denominator)**

```
sage: I = K.fractional_ideal([2/3])
sage: I
Fractional ideal (2/3)
sage: I_ = inverseImage(phi(I), K, phi)
sage: I_
Fractional ideal (2)
sage: I == I_
FALSE
```

**My improvement approach:**

```
...
num_IL = IL.numerator().gens()[0]
denom_IL = IL.denominator().gens()[0]
IK = ZK.fractional_ideal([num_IL/denom_IL, BI])
return IK
```

Now EXAMPLE 2 returns the corresponding fractional ideal I_ **BUT** with an incorrect ideal I_ in EXAMPLE 1.
Thanks for helping!