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

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

""" 

Coercion Maps Between Hyperbolic Plane Models 

 

This module implements the coercion maps between different hyperbolic 

plane models. 

 

AUTHORS: 

 

- Travis Scrimshaw (2014): initial version 

""" 

 

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

# Copyright (C) 2014 Travis Scrimshaw <tscrim at ucdavis.edu> 

# 

# 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.symbolic.all import I 

from sage.matrix.constructor import matrix 

from sage.modules.free_module_element import vector 

from sage.rings.integer import Integer 

from sage.rings.infinity import infinity 

from sage.functions.other import real, imag, sqrt 

from sage.misc.lazy_import import lazy_import 

lazy_import('sage.misc.misc', 'attrcall') 

 

class HyperbolicModelCoercion(Morphism): 

""" 

Abstract base class for morphisms between the hyperbolic models. 

""" 

def _repr_type(self): 

""" 

Return the type of morphism. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = UHP.coerce_map_from(PD) 

sage: phi._repr_type() 

'Coercion Isometry' 

""" 

return "Coercion Isometry" 

 

def _call_(self, x): 

""" 

Return the image of ``x`` under ``self``. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: PD = HyperbolicPlane().PD() 

sage: HM = HyperbolicPlane().HM() 

sage: phi = UHP.coerce_map_from(PD) 

sage: phi(PD.get_point(0.5+0.5*I)) 

Point in UHP 2.00000000000000 + 1.00000000000000*I 

sage: psi = HM.coerce_map_from(UHP) 

sage: psi(UHP.get_point(I)) 

Point in HM (0, 0, 1) 

 

It is an error to try to convert a boundary point to a model 

that doesn't support boundary points:: 

 

sage: psi(UHP.get_point(infinity)) 

Traceback (most recent call last): 

... 

NotImplementedError: boundary points are not implemented for the Hyperboloid Model 

 

It is an error to try to convert a boundary point to a model 

that doesn't support boundary points:: 

 

sage: psi(UHP(infinity)) 

Traceback (most recent call last): 

... 

NotImplementedError: boundary points are not implemented for the Hyperboloid Model 

""" 

C = self.codomain() 

if not C.is_bounded() and self.domain().is_bounded() and x.is_boundary(): 

msg = u"boundary points are not implemented for the {}" 

raise NotImplementedError(msg.format(C.name())) 

 

y = self.image_coordinates(x.coordinates()) 

if self.domain().is_bounded(): 

bdry = x.is_boundary() 

else: 

bdry = C.boundary_point_in_model(y) 

 

return C.element_class(C, y, bdry, check=False, **x.graphics_options()) 

 

def convert_geodesic(self, x): 

""" 

Convert the geodesic ``x`` of the domain into a geodesic of 

the codomain. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = UHP.coerce_map_from(PD) 

sage: phi.convert_geodesic(PD.get_geodesic(0.5+0.5*I, -I)) 

Geodesic in UHP from 2.00000000000000 + 1.00000000000000*I to 0 

""" 

return self.codomain().get_geodesic(self(x.start()), self(x.end()), 

**x.graphics_options()) 

 

def convert_isometry(self, x): 

""" 

Convert the hyperbolic isometry ``x`` of the domain into an 

isometry of the codomain. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: HM = HyperbolicPlane().HM() 

sage: phi = HM.coerce_map_from(UHP) 

sage: I2 = UHP.get_isometry(identity_matrix(2)) 

sage: phi.convert_isometry(I2) 

Isometry in HM 

[1 0 0] 

[0 1 0] 

[0 0 1] 

""" 

C = self.codomain() 

return C._Isometry(C, self.image_isometry_matrix(x._matrix), check=False) 

 

def __invert__(self): 

""" 

Return the inverse coercion of ``self``. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = UHP.coerce_map_from(PD) 

sage: ~phi 

Coercion Isometry morphism: 

From: Hyperbolic plane in the Upper Half Plane Model 

To: Hyperbolic plane in the Poincare Disk Model 

""" 

return self.domain().coerce_map_from(self.codomain()) 

 

############ 

# From UHP # 

############ 

 

class CoercionUHPtoPD(HyperbolicModelCoercion): 

""" 

Coercion from the UHP to PD model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = PD.coerce_map_from(UHP) 

sage: phi.image_coordinates(I) 

0 

""" 

