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

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

r""" 

Jordan Algebras 

 

AUTHORS: 

 

- Travis Scrimshaw (2014-04-02): initial version 

""" 

 

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

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

# 

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

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

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

 

from sage.structure.parent import Parent 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.structure.element import AlgebraElement 

from sage.categories.magmatic_algebras import MagmaticAlgebras 

from sage.misc.cachefunc import cached_method 

#from sage.misc.lazy_attribute import lazy_attribute 

from sage.rings.all import QQ 

from sage.structure.element import is_Matrix 

from sage.modules.free_module import FreeModule 

from sage.sets.family import Family 

 

class JordanAlgebra(Parent, UniqueRepresentation): 

r""" 

A Jordan algebra. 

 

A *Jordan algebra* is a magmatic algebra (over a commutative ring 

`R`) whose multiplication satisfies the following axioms: 

 

- `xy = yx`, and 

- `(xy)(xx) = x(y(xx))` (the Jordan identity). 

 

See [Ja1971]_, [Ch2012]_, and [McC1978]_, for example. 

 

These axioms imply that a Jordan algebra is power-associative and the 

following generalization of Jordan's identity holds [Al1947]_: 

`(x^m y) x^n = x^m (y x^n)` for all `m, n \in \ZZ_{>0}`. 

 

Let `A` be an associative algebra over a ring `R` in which `2` is 

invertible. We construct a Jordan algebra `A^+` with ground set `A` 

by defining the multiplication as 

 

.. MATH:: 

 

x \circ y = \frac{xy + yx}{2}. 

 

Often the multiplication is written as `x \circ y` to avoid confusion 

with the product in the associative algebra `A`. We note that if `A` is 

commutative then this reduces to the usual multiplication in `A`. 

 

Jordan algebras constructed in this fashion, or their subalgebras, 

are called *special*. All other Jordan algebras are called *exceptional*. 

 

Jordan algebras can also be constructed from a module `M` over `R` with 

a symmetric bilinear form `(\cdot, \cdot) : M \times M \to R`. 

We begin with the module `M^* = R \oplus M` and define multiplication 

in `M^*` by 

 

.. MATH:: 

 

(\alpha + x) \circ (\beta + y) = 

\underbrace{\alpha \beta + (x,y)}_{\in R} 

+ \underbrace{\beta x + \alpha y}_{\in M} 

 

where `\alpha, \beta \in R` and `x,y \in M`. 

 

INPUT: 

 

Can be either an associative algebra `A` or a symmetric bilinear 

form given as a matrix (possibly followed by, or preceded by, a base 

ring argument) 

 

EXAMPLES: 

 

We let the base algebra `A` be the free algebra on 3 generators:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F); J 

Jordan algebra of Free Algebra on 3 generators (x, y, z) over Rational Field 

sage: a,b,c = map(J, F.gens()) 

sage: a*b 

1/2*x*y + 1/2*y*x 

sage: b*a 

1/2*x*y + 1/2*y*x 

 

Jordan algebras are typically non-associative:: 

 

sage: (a*b)*c 

1/4*x*y*z + 1/4*y*x*z + 1/4*z*x*y + 1/4*z*y*x 

sage: a*(b*c) 

1/4*x*y*z + 1/4*x*z*y + 1/4*y*z*x + 1/4*z*y*x 

 

We check the Jordan identity:: 

 

sage: (a*b)*(a*a) == a*(b*(a*a)) 

True 

sage: x = a + c 

sage: y = b - 2*a 

sage: (x*y)*(x*x) == x*(y*(x*x)) 

True 

 

Next we construct a Jordan algebra from a symmetric bilinear form:: 

 

sage: m = matrix([[-2,3],[3,4]]) 

sage: J.<a,b,c> = JordanAlgebra(m); J 

Jordan algebra over Integer Ring given by the symmetric bilinear form: 

[-2 3] 

[ 3 4] 

sage: a 

1 + (0, 0) 

sage: b 

0 + (1, 0) 

sage: x = 3*a - 2*b + c; x 

3 + (-2, 1) 

 

We again show that Jordan algebras are usually non-associative:: 

 

sage: (x*b)*b 

-6 + (7, 0) 

sage: x*(b*b) 

-6 + (4, -2) 

 

We verify the Jordan identity:: 

 

sage: y = -a + 4*b - c 

sage: (x*y)*(x*x) == x*(y*(x*x)) 

True 

 

The base ring, while normally inferred from the matrix, can also 

be explicitly specified:: 

 

sage: J.<a,b,c> = JordanAlgebra(m, QQ); J 

Jordan algebra over Rational Field given by the symmetric bilinear form: 

[-2 3] 

[ 3 4] 

sage: J.<a,b,c> = JordanAlgebra(QQ, m); J # either order work 

Jordan algebra over Rational Field given by the symmetric bilinear form: 

[-2 3] 

[ 3 4] 

 

REFERENCES: 

 

- :wikipedia:`Jordan_algebra` 

 

- [Ja1971]_ 

 

- [Ch2012]_ 

 

- [McC1978]_ 

 

- [Al1947]_ 

""" 

