Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

# -*- coding: utf-8 -*- 

r""" 

Function Field Morphisms 

 

AUTHORS: 

 

- William Stein (2010): initial version 

 

- Julian Rüth (2011-09-14, 2014-06-23, 2017-08-21): refactored class hierarchy; added 

derivation classes; morphisms to/from fraction fields 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: K.hom(1/x) 

Function Field endomorphism of Rational function field in x over Rational Field 

Defn: x |--> 1/x 

sage: L.<y> = K.extension(y^2 - x) 

sage: K.hom(y) 

Function Field morphism: 

From: Rational function field in x over Rational Field 

To: Function field in y defined by y^2 - x 

Defn: x |--> y 

sage: L.hom([y,x]) 

Function Field endomorphism of Function field in y defined by y^2 - x 

Defn: y |--> y 

x |--> x 

sage: L.hom([x,y]) 

Traceback (most recent call last): 

... 

ValueError: invalid morphism 

""" 

from __future__ import absolute_import 

#***************************************************************************** 

# Copyright (C) 2010 William Stein <wstein@gmail.com> 

# Copyright (C) 2011-2017 Julian Rüth <julian.rueth@gmail.com> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# as published by the Free Software Foundation; either version 2 of 

# the License, or (at your option) any later version. 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

 

from sage.categories.morphism import Morphism 

from sage.categories.map import Map 

from sage.rings.morphism import RingHomomorphism 

 

class FunctionFieldDerivation(Map): 

r""" 

A base class for derivations on function fields. 

 

A derivation on `R` is map `R\to R` with 

`D(\alpha+\beta)=D(\alpha)+D(\beta)` and `D(\alpha\beta)=\beta 

D(\alpha)+\alpha D(\beta)` for all `\alpha,\beta\in R`. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: d = K.derivation() 

sage: isinstance(d, sage.rings.function_field.maps.FunctionFieldDerivation) 

True 

 

""" 

def __init__(self, K): 

r""" 

Initialize a derivation from ``K`` to ``K``. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: d = K.derivation() # indirect doctest 

 

""" 

from .function_field import is_FunctionField 

if not is_FunctionField(K): 

raise ValueError("K must be a function field") 

self.__field = K 

from sage.categories.homset import Hom 

from sage.categories.sets_cat import Sets 

Map.__init__(self, Hom(K,K,Sets())) 

 

def _repr_type(self): 

r""" 

Return the type of this map (a derivation), for the purposes of printing out self. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: d = K.derivation() 

sage: d._repr_type() 

'Derivation' 

 

""" 

return "Derivation" 

 

def is_injective(self): 

r""" 

Return whether this derivation is injective. 

 

OUTPUT: 

 

Returns ``False`` since derivations are never injective. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: d = K.derivation() 

sage: d.is_injective() 

False 

 

""" 

return False 

 

class FunctionFieldDerivation_rational(FunctionFieldDerivation): 

""" 

A derivation on a rational function field. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: d = K.derivation() 

sage: isinstance(d, sage.rings.function_field.maps.FunctionFieldDerivation_rational) 

True 

""" 

def __init__(self, K, u): 

""" 

Initialize a derivation of ``K`` which sends the generator of ``K`` to 

``u``. 

 

INPUT: 

 

- ``K`` -- a rational function field 

 

- ``u`` -- an element of ``K``, the image of the generator of ``K`` under 

the derivation 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: d = K.derivation() # indirect doctest 

sage: type(d) 

<class 'sage.rings.function_field.maps.FunctionFieldDerivation_rational'> 

""" 

FunctionFieldDerivation.__init__(self, K) 

 

self._u = u 

 

def _call_(self, x): 

""" 

Compute the derivation of ``x``. 

 

INPUT: 

 

- ``x`` -- an element of the rational function field 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: d = K.derivation() 

sage: d(x) # indirect doctest 

1 

sage: d(x^3) 

3*x^2 

sage: d(1/x) 

-1/x^2 

""" 

f = x.numerator() 

g = x.denominator() 

 

numerator = f.derivative() * g - f * g.derivative() 

if numerator.is_zero(): 

return self.codomain().zero() 

else: 

return self._u * self.codomain()(numerator / g**2) 

 

class FunctionFieldDerivation_separable(FunctionFieldDerivation): 

""" 

The unique extension of the derivation ``d`` to ``L``. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x) 

sage: d = L.derivation() 

""" 

def __init__(self, L, d): 