if x == infinity: 

return I 

return (x - I) / (Integer(1) - I*x) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = PD.coerce_map_from(UHP) 

sage: phi.image_isometry_matrix(identity_matrix(2)) 

[1 0] 

[0 1] 

""" 

if x.det() < 0: 

# x = I * x 

return matrix([[1,-I],[-I,1]]) * x * matrix([[1,I],[I,1]]).conjugate()/Integer(2) 

return matrix([[1,-I],[-I,1]]) * x * matrix([[1,I],[I,1]])/Integer(2) 

 

class CoercionUHPtoKM(HyperbolicModelCoercion): 

""" 

Coercion from the UHP to KM model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: KM = HyperbolicPlane().KM() 

sage: phi = KM.coerce_map_from(UHP) 

sage: phi.image_coordinates(3 + I) 

(6/11, 9/11) 

""" 

if x == infinity: 

return (0, 1) 

return ((2*real(x))/(real(x)**2 + imag(x)**2 + 1), 

(real(x)**2 + imag(x)**2 - 1)/(real(x)**2 + imag(x)**2 + 1)) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: KM = HyperbolicPlane().KM() 

sage: phi = KM.coerce_map_from(UHP) 

sage: phi.image_isometry_matrix(identity_matrix(2)) 

[1 0 0] 

[0 1 0] 

[0 0 1] 

""" 

return SL2R_to_SO21(x) 

 

class CoercionUHPtoHM(HyperbolicModelCoercion): 

""" 

Coercion from the UHP to HM model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: HM = HyperbolicPlane().HM() 

sage: phi = HM.coerce_map_from(UHP) 

sage: phi.image_coordinates(3 + I) 

(3, 9/2, 11/2) 

""" 

return vector((real(x)/imag(x), 

(real(x)**2 + imag(x)**2 - 1)/(2*imag(x)), 

(real(x)**2 + imag(x)**2 + 1)/(2*imag(x)))) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: UHP = HyperbolicPlane().UHP() 

sage: HM = HyperbolicPlane().HM() 

sage: phi = HM.coerce_map_from(UHP) 

sage: phi.image_isometry_matrix(identity_matrix(2)) 

[1 0 0] 

[0 1 0] 

[0 0 1] 

""" 

return SL2R_to_SO21(x) 

 

########### 

# From PD # 

########### 

 

class CoercionPDtoUHP(HyperbolicModelCoercion): 

""" 

Coercion from the PD to UHP model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: PD = HyperbolicPlane().PD() 

sage: UHP = HyperbolicPlane().UHP() 

sage: phi = UHP.coerce_map_from(PD) 

sage: phi.image_coordinates(0.5+0.5*I) 

2.00000000000000 + 1.00000000000000*I 

sage: phi.image_coordinates(0) 

I 

sage: phi.image_coordinates(I) 

+Infinity 

sage: phi.image_coordinates(-I) 

0 

""" 

if x == I: 

return infinity 

return (x + I)/(Integer(1) + I*x) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES: 

 

We check that orientation-reversing isometries behave as they 

should:: 

 

sage: PD = HyperbolicPlane().PD() 

sage: UHP = HyperbolicPlane().UHP() 

sage: phi = UHP.coerce_map_from(PD) 

sage: phi.image_isometry_matrix(matrix([[0,I],[I,0]])) 

[-1 0] 

[ 0 -1] 

""" 

from sage.geometry.hyperbolic_space.hyperbolic_isometry import HyperbolicIsometryPD 

if not HyperbolicIsometryPD._orientation_preserving(x): 

return matrix([[1,I],[I,1]]) * x * matrix([[1,-I],[-I,1]]).conjugate() / Integer(2) 

return matrix([[1,I],[I,1]]) * x * matrix([[1,-I],[-I,1]]) / Integer(2) 

 

class CoercionPDtoKM(HyperbolicModelCoercion): 

""" 

Coercion from the PD to KM model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: PD = HyperbolicPlane().PD() 

sage: KM = HyperbolicPlane().KM() 

sage: phi = KM.coerce_map_from(PD) 

sage: phi.image_coordinates(0.5+0.5*I) 

(0.666666666666667, 0.666666666666667) 

""" 

