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

862

863

864

865

866

r""" 

The Real Line and Open Intervals 

 

The class :class:`OpenInterval` implement open intervals as 1-dimensional 

differentiable manifolds over `\RR`. The derived class :class:`RealLine` is 

devoted to `\RR` itself, as the open interval `(-\infty, +\infty)`. 

 

AUTHORS: 

 

- Eric Gourgoulhon (2015): initial version 

- Travis Scrimshaw (2016): review tweaks 

 

REFERENCES: 

 

- [Lee2013]_ 

 

""" 

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

# Copyright (C) 2015 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr> 

# Copyright (C) 2015 Michal Bejger <bejger@camk.edu.pl> 

# 

# 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.misc.latex import latex 

from sage.rings.infinity import infinity, minus_infinity 

from sage.symbolic.ring import SR 

from sage.manifolds.differentiable.manifold import DifferentiableManifold 

from sage.manifolds.structure import RealDifferentialStructure 

 

class OpenInterval(DifferentiableManifold): 

r""" 

Open interval as a 1-dimensional differentiable manifold over `\RR`. 

 

INPUT: 

 

- ``lower`` -- lower bound of the interval (possibly ``-Infinity``) 

- ``upper`` -- upper bound of the interval (possibly ``+Infinity``) 

- ``ambient`` -- (default: ``None``) another open interval, 

to which the constructed interval is a subset of 

- ``name`` -- (default: ``None``) string; name (symbol) given to 

the interval; if ``None``, the name is constructed from ``lower`` 

and ``upper`` 

- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to denote the 

interval; if ``None``, the LaTeX symbol is constructed from ``lower`` 

and ``upper`` if ``name`` is ``None``, otherwise, it is set to ``name`` 

- ``coordinate`` -- (default: ``None``) string defining the symbol of the 

canonical coordinate set on the interval; if none is provided and 

``names`` is ``None``, the symbol 't' is used 

- ``names`` -- (default: ``None``) used only when ``coordinate`` is 

``None``: it must be a single-element tuple containing the canonical 

coordinate symbol (this is guaranteed if the shortcut ``<names>`` is 

used, see examples below) 

- ``start_index`` -- (default: 0) unique value of the index for vectors 

and forms on the interval manifold 

 

EXAMPLES: 

 

The interval `(0,\pi)`:: 

 

sage: I = OpenInterval(0, pi); I 

Real interval (0, pi) 

sage: latex(I) 

\left(0, \pi\right) 

 

``I`` is a 1-dimensional smooth manifold over `\RR`:: 

 

sage: I.category() 

Category of smooth manifolds over Real Field with 53 bits of precision 

sage: I.base_field() 

Real Field with 53 bits of precision 

sage: dim(I) 

1 

 

It is infinitely differentiable (smooth manifold):: 

 

sage: I.diff_degree() 

+Infinity 

 

The instance is unique (as long as the constructor arguments 

are the same):: 

 

sage: I is OpenInterval(0, pi) 

True 

sage: I is OpenInterval(0, pi, name='I') 

False 

 

The display of the interval can be customized:: 

 

sage: I # default display 

Real interval (0, pi) 

sage: latex(I) # default LaTeX display 

\left(0, \pi\right) 

sage: I1 = OpenInterval(0, pi, name='I'); I1 

Real interval I 

sage: latex(I1) 

I 

sage: I2 = OpenInterval(0, pi, name='I', latex_name=r'\mathcal{I}'); I2 

Real interval I 

sage: latex(I2) 

\mathcal{I} 

 

``I`` is endowed with a canonical chart:: 

 

sage: I.canonical_chart() 

Chart ((0, pi), (t,)) 

sage: I.canonical_chart() is I.default_chart() 

True 

sage: I.atlas() 

[Chart ((0, pi), (t,))] 

 

The canonical coordinate is returned by the method 

:meth:`canonical_coordinate`:: 

 

sage: I.canonical_coordinate() 

t 

sage: t = I.canonical_coordinate() 

sage: type(t) 

<type 'sage.symbolic.expression.Expression'> 

 

However, it can be obtained in the same step as the interval construction 

by means of the shortcut ``I.<names>``:: 

 

sage: I.<t> = OpenInterval(0, pi) 

sage: t 

t 

sage: type(t) 

<type 'sage.symbolic.expression.Expression'> 

 

The trick is performed by the Sage preparser:: 

 

sage: preparse("I.<t> = OpenInterval(0, pi)") 

"I = OpenInterval(Integer(0), pi, names=('t',)); (t,) = I._first_ngens(1)" 

 

In particular the shortcut can be used to set a canonical 

coordinate symbol different from ``'t'``:: 

 

sage: J.<x> = OpenInterval(0, pi) 

sage: J.canonical_chart() 

Chart ((0, pi), (x,)) 

sage: J.canonical_coordinate() 

x 

 

The LaTeX symbol of the canonical coordinate can be adjusted via 

the same syntax as a chart declaration (see 

:class:`~sage.manifolds.chart.RealChart`):: 

 

sage: J.<x> = OpenInterval(0, pi, coordinate=r'x:\xi') 

sage: latex(x) 

{\xi} 

sage: latex(J.canonical_chart()) 

\left(\left(0, \pi\right),({\xi})\right) 

 

An element of the open interval ``I``:: 

 

sage: x = I.an_element(); x 

Point on the Real interval (0, pi) 

sage: x.coord() # coordinates in the default chart = canonical chart 

(1/2*pi,) 

 

As for any manifold subset, a specific element of ``I`` can be created 

by providing a tuple containing its coordinate(s) in a given chart:: 

 

sage: x = I((2,)) # (2,) = tuple of coordinates in the canonical chart 

sage: x 

Point on the Real interval (0, pi) 

 

But for convenience, it can also be created directly from the coordinate:: 

 

sage: x = I(2); x 

Point on the Real interval (0, pi) 

sage: x.coord() 

(2,) 

sage: I(2) == I((2,)) 

True 

 

By default, the coordinates passed for the element ``x`` are those 

relative to the canonical chart:: 

 

sage: I(2) == I((2,), chart=I.canonical_chart()) 

True 

 

The lower and upper bounds of the interval ``I``:: 

 

sage: I.lower_bound() 

0 

sage: I.upper_bound() 

pi 

 

One of the endpoint can be infinite:: 

 

sage: J = OpenInterval(1, +oo); J 

Real interval (1, +Infinity) 

sage: J.an_element().coord() 

(2,) 

 

The construction of a subinterval can be performed via the argument 

``ambient`` of ``OpenInterval``:: 

 

sage: J = OpenInterval(0, 1, ambient=I); J 

Real interval (0, 1) 

 

However, it is recommended to use the method :meth:`open_interval` 

instead:: 

 

sage: J = I.open_interval(0, 1); J 

Real interval (0, 1) 

sage: J.is_subset(I) 

True 

sage: J.manifold() is I 

True 

 

A subinterval of a subinterval:: 

 

sage: K = J.open_interval(1/2, 1); K 

Real interval (1/2, 1) 

sage: K.is_subset(J) 

True 

sage: K.is_subset(I) 

True 

sage: K.manifold() is I 

True 

 

We have:: 

 

sage: I.list_of_subsets() 

[Real interval (0, 1), Real interval (0, pi), Real interval (1/2, 1)] 

sage: J.list_of_subsets() 

[Real interval (0, 1), Real interval (1/2, 1)] 

sage: K.list_of_subsets() 

[Real interval (1/2, 1)] 

 

As any open subset of a manifold, open subintervals are created in a 

category of subobjects of smooth manifolds:: 

 

sage: J.category() 

Join of Category of subobjects of sets and Category of smooth manifolds 

over Real Field with 53 bits of precision 

sage: K.category() 

Join of Category of subobjects of sets and Category of smooth manifolds 

over Real Field with 53 bits of precision 

 

On the contrary, ``I``, which has not been created as a subinterval, 

is in the category of smooth manifolds (see 

:class:`~sage.categories.manifolds.Manifolds`):: 

 

sage: I.category() 

Category of smooth manifolds over Real Field with 53 bits of precision 

 

and we have:: 

 

sage: J.category() is I.category().Subobjects() 

True 

 

All intervals are parents:: 

 

sage: x = J(1/2); x 

Point on the Real interval (0, pi) 

sage: x.parent() is J 

True 

sage: y = K(3/4); y 

Point on the Real interval (0, pi) 

sage: y.parent() is K 

True 

 

We have:: 

 

sage: x in I, x in J, x in K 

(True, True, False) 

sage: y in I, y in J, y in K 

(True, True, True) 

 

The canonical chart of subintervals is inherited from the canonical chart 

of the parent interval:: 

 

sage: XI = I.canonical_chart(); XI 

Chart ((0, pi), (t,)) 

sage: XI.coord_range() 

t: (0, pi) 

sage: XJ = J.canonical_chart(); XJ 

Chart ((0, 1), (t,)) 

sage: XJ.coord_range() 

t: (0, 1) 

sage: XK = K.canonical_chart(); XK 

Chart ((1/2, 1), (t,)) 

sage: XK.coord_range() 

t: (1/2, 1) 

 

""" 