@staticmethod 

def __classcall_private__(self, arg0, arg1=None, names=None): 

""" 

Choose the correct parent based upon input. 

 

TESTS: 

 

We check arguments with passing in an associative algebra:: 

 

sage: cat = Algebras(QQ).WithBasis().FiniteDimensional() 

sage: C = CombinatorialFreeModule(QQ, ['x','y','z'], category=cat) 

sage: J1 = JordanAlgebra(C, names=['a','b','c']) 

sage: J2.<a,b,c> = JordanAlgebra(C) 

sage: J1 is J2 

True 

 

We check with passing in a symmetric bilinear form:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J1 = JordanAlgebra(m) 

sage: J2 = JordanAlgebra(QQ, m) 

sage: J3 = JordanAlgebra(m, QQ) 

sage: J1 is J2 

False 

sage: J2 is J3 

True 

sage: J4 = JordanAlgebra(ZZ, m) 

sage: J1 is J4 

True 

sage: m = matrix(QQ, [[0,1],[1,1]]) 

sage: J1 = JordanAlgebra(m) 

sage: J1 is J2 

True 

""" 

if names is not None: 

if isinstance(names, str): 

names = names.split(',') 

names = tuple(names) 

 

if arg1 is None: 

if not is_Matrix(arg0): 

if arg0.base_ring().characteristic() == 2: 

raise ValueError("the base ring cannot have characteristic 2") 

return SpecialJordanAlgebra(arg0, names) 

arg0, arg1 = arg0.base_ring(), arg0 

elif is_Matrix(arg0): 

arg0, arg1 = arg1, arg0 

 

# arg0 is the base ring and arg1 is a matrix 

if not arg1.is_symmetric(): 

raise ValueError("the bilinear form is not symmetric") 

 

arg1 = arg1.change_ring(arg0) # This makes a copy 

arg1.set_immutable() 

return JordanAlgebraSymmetricBilinear(arg0, arg1, names=names) 

 

class SpecialJordanAlgebra(JordanAlgebra): 

r""" 

A (special) Jordan algebra `A^+` from an associative algebra `A`. 

""" 

def __init__(self, A, names=None): 

""" 

Initialize ``self``. 

 

TESTS:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: TestSuite(J).run() 

sage: J.category() 

Category of commutative unital algebras with basis over Rational Field 

""" 

R = A.base_ring() 

C = MagmaticAlgebras(R) 

if A not in C.Associative(): 

raise ValueError("A is not an associative algebra") 

 

self._A = A 

cat = C.Commutative() 

if A in C.Unital(): 

cat = cat.Unital() 

self._no_generic_basering_coercion = True 

# Remove the preceding line once trac #16492 is fixed 

# Removing this line will also break some of the input formats, 

# see trac #16054 

if A in C.WithBasis(): 

cat = cat.WithBasis() 

if A in C.FiniteDimensional(): 

cat = cat.FiniteDimensional() 

 

Parent.__init__(self, base=R, names=names, category=cat) 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: JordanAlgebra(F) 

Jordan algebra of Free Algebra on 3 generators (x, y, z) over Rational Field 