return (2*real(x)/(Integer(1) + real(x)**2 + imag(x)**2), 

2*imag(x)/(Integer(1) + real(x)**2 + imag(x)**2)) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: PD = HyperbolicPlane().PD() 

sage: KM = HyperbolicPlane().KM() 

sage: phi = KM.coerce_map_from(PD) 

sage: phi.image_isometry_matrix(matrix([[0,I],[I,0]])) 

[-1 0 0] 

[ 0 1 0] 

[ 0 0 -1] 

""" 

return SL2R_to_SO21(matrix(2, [1, I, I, 1]) * x * 

matrix(2, [1, -I, -I, 1]) / Integer(2)) 

 

 

class CoercionPDtoHM(HyperbolicModelCoercion): 

""" 

Coercion from the PD to HM model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: PD = HyperbolicPlane().PD() 

sage: HM = HyperbolicPlane().HM() 

sage: phi = HM.coerce_map_from(PD) 

sage: phi.image_coordinates(0.5+0.5*I) 

(2.00000000000000, 2.00000000000000, 3.00000000000000) 

""" 

return vector((2*real(x)/(1 - real(x)**2 - imag(x)**2), 

2*imag(x)/(1 - real(x)**2 - imag(x)**2), 

(real(x)**2 + imag(x)**2 + 1) / 

(1 - real(x)**2 - imag(x)**2))) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: PD = HyperbolicPlane().PD() 

sage: HM = HyperbolicPlane().HM() 

sage: phi = HM.coerce_map_from(PD) 

sage: phi.image_isometry_matrix(matrix([[0,I],[I,0]])) 

[-1 0 0] 

[ 0 1 0] 

[ 0 0 -1] 

""" 

return SL2R_to_SO21(matrix(2, [1, I, I, 1]) * x * 

matrix(2, [1, -I, -I, 1]) / Integer(2)) 

 

########### 

# From KM # 

########### 

 

 

class CoercionKMtoUHP(HyperbolicModelCoercion): 

""" 

Coercion from the KM to UHP model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: KM = HyperbolicPlane().KM() 

sage: UHP = HyperbolicPlane().UHP() 

sage: phi = UHP.coerce_map_from(KM) 

sage: phi.image_coordinates((0, 0)) 

I 

sage: phi.image_coordinates((0, 1)) 

+Infinity 

""" 

if tuple(x) == (0, 1): 

return infinity 

return (-x[0]/(x[1] - 1) 

+ I*(-(sqrt(-x[0]**2 - x[1]**2 + 1) - x[0]**2 - x[1]**2 + 1) 

/ ((x[1] - 1)*sqrt(-x[0]**2 - x[1]**2 + 1) + x[1] - 1))) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: KM = HyperbolicPlane().KM() 

sage: UHP = HyperbolicPlane().UHP() 

sage: phi = UHP.coerce_map_from(KM) 

sage: m = matrix([[5/3,0,4/3], [0,1,0], [4/3,0,5/3]]) 

sage: phi.image_isometry_matrix(m) 

[2*sqrt(1/3) sqrt(1/3)] 

[ sqrt(1/3) 2*sqrt(1/3)] 

""" 

return SO21_to_SL2R(x) 

 

class CoercionKMtoPD(HyperbolicModelCoercion): 

""" 

Coercion from the KM to PD model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: KM = HyperbolicPlane().KM() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = PD.coerce_map_from(KM) 

sage: phi.image_coordinates((0, 0)) 

0 

""" 

return (x[0]/(1 + (1 - x[0]**2 - x[1]**2).sqrt()) 

+ I*x[1]/(1 + (1 - x[0]**2 - x[1]**2).sqrt())) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: KM = HyperbolicPlane().KM() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = PD.coerce_map_from(KM) 

sage: m = matrix([[5/3,0,4/3], [0,1,0], [4/3,0,5/3]]) 

sage: phi.image_isometry_matrix(m) 

[2*sqrt(1/3) sqrt(1/3)] 

[ sqrt(1/3) 2*sqrt(1/3)] 

""" 

return (matrix(2,[1,-I,-I,1]) * SO21_to_SL2R(x) * 

matrix(2,[1,I,I,1])/Integer(2)) 

 

class CoercionKMtoHM(HyperbolicModelCoercion): 