def __init__(self, lower, upper, ambient=None, 

name=None, latex_name=None, 

coordinate=None, names=None, start_index=0): 

r""" 

Construct an open interval. 

 

TESTS:: 

 

sage: I = OpenInterval(-1,1); I 

Real interval (-1, 1) 

sage: TestSuite(I).run(skip='_test_elements') # pickling of elements fails 

sage: J = OpenInterval(-oo, 2); J 

Real interval (-Infinity, 2) 

sage: TestSuite(J).run(skip='_test_elements') # pickling of elements fails 

 

""" 

if latex_name is None: 

if name is None: 

latex_name = r"\left({}, {}\right)".format(latex(lower), latex(upper)) 

else: 

latex_name = name 

if name is None: 

name = "({}, {})".format(lower, upper) 

if ambient is None: 

ambient_manifold = None 

else: 

if not isinstance(ambient, OpenInterval): 

raise TypeError("the argument ambient must be an open interval") 

ambient_manifold = ambient.manifold() 

field = 'real' 

structure = RealDifferentialStructure() 

DifferentiableManifold.__init__(self, 1, name, field, structure, 

ambient=ambient_manifold, 

latex_name=latex_name, 

start_index=start_index) 

if ambient is None: 

if coordinate is None: 

if names is None: 

coordinate = 't' 