""" 

return "Jordan algebra of {}".format(self._A) 

 

def _element_constructor_(self, x): 

""" 

Construct an element of ``self`` from ``x``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: J(5) 

5 

sage: elt = J(x + 2*x*y); elt 

x + 2*x*y 

sage: elt.parent() is J 

True 

""" 

return self.element_class(self, self._A(x)) 

 

def _an_element_(self): 

""" 

Return an element of ``self``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: J.an_element() 

2 + 2*x + 3*y 

""" 

return self.element_class(self, self._A.an_element()) 

 

@cached_method 

def basis(self): 

""" 

Return the basis of ``self``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: J.basis() 

Lazy family (Term map(i))_{i in Free monoid on 3 generators (x, y, z)} 

""" 

B = self._A.basis() 

return Family(B.keys(), lambda x: self.element_class(self, B[x]), name="Term map") 

 

algebra_generators = basis 

 

# TODO: Keep this until we can better handle R.<...> shorthand 

def gens(self): 

""" 

Return the generators of ``self``. 

 

EXAMPLES:: 

 

sage: cat = Algebras(QQ).WithBasis().FiniteDimensional() 

sage: C = CombinatorialFreeModule(QQ, ['x','y','z'], category=cat) 

sage: J = JordanAlgebra(C) 

sage: J.gens() 

(B['x'], B['y'], B['z']) 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: J.gens() 

Traceback (most recent call last): 

... 

NotImplementedError: infinite set 

""" 

return tuple(self.algebra_generators()) 

 

@cached_method 

def zero(self): 

""" 

Return the element `0`. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: J.zero() 

0 

""" 

return self.element_class(self, self._A.zero()) 

 

@cached_method 

def one(self): 

""" 

Return the element `1` if it exists. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: J.one() 

1 

""" 

return self.element_class(self, self._A.one()) 

 

class Element(AlgebraElement): 

""" 

An element of a special Jordan algebra. 

""" 

def __init__(self, parent, x): 

""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: TestSuite(a + 2*b - c).run() 

""" 

self._x = x 

AlgebraElement.__init__(self, parent) 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: a + 2*b - c 

x + 2*y - z 

""" 

return repr(self._x) 

 

def _latex_(self): 

""" 

Return a latex representation of ``self``. 

 

EXAMPLES:: 

 

sage: F.<x0,x1,x2> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: latex(a + 2*b - c) 

x_{0} + 2x_{1} - x_{2} 

""" 

from sage.misc.latex import latex 

return latex(self._x) 

 

def __bool__(self): 

""" 

Return if ``self`` is non-zero. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: bool(a + 2*b - c) 

True 

""" 

return bool(self._x) 

 

__nonzero__ = __bool__ 

 

def __eq__(self, other): 

""" 

Check equality. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: elt = a + 2*b - c 

sage: elt == elt 

True 

sage: elt == x 

False 

sage: elt == 2*b 

False 

""" 

if not isinstance(other, SpecialJordanAlgebra.Element): 

return False 

if other.parent() != self.parent(): 

return False 

return self._x == other._x 

 

def __ne__(self, other): 

""" 

Check inequality. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: elt = a + 2*b - c 

sage: elt != elt 

False 

sage: elt != x 

True 

sage: elt != 2*b 

True 

""" 

return not self == other 

 

def _add_(self, other): 

""" 

Add ``self`` and ``other``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: a + 2*b 

x + 2*y 

""" 

return self.__class__(self.parent(), self._x + other._x) 

 

def _neg_(self): 

""" 

Negate ``self``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: -(a + 2*b) 

-x - 2*y 

""" 

return self.__class__(self.parent(), -self._x) 

 

def _sub_(self, other): 

""" 

Subtract ``other`` from ``self``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: a - 2*b 

x - 2*y 

""" 

return self.__class__(self.parent(), self._x - other._x) 

 

def _mul_(self, other): 

""" 

Multiply ``self`` and ``other``. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: (a + 2*b) * (c - b) 

-1/2*x*y + 1/2*x*z - 1/2*y*x - 2*y^2 + y*z + 1/2*z*x + z*y 

 