""" 

Initialization. 

 

INPUT: 

 

- ``L`` -- a function field which is a separable extension of the domain of 

``d`` 

 

- ``d`` -- a derivation on the base function field of ``L`` 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(GF(3)) 

sage: R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x) 

sage: d = L.derivation() # indirect doctest 

sage: type(d) 

<class 'sage.rings.function_field.maps.FunctionFieldDerivation_separable'> 

""" 

FunctionFieldDerivation.__init__(self, L) 

 

f = self.domain().polynomial() 

if not f.gcd(f.derivative()).is_one(): 

raise ValueError("L must be a separable extension of its base field.") 

 

x = self.domain().gen() 

 

self._d = d 

self._gen_image = - f.map_coefficients(lambda c:d(c))(x) / f.derivative()(x) 

 

def _call_(self, x): 

r""" 

Evaluate the derivation on ``x``. 

 

INPUT: 

 

- ``x`` -- an element of the function field 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x) 

sage: d = L.derivation() 

sage: d(x) # indirect doctest 

1 

sage: d(y) 

(-1/2/-x)*y 

sage: d(y^2) 

1 

""" 

if x.is_zero(): 

return self.codomain().zero() 

 

x = x._x 

y = self.domain().gen() 

 

return x.map_coefficients(self._d) + x.derivative()(y) * self._gen_image 

 

def _repr_defn(self): 

""" 

Return the string representation of the map. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x) 

sage: L.derivation() # indirect doctest 

Derivation map: 

From: Function field in y defined by y^2 - x 

To: Function field in y defined by y^2 - x 

Defn: y |--> (-1/2/-x)*y 

 

sage: R.<z> = L[] 

sage: M.<z> = L.extension(z^2 - y) 

sage: M.derivation() 

Derivation map: 

From: Function field in z defined by z^2 - y 

To: Function field in z defined by z^2 - y 

Defn: y |--> (-1/2/-x)*y 

z |--> 1/4/x*z 

""" 

base = self._d._repr_defn() 

ret = '{} |--> {}'.format(self.domain().gen(), self._gen_image) 

if base: 

return base + '\n' + ret 

else: 

return ret 

 

class FunctionFieldIsomorphism(Morphism): 

r""" 

A base class for isomorphisms involving function fields. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space() 

sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldIsomorphism) 

True 

""" 

def _repr_type(self): 

""" 

Return the type of this map (an isomorphism), for the purposes of 

printing this map. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space() 

sage: f._repr_type() 

'Isomorphism' 

""" 

return "Isomorphism" 

 

def is_injective(self): 

""" 

Return True, since this isomorphism is injective. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space() 

sage: f.is_injective() 

True 

""" 

return True 

 

def is_surjective(self): 

""" 

Return True, since this isomorphism is surjective. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space() 

sage: f.is_surjective() 

True 

""" 

return True 

 

def _richcmp_(self, other, op): 

r""" 

Compare this map to ``other``. 

 

.. NOTE:: 

 

This implementation assumes that this isomorphism is defined by its 

domain and codomain. Isomorphisms for which this is not true must 

override this implementation. 

 

EXAMPLES:: 

 

sage: K = QQ['x'].fraction_field() 

sage: L = K.function_field() 

sage: f = K.coerce_map_from(L) 

 

sage: K = QQbar['x'].fraction_field() 

sage: L = K.function_field() 

sage: g = K.coerce_map_from(L) 

 

sage: f == g 

False 

sage: f == f 

True 

 

""" 

if type(self) != type(other): 

return NotImplemented 

 

from sage.structure.richcmp import richcmp 

return richcmp((self.domain(),self.codomain()), (other.domain(),other.codomain()), op) 

 

def __hash__(self): 

r""" 

Return a hash value of this map. 

 

This implementation assumes that this isomorphism is defined by its 

domain and codomain. Isomorphisms for which this is not true should 

override this implementation. 

 

EXAMPLES:: 

 

sage: K = QQ['x'].fraction_field() 

sage: L = K.function_field() 

sage: f = K.coerce_map_from(L) 

sage: hash(f) == hash(f) 

True 

 

""" 

return hash((self.domain(), self.codomain())) 

 

 

class MapVectorSpaceToFunctionField(FunctionFieldIsomorphism): 

r""" 

An isomorphism from a vector space to a function field. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space(); f 

Isomorphism morphism: 

From: Vector space of dimension 2 over Rational function field in x over Rational Field 

To: Function field in y defined by y^2 - x*y + 4*x^3 

""" 