else: 

coordinate = names[0] 

self._canon_chart = self.chart(coordinates=coordinate) 

t = self._canon_chart[start_index] 

else: 

if lower < ambient.lower_bound(): 

raise ValueError("the lower bound is smaller than that of " 

+ "the containing interval") 

if upper > ambient.upper_bound(): 

raise ValueError("the upper bound is larger than that of " 

+ "the containing interval") 

self._supersets.update(ambient._supersets) 

for sd in ambient._supersets: 

sd._subsets.add(self) 

ambient._top_subsets.add(self) 

t = ambient.canonical_coordinate() 

if lower != minus_infinity: 

if upper != infinity: 

restrictions = [t > lower, t < upper] 

else: 

restrictions = t > lower 

else: 

if upper != infinity: 

restrictions = t < upper 

else: 

restrictions = None 

if ambient is None: 

if restrictions is not None: 

self._canon_chart.add_restrictions(restrictions) 

else: 

self._canon_chart = ambient.canonical_chart().restrict(self, 

restrictions=restrictions) 

self._lower = lower 

self._upper = upper 

 

def _repr_(self): 

r""" 

String representation of ``self``. 

 

TESTS:: 

 

sage: I = OpenInterval(-1, pi) 

sage: I 

Real interval (-1, pi) 

sage: I = OpenInterval(-1, +oo) 

sage: I 

Real interval (-1, +Infinity) 

sage: I = OpenInterval(-oo,0) 

sage: I 

Real interval (-Infinity, 0) 

 

""" 

return "Real interval " + self._name 

 

def _first_ngens(self, n): 

r""" 

Return the coordinate of the canonical chart. 

 

This is useful only for the use of Sage preparser. 

 

INPUT: 

 

- ``n`` -- the number of coordinates: must be 1 

 

TESTS:: 

 

sage: I = OpenInterval(-1, 1) 

sage: I._first_ngens(1) 

(t,) 

sage: I = OpenInterval(-1, 1, coordinate='x') 

sage: I._first_ngens(1) 

(x,) 

sage: I = OpenInterval(-1, 1, names=('x',)) 

sage: I._first_ngens(1) 

(x,) 

 

""" 

return self._canon_chart[:] 

 

def _element_constructor_(self, coords=None, chart=None, name=None, 

latex_name=None, check_coords=True): 