sage: F.<x,y,z> = FreeAlgebra(GF(3)) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: (a + 2*b) * (c - b) 

x*y + 2*x*z + y*x + y^2 + y*z + 2*z*x + z*y 

""" 

x = self._x 

y = other._x 

# This is safer than dividing by 2 

R = self.parent().base_ring() 

return self.__class__(self.parent(), (x*y + y*x) * ~R(2)) 

 

def _lmul_(self, other): 

""" 

Multiply ``self`` by the scalar ``other`` on the left. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: (a + b) * 2 

2*x + 2*y 

""" 

return self.__class__(self.parent(), self._x * other) 

 

def _rmul_(self, other): 

""" 

Multiply ``self`` and the scalar ``other`` by the right 

action. 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: 2 * (a + b) 

2*x + 2*y 

""" 

return self.__class__(self.parent(), other * self._x) 

 

def monomial_coefficients(self, copy=True): 

""" 

Return a dictionary whose keys are indices of basis elements in 

the support of ``self`` and whose values are the corresponding 

coefficients. 

 

INPUT: 

 

- ``copy`` -- (default: ``True``) if ``self`` is internally 

represented by a dictionary ``d``, then make a copy of ``d``; 

if ``False``, then this can cause undesired behavior by 

mutating ``d`` 

 

EXAMPLES:: 

 

sage: F.<x,y,z> = FreeAlgebra(QQ) 

sage: J = JordanAlgebra(F) 

sage: a,b,c = map(J, F.gens()) 

sage: elt = a + 2*b - c 

sage: elt.monomial_coefficients() 

{x: 1, y: 2, z: -1} 

""" 

return self._x.monomial_coefficients(copy) 

 

class JordanAlgebraSymmetricBilinear(JordanAlgebra): 

r""" 

A Jordan algebra given by a symmetric bilinear form `m`. 

""" 

def __init__(self, R, form, names=None): 

""" 

Initialize ``self``. 

 

TESTS:: 

 

sage: m = matrix([[-2,3],[3,4]]) 

sage: J = JordanAlgebra(m) 

sage: TestSuite(J).run() 

""" 

self._form = form 

self._M = FreeModule(R, form.ncols()) 

cat = MagmaticAlgebras(R).Commutative().Unital().FiniteDimensional().WithBasis() 

self._no_generic_basering_coercion = True # Remove once 16492 is fixed 

Parent.__init__(self, base=R, names=names, category=cat) 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: m = matrix([[-2,3],[3,4]]) 

sage: JordanAlgebra(m) 

Jordan algebra over Integer Ring given by the symmetric bilinear form: 

[-2 3] 

[ 3 4] 

""" 

return "Jordan algebra over {} given by the symmetric bilinear" \ 

" form:\n{}".format(self.base_ring(), self._form) 

 

def _element_constructor_(self, *args): 

""" 

Construct an element of ``self`` from ``s``. 

 

Here ``s`` can be a pair of an element of `R` and an 

element of `M`, or an element of `R`, or an element of 

`M`, or an element of a(nother) Jordan algebra given 

by a symmetric bilinear form. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J = JordanAlgebra(m) 

sage: J(2) 

2 + (0, 0) 

sage: J((-4, (2, 5))) 

-4 + (2, 5) 

sage: J((-4, (ZZ^2)((2, 5)))) 

-4 + (2, 5) 

sage: J(2, (-2, 3)) 

2 + (-2, 3) 

sage: J(2, (ZZ^2)((-2, 3))) 

2 + (-2, 3) 

sage: J(-1, 1, 0) 

-1 + (1, 0) 

sage: J((ZZ^2)((1, 3))) 

0 + (1, 3) 

 

sage: m = matrix([[2]]) 

sage: J = JordanAlgebra(m) 

sage: J(2) 

2 + (0) 

sage: J((-4, (2,))) 

-4 + (2) 

sage: J(2, (-2,)) 

2 + (-2) 

sage: J(-1, 1) 

-1 + (1) 

sage: J((ZZ^1)((3,))) 

0 + (3) 

 

sage: m = Matrix(QQ, []) 

sage: J = JordanAlgebra(m) 

sage: J(2) 

2 + () 

sage: J((-4, ())) 

-4 + () 

sage: J(2, ()) 

2 + () 

sage: J(-1) 

-1 + () 

sage: J((ZZ^0)(())) 

0 + () 

""" 