def __init__(self, V, K): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space(); type(f) 

<class 'sage.rings.function_field.maps.MapVectorSpaceToFunctionField'> 

""" 

self._V = V 

self._K = K 

self._R = K.polynomial_ring() 

from sage.categories.homset import Hom 

FunctionFieldIsomorphism.__init__(self, Hom(V, K)) 

 

def _call_(self, v): 

""" 

Map ``v`` to the function field. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space() 

sage: f(x*V.0 + (1/x^3)*V.1) # indirect doctest 

1/x^3*y + x 

 

TESTS: 

 

Test that this map is a bijection for some random inputs:: 

 

sage: R.<z> = L[] 

sage: M.<z> = L.extension(z^3 - y - x) 

sage: for F in [K,L,M]: 

....: for base in F._intermediate_fields(K): 

....: V, f, t = F.vector_space(base) 

....: for i in range(100): 

....: a = F.random_element() 

....: assert(f(t(a)) == a) 

 

""" 

fields = self._K._intermediate_fields(self._V.base_field()) 

fields.pop() 

degrees = [k.degree() for k in fields] 

gens = [k.gen() for k in fields] 

 

# construct the basis composed of powers of the generators of all the 

# intermediate fields, i.e., 1, x, y, x*y, ... 

from sage.misc.misc_c import prod 

from itertools import product 

exponents = product(*[range(d) for d in degrees]) 

basis = [prod(g**e for g,e in zip(gens,es)) for es in exponents] 

 

# multiply the entries of v with the values in basis 

coefficients = self._V(v).list() 

ret = sum([c*b for (c,b) in zip(coefficients,basis)]) 

return self._K(ret) 

 

class MapFunctionFieldToVectorSpace(FunctionFieldIsomorphism): 

""" 

An isomorphism from a function field to a vector space. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space(); t 

Isomorphism morphism: 

From: Function field in y defined by y^2 - x*y + 4*x^3 

To: Vector space of dimension 2 over Rational function field in x over Rational Field 

""" 

def __init__(self, K, V): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space(); type(t) 

<class 'sage.rings.function_field.maps.MapFunctionFieldToVectorSpace'> 

""" 

self._V = V 

self._K = K 

self._zero = K.base_ring()(0) 

self._n = K.degree() 

from sage.categories.homset import Hom 

FunctionFieldIsomorphism.__init__(self, Hom(K, V)) 

 

def _call_(self, x): 

""" 

Map ``x`` to the vector space. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x*y + 4*x^3) 

sage: V, f, t = L.vector_space() 

sage: t(x + (1/x^3)*y) # indirect doctest 

(x, 1/x^3) 

 

TESTS: 

 

Test that this map is a bijection for some random inputs:: 

 

sage: R.<z> = L[] 

sage: M.<z> = L.extension(z^3 - y - x) 

sage: for F in [K,L,M]: 

....: for base in F._intermediate_fields(K): 

....: V, f, t = F.vector_space(base) 

....: for i in range(100): 

....: a = V.random_element() 

....: assert(t(f(a)) == a) 

 

""" 

ret = [x] 

fields = self._K._intermediate_fields(self._V.base_field()) 

fields.pop() 

from itertools import chain 

for k in fields: 

ret = chain.from_iterable([y.list() for y in ret]) 

ret = list(ret) 

assert all([t.parent() is self._V.base_field() for t in ret]) 

return self._V(ret) 

 

class FunctionFieldMorphism(RingHomomorphism): 

r""" 

Base class for morphisms between function fields. 

""" 

def __init__(self, parent, im_gen, base_morphism): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: f = K.hom(1/x); f 

Function Field endomorphism of Rational function field in x over Rational Field 

Defn: x |--> 1/x 

sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldMorphism) 

True 

""" 

RingHomomorphism.__init__(self, parent) 

 

self._im_gen = im_gen 

self._base_morphism = base_morphism 

 

def _repr_type(self): 

r""" 

Return the type of this map (a morphism of function fields), for the 

purposes of printing this map. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(GF(7)); R.<y> = K[] 

sage: L.<y> = K.extension(y^3 + 6*x^3 + x) 

sage: f = L.hom(y*2) 

sage: f._repr_type() 

'Function Field' 

 

""" 

return "Function Field" 

 

def _repr_defn(self): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(GF(7)); R.<y> = K[] 

sage: L.<y> = K.extension(y^3 + 6*x^3 + x) 

sage: f = L.hom(y*2) 

sage: f._repr_defn() 

'y |--> 2*y' 

""" 