r""" 

Construct an element of ``self``. 

 

This is a redefinition of 

:meth:`sage.manifolds.differentiable.DifferentiableManifold._element_constructor_` 

to allow for construction from a number (considered as the canonical 

coordinate). 

 

INPUT: 

 

- ``coords`` -- (default: ``None``) either (i) the point coordinates 

(as a single-element tuple or list) in the chart ``chart``, (ii) the 

value of the point coordinate in the chart ``chart``, or (iii) 

another point in the interval 

- ``chart`` -- (default: ``None``) chart in which the coordinates are 

given; if none is provided, the coordinates are assumed to refer to 

the interval's default chart 

- ``name`` -- (default: ``None``) name given to the point 

- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the 

point; if none is provided, the LaTeX symbol is set to ``name`` 

- ``check_coords`` -- (default: ``True``) determines whether ``coords`` 

are valid coordinates for the chart ``chart``; for symbolic 

coordinates, it is recommended to set ``check_coords`` to ``False`` 

 

OUTPUT: 

 

- :class:`~sage.manifolds.point.TopologicalManifoldPoint` 

representing a point in the current interval 

 

EXAMPLES:: 

 

sage: I = OpenInterval(-1, 4) 

sage: I((2,)) # standard used of TopologicalManifoldSubset._element_constructor_ 

Point on the Real interval (-1, 4) 

sage: I(2) # specific use with a single coordinate 

Point on the Real interval (-1, 4) 

sage: I(2).coord() 

(2,) 

sage: I(2) == I((2,)) 

True 

sage: I(pi) 

Point on the Real interval (-1, 4) 

sage: I(pi).coord() 

(pi,) 

sage: I(8) 

Traceback (most recent call last): 

... 

ValueError: the coordinates (8,) are not valid on the Chart 

((-1, 4), (t,)) 

 

""" 

if coords in SR: 

coords = (coords,) 

return super(OpenInterval, self)._element_constructor_(coords=coords, 

chart=chart, name=name, latex_name=latex_name, 

check_coords=check_coords) 

 

def _Hom_(self, other, category=None): 

r""" 

Construct the set of curves in ``other`` with parameter in ``self``. 

 

INPUT: 

 

- ``other`` -- a differentiable manifold `M` 

- ``category`` -- (default: ``None``) not used here (to ensure 

compatibility with generic hook ``_Hom_``) 

 

OUTPUT: 

 

- the set of curves `I \to M`, where `I` is ``self`` 

 

.. SEEALSO:: 

 

:class:`~sage.manifolds.differentiable.manifold_homset.DifferentiableCurveSet` 

for more documentation. 

 

TESTS:: 

 

sage: I = OpenInterval(-1,1) 

sage: M = Manifold(3, 'M') 

sage: H = I._Hom_(M); H 

Set of Morphisms from Real interval (-1, 1) to 3-dimensional 

differentiable manifold M in Category of smooth manifolds over 

Real Field with 53 bits of precision 

sage: H is Hom(I, M) 

True 

 

""" 

from sage.manifolds.differentiable.manifold_homset import DifferentiableCurveSet 

return DifferentiableCurveSet(self, other) 

 

def canonical_chart(self): 

r""" 

Return the canonical chart defined on ``self``. 

 

OUTPUT: 

 

- :class:`~sage.manifolds.differentiable.chart.RealDiffChart` 

 

EXAMPLES: 

 

Canonical chart on the interval `(0, \pi)`:: 

 

sage: I = OpenInterval(0, pi) 

sage: I.canonical_chart() 

Chart ((0, pi), (t,)) 

sage: I.canonical_chart().coord_range() 

t: (0, pi) 

 

The symbol used for the coordinate of the canonical chart is that 

defined during the construction of the interval:: 

 

sage: I.<x> = OpenInterval(0, pi) 

sage: I.canonical_chart() 

Chart ((0, pi), (x,)) 

 

""" 

return self._canon_chart 

 

def canonical_coordinate(self): 

r""" 

Return the canonical coordinate defined on the interval. 

 

OUTPUT: 

 

- the symbolic variable representing the canonical coordinate 

 

EXAMPLES: 

 

Canonical coordinate on the interval `(0, \pi)`:: 

 

sage: I = OpenInterval(0, pi) 

sage: I.canonical_coordinate() 

t 

sage: type(I.canonical_coordinate()) 

<type 'sage.symbolic.expression.Expression'> 

sage: I.canonical_coordinate().is_real() 

True 

 

The canonical coordinate is the first (unique) coordinate of the 

canonical chart:: 

 

sage: I.canonical_coordinate() is I.canonical_chart()[0] 

True 

 

Its default symbol is `t`; but it can be customized during the 

creation of the interval:: 

 

sage: I = OpenInterval(0, pi, coordinate='x') 

sage: I.canonical_coordinate() 

x 

sage: I.<x> = OpenInterval(0, pi) 

sage: I.canonical_coordinate() 

x 

 

""" 