""" 

Coercion from the KM to HM model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: KM = HyperbolicPlane().KM() 

sage: HM = HyperbolicPlane().HM() 

sage: phi = HM.coerce_map_from(KM) 

sage: phi.image_coordinates((0, 0)) 

(0, 0, 1) 

""" 

return (vector((2*x[0], 2*x[1], 1 + x[0]**2 + x[1]**2)) 

/ (1 - x[0]**2 - x[1]**2)) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: KM = HyperbolicPlane().KM() 

sage: HM = HyperbolicPlane().HM() 

sage: phi = HM.coerce_map_from(KM) 

sage: m = matrix([[5/3,0,4/3], [0,1,0], [4/3,0,5/3]]) 

sage: phi.image_isometry_matrix(m) 

[5/3 0 4/3] 

[ 0 1 0] 

[4/3 0 5/3] 

""" 

return x 

 

########### 

# From HM # 

########### 

 

class CoercionHMtoUHP(HyperbolicModelCoercion): 

""" 

Coercion from the HM to UHP model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: HM = HyperbolicPlane().HM() 

sage: UHP = HyperbolicPlane().UHP() 

sage: phi = UHP.coerce_map_from(HM) 

sage: phi.image_coordinates( vector((0,0,1)) ) 

I 

""" 

return -((x[0]*x[2] + x[0]) + I*(x[2] + 1)) / ((x[1] - 1)*x[2] 

- x[0]**2 - x[1]**2 + x[1] - 1) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: HM = HyperbolicPlane().HM() 

sage: UHP = HyperbolicPlane().UHP() 

sage: phi = UHP.coerce_map_from(HM) 

sage: phi.image_isometry_matrix(identity_matrix(3)) 

[1 0] 

[0 1] 

""" 

return SO21_to_SL2R(x) 

 

class CoercionHMtoPD(HyperbolicModelCoercion): 

""" 

Coercion from the HM to PD model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: HM = HyperbolicPlane().HM() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = PD.coerce_map_from(HM) 

sage: phi.image_coordinates( vector((0,0,1)) ) 

0 

""" 

return x[0]/(1 + x[2]) + I*(x[1]/(1 + x[2])) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: HM = HyperbolicPlane().HM() 

sage: PD = HyperbolicPlane().PD() 

sage: phi = PD.coerce_map_from(HM) 

sage: phi.image_isometry_matrix(identity_matrix(3)) 

[1 0] 

[0 1] 

""" 

return (matrix(2,[1,-I,-I,1]) * SO21_to_SL2R(x) * 

matrix(2,[1,I,I,1])/Integer(2)) 

 

class CoercionHMtoKM(HyperbolicModelCoercion): 

""" 

Coercion from the HM to KM model. 

""" 

def image_coordinates(self, x): 

""" 

Return the image of the coordinates of the hyperbolic point ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: HM = HyperbolicPlane().HM() 

sage: KM = HyperbolicPlane().KM() 

sage: phi = KM.coerce_map_from(HM) 

sage: phi.image_coordinates( vector((0,0,1)) ) 

(0, 0) 

""" 

return (x[0]/(1 + x[2]), x[1]/(1 + x[2])) 

 

def image_isometry_matrix(self, x): 

""" 

Return the image of the matrix of the hyperbolic isometry ``x`` 

under ``self``. 

 

EXAMPLES:: 

 

sage: HM = HyperbolicPlane().HM() 

sage: KM = HyperbolicPlane().KM() 

sage: phi = KM.coerce_map_from(HM) 

sage: phi.image_isometry_matrix(identity_matrix(3)) 

[1 0 0] 

[0 1 0] 

[0 0 1] 

""" 

return x 

 

##################################################################### 

## Helper functions 

 

def SL2R_to_SO21(A): 

r""" 

Given a matrix in `SL(2, \RR)` return its irreducible representation in 

`O(2,1)`. 

 

Note that this is not the only homomorphism, but it is the only one 

that works in the context of the implemented 2D hyperbolic geometry 

models. 

 

EXAMPLES:: 

 

sage: from sage.geometry.hyperbolic_space.hyperbolic_coercion import SL2R_to_SO21 

sage: A = SL2R_to_SO21(identity_matrix(2)) 

sage: J = matrix([[1,0,0],[0,1,0],[0,0,-1]]) #Lorentzian Gram matrix 