R = self.base_ring() 

if len(args) == 1: 

s = args[0] 

 

if isinstance(s, JordanAlgebraSymmetricBilinear.Element): 

if s.parent() is self: 

return s 

return self.element_class(self, R(s._s), self._M(s._v)) 

 

if isinstance(s, (list, tuple)): 

if len(s) != 2: 

raise ValueError("must be length 2") 

return self.element_class(self, R(s[0]), self._M(s[1])) 

 

if s in self._M: 

return self.element_class(self, R.zero(), self._M(s)) 

 

return self.element_class(self, R(s), self._M.zero()) 

 

if len(args) == 2 and (isinstance(args[1], (list, tuple)) or args[1] in self._M): 

return self.element_class(self, R(args[0]), self._M(args[1])) 

 

if len(args) == self._form.ncols() + 1: 

return self.element_class(self, R(args[0]), self._M(args[1:])) 

 

raise ValueError("unable to construct an element from the given data") 

 

@cached_method 

def basis(self): 

""" 

Return a basis of ``self``. 

 

The basis returned begins with the unity of `R` and continues with 

the standard basis of `M`. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J = JordanAlgebra(m) 

sage: J.basis() 

Family (1 + (0, 0), 0 + (1, 0), 0 + (0, 1)) 

""" 

R = self.base_ring() 

ret = (self.element_class(self, R.one(), self._M.zero()),) 

ret += tuple(self.element_class(self, R.zero(), x) 

for x in self._M.basis()) 

return Family(ret) 

 

algebra_generators = basis 

 

def gens(self): 

""" 

Return the generators of ``self``. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J = JordanAlgebra(m) 

sage: J.basis() 

Family (1 + (0, 0), 0 + (1, 0), 0 + (0, 1)) 

""" 

return tuple(self.algebra_generators()) 

 

@cached_method 

def zero(self): 

""" 

Return the element 0. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J = JordanAlgebra(m) 

sage: J.zero() 

0 + (0, 0) 

""" 

return self.element_class(self, self.base_ring().zero(), self._M.zero()) 

 

@cached_method 

def one(self): 

""" 

Return the element 1 if it exists. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J = JordanAlgebra(m) 

sage: J.one() 

1 + (0, 0) 

""" 

return self.element_class(self, self.base_ring().one(), self._M.zero()) 

 

class Element(AlgebraElement): 

""" 

An element of a Jordan algebra defined by a symmetric bilinear form. 

""" 

def __init__(self, parent, s, v): 

""" 

Initialize ``self``. 

 

TESTS:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: TestSuite(a + 2*b - c).run() 

""" 

self._s = s 

self._v = v 

AlgebraElement.__init__(self, parent) 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: a + 2*b - c 

1 + (2, -1) 

""" 

return "{} + {}".format(self._s, self._v) 

 

def _latex_(self): 

r""" 

Return a latex representation of ``self``. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: latex(a + 2*b - c) 

1 + \left(2,\,-1\right) 

""" 

from sage.misc.latex import latex 

return "{} + {}".format(latex(self._s), latex(self._v)) 

 

def __bool__(self): 

""" 

Return if ``self`` is non-zero. 

 

TESTS:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: bool(1) 

True 

sage: bool(b) 

True 

sage: bool(a + 2*b - c) 

True 

""" 

return bool(self._s) or bool(self._v) 

 

__nonzero__ = __bool__ 

 

def __eq__(self, other): 

""" 

Check equality. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: x = 4*a - b + 3*c 

sage: x == J((4, (-1, 3))) 

True 

sage: a == x 

False 

 