return self._canon_chart._xx[0] 

 

def lower_bound(self): 

r""" 

Return the lower bound (infimum) of the interval. 

 

EXAMPLES:: 

 

sage: I = OpenInterval(1/4, 3) 

sage: I.lower_bound() 

1/4 

sage: J = OpenInterval(-oo, 2) 

sage: J.lower_bound() 

-Infinity 

 

An alias of :meth:`lower_bound` is :meth:`inf`:: 

 

sage: I.inf() 

1/4 

sage: J.inf() 

-Infinity 

 

""" 

return self._lower 

 

inf = lower_bound 

 

def upper_bound(self): 

r""" 

Return the upper bound (supremum) of the interval. 

 

EXAMPLES:: 

 

sage: I = OpenInterval(1/4, 3) 

sage: I.upper_bound() 

3 

sage: J = OpenInterval(1, +oo) 

sage: J.upper_bound() 

+Infinity 

 

An alias of :meth:`upper_bound` is :meth:`sup`:: 

 

sage: I.sup() 

3 

sage: J.sup() 

+Infinity 

 

""" 

return self._upper 

 

sup = upper_bound 

 

def open_interval(self, lower, upper, name=None, latex_name=None): 

r""" 

Define an open subinterval of ``self``. 

 

INPUT: 

 

- ``lower`` -- lower bound of the subinterval (possibly ``-Infinity``) 

- ``upper`` -- upper bound of the subinterval (possibly ``+Infinity``) 

- ``name`` -- (default: ``None``) string; name (symbol) given to the 

subinterval; if ``None``, the name is constructed from ``lower`` and 

``upper`` 

- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to denote 

the subinterval; if ``None``, the LaTeX symbol is constructed from 

``lower`` and ``upper`` if ``name`` is ``None``, otherwise, it is set 

to ``name`` 

 

OUTPUT: 

 

- :class:`~sage.manifolds.differentiable.real_line.OpenInterval` 

representing the open interval (``lower``, ``upper``) 

 

EXAMPLES: 

 

The interval `(0, \pi)` as a subinterval of `(-4, 4)`:: 

 

sage: I = OpenInterval(-4, 4) 

sage: J = I.open_interval(0, pi); J 

Real interval (0, pi) 

sage: J.is_subset(I) 

True 

sage: I.list_of_subsets() 

[Real interval (-4, 4), Real interval (0, pi)] 

 

``J`` is considered as an open submanifold of ``I``:: 

 

sage: J.manifold() is I 

True 

 

The subinterval `(-4, 4)` is ``I`` itself:: 

 

sage: I.open_interval(-4, 4) is I 

True 

 

""" 

if lower == self._lower and upper == self._upper: 

return self 

# To cope with the unique representation framework, we have to 

# distinguish several cases, instead of performing a mere 

# return OpenInterval(lower, upper, ambient=self, name=name, 

# latex_name=latex_name) 

if name is None: 

if latex_name is None: 

return OpenInterval(lower, upper, ambient=self) 

return OpenInterval(lower, upper, ambient=self, 

latex_name=latex_name) 

if latex_name is None: 

return OpenInterval(lower, upper, ambient=self, name=name) 

return OpenInterval(lower, upper, ambient=self, name=name, 

latex_name=latex_name) 

 

 

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

 

class RealLine(OpenInterval): 