a = '%s |--> %s'%(self.domain().gen(), self._im_gen) 

if self._base_morphism is not None: 

a += '\n' + self._base_morphism._repr_defn() 

return a 

 

class FunctionFieldMorphism_polymod(FunctionFieldMorphism): 

""" 

Morphism from a finite extension of a function field to a function field. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ); R.<y> = K[] 

sage: L.<y> = K.extension(y^2 - x) 

sage: f = L.hom(-y); f 

Function Field endomorphism of Function field in y defined by y^2 - x 

Defn: y |--> -y 

""" 

def __init__(self, parent, im_gen, base_morphism): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(GF(7)); R.<y> = K[] 

sage: L.<y> = K.extension(y^3 + 6*x^3 + x) 

sage: f = L.hom(y*2); f 

Function Field endomorphism of Function field in y defined by y^3 + 6*x^3 + x 

Defn: y |--> 2*y 

sage: type(f) 

<class 'sage.rings.function_field.maps.FunctionFieldMorphism_polymod'> 

sage: factor(L.polynomial()) 

y^3 + 6*x^3 + x 

sage: f(y).charpoly('y') 

y^3 + 6*x^3 + x 

""" 

FunctionFieldMorphism.__init__(self, parent, im_gen, base_morphism) 

# Verify that the morphism is valid: 

R = self.codomain()['X'] 

v = parent.domain().polynomial().list() 

if base_morphism is not None: 

v = [base_morphism(a) for a in v] 

f = R(v) 

if f(im_gen): 

raise ValueError("invalid morphism") 

 

def _call_(self, x): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(GF(7)); R.<y> = K[] 

sage: L.<y> = K.extension(y^3 + 6*x^3 + x); f = L.hom(y*2) 

sage: f(y/x + x^2/(x+1)) # indirect doctest 

2/x*y + x^2/(x + 1) 

sage: f(y) 

2*y 

""" 

v = x.list() 

if self._base_morphism is not None: 

v = [self._base_morphism(a) for a in v] 

f = v[0].parent()['X'](v) 

return f(self._im_gen) 

 

class FunctionFieldMorphism_rational(FunctionFieldMorphism): 

""" 

Morphism from a rational function field to a function field. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: f = K.hom(1/x); f 

Function Field endomorphism of Rational function field in x over Rational Field 

Defn: x |--> 1/x 

""" 

def __init__(self, parent, im_gen, base_morphism): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(GF(7)) 

sage: f = K.hom(1/x); f 

Function Field endomorphism of Rational function field in x over Finite Field of size 7 

Defn: x |--> 1/x 

sage: type(f) 

<class 'sage.rings.function_field.maps.FunctionFieldMorphism_rational'> 

""" 

FunctionFieldMorphism.__init__(self, parent, im_gen, base_morphism) 

 

def _call_(self, x): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(GF(7)) 

sage: f = K.hom(1/x); f 

Function Field endomorphism of Rational function field in x over Finite Field of size 7 

Defn: x |--> 1/x 

sage: f(x+1) # indirect doctest 

(x + 1)/x 

sage: 1/x + 1 

(x + 1)/x 

 

You can specify a morphism on the base ring:: 

 

sage: Qi = GaussianIntegers().fraction_field() 

sage: i = Qi.gen() 

sage: K.<x> = FunctionField(Qi) 

sage: phi1 = Qi.hom([CC.gen()]) 

sage: phi2 = Qi.hom([-CC.gen()]) 

sage: f = K.hom(CC.pi(),phi1) 

sage: f(1+i+x) 

4.14159265358979 + 1.00000000000000*I 

sage: g = K.hom(CC.pi(),phi2) 

sage: g(1+i+x) 

4.14159265358979 - 1.00000000000000*I 

""" 

a = x.element() 

if self._base_morphism is None: 

return a.subs({a.parent().gen():self._im_gen}) 

else: 

f = self._base_morphism 

num = a.numerator() 

den = a.denominator() 

R = self._im_gen.parent()['X'] 

num = R([f(c) for c in num.list()]) 

den = R([f(c) for c in den.list()]) 

return num.subs(self._im_gen) / den.subs(self._im_gen) 

 

class FunctionFieldConversionToConstantBaseField(Map): 

r""" 

Conversion map from the function field to its constant base field. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: QQ.convert_map_from(K) 

Conversion map: 

From: Rational function field in x over Rational Field 

To: Rational Field 

 

""" 

def __init__(self, parent): 