sage: m = matrix([[-2,3],[3,4]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: 4*a - b + 3*c == x 

False 

""" 

if not isinstance(other, JordanAlgebraSymmetricBilinear.Element): 

return False 

if other.parent() != self.parent(): 

return False 

return self._s == other._s and self._v == other._v 

 

def __ne__(self, other): 

""" 

Check inequality. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: x = 4*a - b + 3*c 

sage: x != J((4, (-1, 3))) 

False 

sage: a != x 

True 

 

sage: m = matrix([[-2,3],[3,4]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: 4*a - b + 3*c != x 

True 

""" 

return not self == other 

 

def _add_(self, other): 

""" 

Add ``self`` and ``other``. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: a + b 

1 + (1, 0) 

sage: b + c 

0 + (1, 1) 

""" 

return self.__class__(self.parent(), self._s + other._s, self._v + other._v) 

 

def _neg_(self): 

""" 

Negate ``self``. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: -(a + b - 2*c) 

-1 + (-1, 2) 

""" 

return self.__class__(self.parent(), -self._s, -self._v) 

 

def _sub_(self, other): 

""" 

Subtract ``other`` from ``self``. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: a - b 

1 + (-1, 0) 

sage: b - c 

0 + (1, -1) 

""" 

return self.__class__(self.parent(), self._s - other._s, self._v - other._v) 

 

def _mul_(self, other): 

""" 

Multiply ``self`` and ``other``. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: (4*a - b + 3*c)*(2*a + 2*b - c) 

12 + (6, 2) 

 

sage: m = matrix([[-2,3],[3,4]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: (4*a - b + 3*c)*(2*a + 2*b - c) 

21 + (6, 2) 

""" 

P = self.parent() 

return self.__class__(P, 

self._s * other._s 

+ (self._v * P._form * other._v.column())[0], 

other._s * self._v + self._s * other._v) 

 

def _lmul_(self, other): 

""" 

Multiply ``self`` by the scalar ``other`` on the left. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: (a + b - c) * 2 

2 + (2, -2) 

""" 

return self.__class__(self.parent(), self._s * other, self._v * other) 

 

def _rmul_(self, other): 

""" 

Multiply ``self`` with the scalar ``other`` by the right 

action. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: 2 * (a + b - c) 

2 + (2, -2) 

""" 

return self.__class__(self.parent(), other * self._s, other * self._v) 

 

def monomial_coefficients(self, copy=True): 

""" 

Return a dictionary whose keys are indices of basis elements in 

the support of ``self`` and whose values are the corresponding 

coefficients. 

 

INPUT: 

 

- ``copy`` -- ignored 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: elt = a + 2*b - c 

sage: elt.monomial_coefficients() 

{0: 1, 1: 2, 2: -1} 

""" 

d = {0: self._s} 

for i,c in enumerate(self._v): 

d[i+1] = c 

return d 

 

def trace(self): 

r""" 

Return the trace of ``self``. 

 

The trace of an element `\alpha + x \in M^*` is given by 

`t(\alpha + x) = 2 \alpha`. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: x = 4*a - b + 3*c 

sage: x.trace() 

8 

""" 

return 2 * self._s 

 

def norm(self): 

r""" 

Return the norm of ``self``. 

 

The norm of an element `\alpha + x \in M^*` is given by 

`n(\alpha + x) = \alpha^2 - (x, x)`. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: x = 4*a - b + 3*c; x 

4 + (-1, 3) 

sage: x.norm() 

13 

""" 

return self._s * self._s - (self._v * self.parent()._form 

* self._v.column())[0] 

 

def bar(self): 

r""" 

Return the result of the bar involution of ``self``. 

 

The bar involution `\bar{\cdot}` is the `R`-linear 

endomorphism of `M^*` defined by `\bar{1} = 1` and 

`\bar{x} = -x` for `x \in M`. 

 

EXAMPLES:: 

 

sage: m = matrix([[0,1],[1,1]]) 

sage: J.<a,b,c> = JordanAlgebra(m) 

sage: x = 4*a - b + 3*c 

sage: x.bar() 

4 + (1, -3) 

 

We check that it is an algebra morphism:: 

 

sage: y = 2*a + 2*b - c 

sage: x.bar() * y.bar() == (x*y).bar() 

True 

""" 

return self.__class__(self.parent(), self._s, -self._v)