r""" 

Field of real numbers, as a differentiable manifold of dimension 1 (real 

line) with a canonical coordinate chart. 

 

INPUT: 

 

- ``name`` -- (default: ``'R'``) string; name (symbol) given to 

the real line 

- ``latex_name`` -- (default: ``r'\Bold{R}'``) string; LaTeX symbol to 

denote the real line 

- ``coordinate`` -- (default: ``None``) string defining the symbol of the 

canonical coordinate set on the real line; if none is provided and 

``names`` is ``None``, the symbol 't' is used 

- ``names`` -- (default: ``None``) used only when ``coordinate`` is 

``None``: it must be a single-element tuple containing the canonical 

coordinate symbol (this is guaranteed if the shortcut ``<names>`` is 

used, see examples below) 

- ``start_index`` -- (default: 0) unique value of the index for vectors 

and forms on the real line manifold 

 

EXAMPLES: 

 

Constructing the real line without any argument:: 

 

sage: R = RealLine() ; R 

Real number line R 

sage: latex(R) 

\Bold{R} 

 

``R`` is a 1-dimensional real smooth manifold:: 

 

sage: R.category() 

Category of smooth manifolds over Real Field with 53 bits of precision 

sage: isinstance(R, sage.manifolds.differentiable.manifold.DifferentiableManifold) 

True 

sage: dim(R) 

1 

 

It is endowed with a canonical chart:: 

 

sage: R.canonical_chart() 

Chart (R, (t,)) 

sage: R.canonical_chart() is R.default_chart() 

True 

sage: R.atlas() 

[Chart (R, (t,))] 

 

The instance is unique (as long as the constructor arguments are the 

same):: 

 

sage: R is RealLine() 

True 

sage: R is RealLine(latex_name='R') 

False 

 

The canonical coordinate is returned by the method 

:meth:`~sage.manifolds.differentiable.real_line.OpenInterval.canonical_coordinate`:: 

 

sage: R.canonical_coordinate() 

t 

sage: t = R.canonical_coordinate() 

sage: type(t) 

<type 'sage.symbolic.expression.Expression'> 

 

However, it can be obtained in the same step as the real line construction 

by means of the shortcut ``R.<names>``:: 

 

sage: R.<t> = RealLine() 

sage: t 

t 

sage: type(t) 

<type 'sage.symbolic.expression.Expression'> 

 

The trick is performed by Sage preparser:: 

 

sage: preparse("R.<t> = RealLine()") 

"R = RealLine(names=('t',)); (t,) = R._first_ngens(1)" 

 

In particular the shortcut is to be used to set a canonical 

coordinate symbol different from 't':: 

 

sage: R.<x> = RealLine() 

sage: R.canonical_chart() 

Chart (R, (x,)) 

sage: R.atlas() 

[Chart (R, (x,))] 

sage: R.canonical_coordinate() 

x 

 

The LaTeX symbol of the canonical coordinate can be adjusted via the same 

syntax as a chart declaration (see 

:class:`~sage.manifolds.chart.RealChart`):: 

 

sage: R.<x> = RealLine(coordinate=r'x:\xi') 

sage: latex(x) 

{\xi} 

sage: latex(R.canonical_chart()) 

\left(\Bold{R},({\xi})\right) 

 

The LaTeX symbol of the real line itself can also be customized:: 

 

sage: R.<x> = RealLine(latex_name=r'\mathbb{R}') 

sage: latex(R) 

\mathbb{R} 

 

Elements of the real line can be constructed directly from a number:: 

 

sage: p = R(2) ; p 

Point on the Real number line R 

sage: p.coord() 

(2,) 

sage: p = R(1.742) ; p 

Point on the Real number line R 

sage: p.coord() 

(1.74200000000000,) 

 

Symbolic variables can also be used:: 

 

sage: p = R(pi, name='pi') ; p 

Point pi on the Real number line R 

sage: p.coord() 

(pi,) 

sage: a = var('a') 

sage: p = R(a) ; p 

Point on the Real number line R 

sage: p.coord() 

(a,) 

 

The real line is considered as the open interval `(-\infty, +\infty)`:: 

 

sage: isinstance(R, sage.manifolds.differentiable.real_line.OpenInterval) 

True 

sage: R.lower_bound() 

-Infinity 

sage: R.upper_bound() 

+Infinity 

 

A real interval can be created from ``R`` means of the method 

:meth:`~sage.manifolds.differentiable.real_line.OpenInterval.open_interval`:: 

 

sage: I = R.open_interval(0, 1); I 

Real interval (0, 1) 

sage: I.manifold() 

Real number line R 

sage: R.list_of_subsets() 

[Real interval (0, 1), Real number line R] 

 

""" 

def __init__(self, name='R', latex_name=r'\Bold{R}', coordinate=None, 

names=None, start_index=0): 

r""" 

Construct the real line manifold. 

 

TESTS:: 

 

sage: R = RealLine() ; R 

Real number line R 

sage: R.category() 

Category of smooth manifolds over Real Field with 53 bits of precision 

sage: TestSuite(R).run(skip='_test_elements') # pickling of elements fails 

 

""" 

OpenInterval.__init__(self, minus_infinity, infinity, name=name, 

latex_name=latex_name, coordinate=coordinate, 

names=names, start_index=start_index) 

 

def _repr_(self): 

r""" 

String representation of ``self``. 

 

TESTS:: 

 

sage: R = RealLine() 

sage: R._repr_() 

'Real number line R' 

sage: R = RealLine(name='r') 

sage: R._repr_() 

'Real number line r' 

 

""" 

return "Real number line " + self._name