r""" 

TESTS:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: f = QQ.convert_map_from(K) 

sage: from sage.rings.function_field.maps import FunctionFieldConversionToConstantBaseField 

sage: isinstance(f, FunctionFieldConversionToConstantBaseField) 

True 

 

""" 

Map.__init__(self, parent) 

 

def _repr_type(self): 

r""" 

Return the type of this map (a conversion), for the purposes of printing out self. 

 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: QQ.convert_map_from(K) # indirect doctest 

Conversion map: 

From: Rational function field in x over Rational Field 

To: Rational Field 

 

""" 

return "Conversion" 

 

def _call_(self, x): 

""" 

EXAMPLES:: 

 

sage: K.<x> = FunctionField(QQ) 

sage: QQ(K(1)) # indirect doctest 

1 

 

""" 

return x.parent()._to_constant_base_field(x) 

 

class FunctionFieldToFractionField(FunctionFieldIsomorphism): 

r""" 

Isomorphism from rational function field to the isomorphic fraction 

field of a polynomial ring. 

 

EXAMPLES:: 

 

sage: K = QQ['x'].fraction_field() 

sage: L = K.function_field() 

sage: f = K.coerce_map_from(L); f 

Isomorphism morphism: 

From: Rational function field in x over Rational Field 

To: Fraction Field of Univariate Polynomial Ring in x over Rational Field 

 

.. SEEALSO:: 

 

:class:`FractionFieldToFunctionField` 

 

TESTS:: 

 

sage: from sage.rings.function_field.maps import FunctionFieldToFractionField 

sage: isinstance(f, FunctionFieldToFractionField) 

True 

sage: TestSuite(f).run() 

 

""" 

def _call_(self, f): 

r""" 

Return the value of this map at ``f``. 

 

EXAMPLES:: 

 

sage: K = QQ['x'].fraction_field() 

sage: L = K.function_field() 

sage: f = K.coerce_map_from(L) 

sage: f(~L.gen()) 

1/x 

 

""" 

return self.codomain()(f.numerator(), f.denominator()) 

 

def section(self): 

r""" 

Return the inverse map of this isomorphism. 

 

EXAMPLES:: 

 

sage: K = QQ['x'].fraction_field() 

sage: L = K.function_field() 

sage: f = K.coerce_map_from(L) 

sage: f.section() 

Isomorphism morphism: 

From: Fraction Field of Univariate Polynomial Ring in x over Rational Field 

To: Rational function field in x over Rational Field 

 

 

""" 

from sage.categories.all import Hom 

parent = Hom(self.codomain(), self.domain()) 

return parent.__make_element_class__(FractionFieldToFunctionField)(parent.domain(), parent.codomain()) 

 

class FractionFieldToFunctionField(FunctionFieldIsomorphism): 

r""" 

Isomorphism from a fraction field of a polynomial ring to the isomorphic 

function field. 

 

EXAMPLES:: 

 

sage: K = QQ['x'].fraction_field() 

sage: L = K.function_field() 

sage: f = L.coerce_map_from(K); f 

Isomorphism morphism: 

From: Fraction Field of Univariate Polynomial Ring in x over Rational Field 

To: Rational function field in x over Rational Field 

 

.. SEEALSO:: 

 

:class:`FunctionFieldToFractionField` 

 

TESTS:: 

 

sage: from sage.rings.function_field.maps import FractionFieldToFunctionField 

sage: isinstance(f, FractionFieldToFunctionField) 

True 

sage: TestSuite(f).run() 

 

""" 

def _call_(self, f): 

r""" 

Return the value of this morphism at ``f``. 

 

EXAMPLES:: 

 

sage: K = QQ['x'].fraction_field() 

sage: L = K.function_field() 

sage: f = L.coerce_map_from(K) 

sage: f(~K.gen()) 

1/x 

""" 

return self.codomain()._element_constructor_(f) 

 

def section(self): 

r""" 

Return the inverse map of this isomorphism. 

 

EXAMPLES:: 

 

sage: K = QQ['x'].fraction_field() 

sage: L = K.function_field() 

sage: f = L.coerce_map_from(K) 

sage: f.section() 

Isomorphism morphism: 

From: Rational function field in x over Rational Field 

To: Fraction Field of Univariate Polynomial Ring in x over Rational Field 

 

""" 

from sage.categories.all import Hom 

parent = Hom(self.codomain(), self.domain()) 

return parent.__make_element_class__(FunctionFieldToFractionField)(parent)