sage: norm(A.transpose()*J*A - J) < 10**-4 

True 

""" 

a, b, c, d = (A/A.det().sqrt()).list() 

 

# Kill ~0 imaginary parts 

B = matrix(3, map(real, 

[a*d + b*c, a*c - b*d, a*c + b*d, a*b - c*d, 

Integer(1)/Integer(2)*a**2 - Integer(1)/Integer(2)*b**2 - 

Integer(1)/Integer(2)*c**2 + Integer(1)/Integer(2)*d**2, 

Integer(1)/Integer(2)*a**2 + Integer(1)/Integer(2)*b**2 - 

Integer(1)/Integer(2)*c**2 - Integer(1)/Integer(2)*d**2, 

a*b + c*d, Integer(1)/Integer(2)*a**2 - 

Integer(1)/Integer(2)*b**2 + Integer(1)/Integer(2)*c**2 - 

Integer(1)/Integer(2)*d**2, Integer(1)/Integer(2)*a**2 + 

Integer(1)/Integer(2)*b**2 + Integer(1)/Integer(2)*c**2 + 

Integer(1)/Integer(2)*d**2])) 

 

#B = B.apply_map(attrcall('real')) 

if A.det() > 0: 

return B 

else: 

# Orientation-reversing isometries swap the nappes of 

# the lightcone. This fixes that issue. 

return -B 

 

def SO21_to_SL2R(M): 

r""" 

A homomorphism from `SO(2, 1)` to `SL(2, \RR)`. 

 

Note that this is not the only homomorphism, but it is the only one 

that works in the context of the implemented 2D hyperbolic geometry 

models. 

 

EXAMPLES:: 

 

sage: from sage.geometry.hyperbolic_space.hyperbolic_coercion import SO21_to_SL2R 

sage: (SO21_to_SL2R(identity_matrix(3)) - identity_matrix(2)).norm() < 10**-4 

True 

""" 

#################################################################### 

# SL(2,R) is the double cover of SO (2,1)^+, so we need to choose # 

# a lift. I have formulas for the absolute values of each entry # 

# a,b ,c,d of the lift matrix(2,[a,b,c,d]), but we need to choose # 

# one entry to be positive. I choose d for no particular reason, # 

# unless d = 0, then we choose c > 0. The basic strategy for this # 

# function is to find the linear map induced by the SO(2,1) # 

# element on the Lie algebra sl(2, R). This corresponds to the # 

# Adjoint action by a matrix A or -A in SL(2,R). To find which # 

# matrix let X,Y,Z be a basis for sl(2,R) and look at the images # 

# of X,Y,Z as well as the second and third standard basis vectors # 

# for 2x2 matrices (these are traceless, so are in the Lie # 

# algebra). These corresponds to AXA^-1 etc and give formulas # 

# for the entries of A. # 

#################################################################### 

(m_1,m_2,m_3,m_4,m_5,m_6,m_7,m_8,m_9) = M.list() 

d = sqrt(Integer(1)/Integer(2)*m_5 - Integer(1)/Integer(2)*m_6 - 

Integer(1)/Integer(2)*m_8 + Integer(1)/Integer(2)*m_9) 

if M.det() > 0: # EPSILON? 

det_sign = 1 

elif M.det() < 0: # EPSILON? 

det_sign = -1 

if d > 0: # EPSILON? 

c = (-Integer(1)/Integer(2)*m_4 + Integer(1)/Integer(2)*m_7)/d 

b = (-Integer(1)/Integer(2)*m_2 + Integer(1)/Integer(2)*m_3)/d 

ad = det_sign*1 + b*c # ad - bc = pm 1 

a = ad/d 

else: # d is 0, so we make c > 0 

c = sqrt(-Integer(1)/Integer(2)*m_5 - Integer(1)/Integer(2)*m_6 + 

Integer(1)/Integer(2)*m_8 + Integer(1)/Integer(2)*m_9) 

d = (-Integer(1)/Integer(2)*m_4 + Integer(1)/Integer(2)*m_7)/c 

# d = 0, so ad - bc = -bc = pm 1. 

b = - (det_sign*1)/c 

a = (Integer(1)/Integer(2)*m_4 + Integer(1)/Integer(2)*m_7)/b 

A = matrix(2, [a, b, c, d]) 

return A