Changeset 1730:e85c22bdb6e5
- Timestamp:
- 10/30/06 03:21:50 (7 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
sage/rings/complex_number.py (modified) (31 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/rings/complex_number.py
r1674 r1730 147 147 sage: C, i = ComplexField(20).objgen() 148 148 sage: a = i^2; a 149 -1.0000 000149 -1.0000 150 150 sage: a.parent() 151 151 Complex Field with 20 bits of precision 152 152 sage: a = (1+i)^i; a 153 0.42882 919 + 0.15487170*I153 0.42882 + 0.15487*I 154 154 sage: (1+i)^(1+i) 155 0.27395 725 + 0.58370113*I155 0.27395 + 0.58370*I 156 156 sage: a.parent() 157 157 Complex Field with 20 bits of precision 158 158 sage: i^i 159 0.20787 954159 0.20787 160 160 sage: (2+i)^(0.5) 161 1.4553 471 + 0.34356070*I161 1.4553 + 0.34356*I 162 162 """ 163 163 if isinstance(right, (int, long, integer.Integer)): … … 188 188 sage: z = 2 + 3*i 189 189 sage: x = z.real(); x 190 2.0000000000000000000000000000 000190 2.0000000000000000000000000000 191 191 sage: x.parent() 192 192 Real Field with 100 bits of precision … … 202 202 sage: z = 2 + 3*i 203 203 sage: x = z.imag(); x 204 3.0000000000000000000000000000 000204 3.0000000000000000000000000000 205 205 sage: x.parent() 206 206 Real Field with 100 bits of precision … … 226 226 sage: a = ~(5+I) 227 227 sage: a * (5+I) 228 1.00000000000000 02 + 0.000000000000000027755575615628914*I228 1.00000000000000 - 0.0000000000000000555111512312578*I 229 229 """ 230 230 a = abs(self)*abs(self) … … 274 274 Infinity 275 275 sage: w = (1+sqrt(-3))/2; w 276 0.500000000000000 00 + 0.86602540378443860*I276 0.500000000000000 + 0.866025403784438*I 277 277 sage: abs(w) 278 0.999999999999999 89278 0.999999999999999 279 279 sage: w.multiplicative_order() 280 280 Traceback (most recent call last): … … 307 307 EXAMPLES: 308 308 sage: (1+I).acos() 309 0.904556894302381 40 - 1.0612750619050357*I309 0.904556894302381 - 1.06127506190503*I 310 310 """ 311 311 return self.parent()(self._pari_().acos()) … … 315 315 EXAMPLES: 316 316 sage: (1+I).acosh() 317 1.06127506190503 57 + 0.90455689430238140*I317 1.06127506190503 + 0.904556894302381*I 318 318 """ 319 319 return self.parent()(self._pari_().acosh()) … … 323 323 EXAMPLES: 324 324 sage: (1+I).asin() 325 0.666239432492515 27 + 1.0612750619050357*I325 0.666239432492515 + 1.06127506190503*I 326 326 """ 327 327 return self.parent()(self._pari_().asin()) … … 331 331 EXAMPLES: 332 332 sage: (1+I).asinh() 333 1.06127506190503 57 + 0.66623943249251527*I333 1.06127506190503 + 0.666239432492515*I 334 334 """ 335 335 return self.parent()(self._pari_().asinh()) … … 339 339 EXAMPLES: 340 340 sage: (1+I).atan() 341 1.01722196789785 14 + 0.40235947810852507*I341 1.01722196789785 + 0.402359478108525*I 342 342 """ 343 343 return self.parent()(self._pari_().atan()) … … 347 347 EXAMPLES: 348 348 sage: (1+I).atanh() 349 0.402359478108525 07 + 1.0172219678978514*I349 0.402359478108525 + 1.01722196789785*I 350 350 """ 351 351 return self.parent()(self._pari_().atanh()) … … 355 355 EXAMPLES: 356 356 sage: (1+I).cotan() 357 0.217621561854402 68 - 0.86801414289592493*I357 0.217621561854402 - 0.868014142895925*I 358 358 sage: i = ComplexField(200).0 359 359 sage: (1+i).cotan() 360 0.21762156185440268136513424360523807352075436916785404091068 128 - 0.86801414289592494863584920891627388827343874994609327121115055*I# 32-bit361 0.217621561854402681365134243605238073520754369167854040910681 28 - 0.86801414289592494863584920891627388827343874994609327121115055*I # 64-bit360 0.21762156185440268136513424360523807352075436916785404091068 - 0.86801414289592494863584920891627388827343874994609327121115*I # 32-bit 361 0.21762156185440268136513424360523807352075436916785404091068112 - 0.86801414289592494863584920891627388827343874994609327121115117*I # 64-bit 362 362 sage: i = ComplexField(220).0 363 363 sage: (1+i).cotan() 364 0.21762156185440268136513424360523807352075436916785404091068124239 250 - 0.86801414289592494863584920891627388827343874994609327121115071646235*I# 32-bit365 0.217621561854402681365134243605238073520754369167854040910681242392 50- 0.86801414289592494863584920891627388827343874994609327121115071646235*I # 64-bit364 0.21762156185440268136513424360523807352075436916785404091068124239 - 0.86801414289592494863584920891627388827343874994609327121115071646*I # 32-bit 365 0.21762156185440268136513424360523807352075436916785404091068124239235 - 0.86801414289592494863584920891627388827343874994609327121115071646235*I # 64-bit 366 366 """ 367 367 return self.parent()(self._pari_().cotan()) … … 371 371 EXAMPLES: 372 372 sage: (1+I).cos() 373 0.833730025131149 02 - 0.98889770576286506*I373 0.833730025131149 - 0.988897705762865*I 374 374 """ 375 375 return self.parent()(self._pari_().cos()) … … 379 379 EXAMPLES: 380 380 sage: (1+I).cosh() 381 0.833730025131149 02 + 0.98889770576286506*I381 0.833730025131149 + 0.988897705762865*I 382 382 """ 383 383 return self.parent()(self._pari_().cosh()) … … 409 409 sage: i = CC.0 410 410 sage: z = 1+i; z.eta() 411 0.742048775836564 70 + 0.19883137022991071*I411 0.742048775836564 + 0.198831370229910*I 412 412 413 413 We compute eta to low precision directly from the definition. 414 414 sage: z = 1 + i; z.eta() 415 0.742048775836564 70 + 0.19883137022991071*I415 0.742048775836564 + 0.198831370229910*I 416 416 sage: exp(pi * i * z / 12) * prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) 417 0.74204877583656 470 + 0.19883137022991068*I417 0.742048775836563 + 0.198831370229910*I 418 418 419 419 The optional argument allows us to omit the fractional part: 420 420 sage: z = 1 + i 421 421 sage: z.eta(omit_frac=True) 422 0.998129069925958 51 - 0.00000000000000000000081276931900000004*I # 32-bit423 0.998129069925958 51- 0.00000000000000000000081276931878173961*I # 64-bit422 0.998129069925958 - 0.000000000000000000000812769319000000*I # 32-bit 423 0.998129069925958 - 0.00000000000000000000081276931878173961*I # 64-bit 424 424 sage: prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) 425 0.99812906992595 840 + 0.00000000000000000052001876663675507*I# 32-bit426 0.99812906992595 840+ 0.00000000000000000052001876674058408*I # 64-bit425 0.998129069925956 + 0.0000000000000000123489424448887*I # 32-bit 426 0.998129069925956 + 0.00000000000000000052001876674058408*I # 64-bit 427 427 428 428 … … 437 437 You can also use functional notation. 438 438 sage: eta(1+I) 439 0.742048775836564 70 + 0.19883137022991071*I439 0.742048775836564 + 0.198831370229910*I 440 440 """ 441 441 try: … … 449 449 EXAMPLES: 450 450 sage: (1+I).sin() 451 1.29845758141597 73 + 0.63496391478473613*I451 1.29845758141597 + 0.634963914784736*I 452 452 """ 453 453 return self.parent()(self._pari_().sin()) … … 457 457 EXAMPLES: 458 458 sage: (1+I).sinh() 459 0.634963914784736 13 + 1.2984575814159773*I459 0.634963914784736 + 1.29845758141597*I 460 460 """ 461 461 return self.parent()(self._pari_().sinh()) … … 465 465 EXAMPLES: 466 466 sage: (1+I).tan() 467 0.271752585319511 74 + 1.0839233273386946*I467 0.271752585319511 + 1.08392332733869*I 468 468 """ 469 469 return self.parent()(self._pari_().tan()) … … 473 473 EXAMPLES: 474 474 sage: (1+I).tanh() 475 1.08392332733869 46 + 0.27175258531951174*I475 1.08392332733869 + 0.271752585319511*I 476 476 """ 477 477 return self.parent()(self._pari_().tanh()) … … 482 482 EXAMPLES: 483 483 sage: (1+I).agm(2-I) 484 1.62780548487270 66 + 0.13682754839736855*I484 1.62780548487270 + 0.136827548397368*I 485 485 """ 486 486 t = self.parent()(right)._pari_() … … 496 496 sage: i = CC.0 497 497 sage: (i^2).argument() 498 3.14159265358979 31498 3.14159265358979 499 499 sage: (1+i).argument() 500 0.785398163397448 28500 0.785398163397448 501 501 sage: i.argument() 502 1.57079632679489 66502 1.57079632679489 503 503 sage: (-i).argument() 504 -1.57079632679489 66504 -1.57079632679489 505 505 sage: (RR('-0.001') - i).argument() 506 -1.57179632646156 35506 -1.57179632646156 507 507 """ 508 508 return self.parent()(self._pari_().arg()) … … 515 515 sage: i = CC.0 516 516 sage: (i^2).arg() 517 3.14159265358979 31517 3.14159265358979 518 518 """ 519 519 return self.argument() … … 526 526 sage: i = CC.0 527 527 sage: (1+i).conjugate() 528 1.00000000000000 00 - 1.0000000000000000*I528 1.00000000000000 - 1.00000000000000*I 529 529 """ 530 530 return ComplexNumber(self.parent(), self.__re, -self.__im) … … 541 541 sage: z = 1 + i 542 542 sage: z.exp() 543 1.46869393991588515713896759732660426132695673662900872279767567631093696585951213872272449 73 + 2.2873552871788423912081719067005018089555862566683556809386581141036471601893454092673448521*I# 32-bit543 1.46869393991588515713896759732660426132695673662900872279767567631093696585951213872272449 + 2.28735528717884239120817190670050180895558625666835568093865811410364716018934540926734485*I # 32-bit 544 544 1.4686939399158851571389675973266042613269567366290087227976756763109369658595121387227244973 + 2.2873552871788423912081719067005018089555862566683556809386581141036471601893454092673448521*I # 64-bit 545 545 """ … … 553 553 sage: i = ComplexField(30).0 554 554 sage: (1+i).gamma() 555 0.49801566 824 - 0.15494982828*I555 0.49801566 - 0.15494982*I 556 556 """ 557 557 return self.parent()(self._pari_().gamma()) … … 565 565 sage: C, i = ComplexField(30).objgen() 566 566 sage: (1+i).gamma_inc(2 + 3*i) 567 0.0020969148 645 - 0.059981913655*I567 0.0020969148 - 0.059981913*I 568 568 sage: (1+i).gamma_inc(5) 569 -0.0013781309 353 + 0.0065198200246*I569 -0.0013781309 + 0.0065198200*I 570 570 sage: C(2).gamma_inc(1 + i) 571 0.70709209 610 - 0.42035364080*I571 0.70709209 - 0.42035364*I 572 572 sage: gamma_inc(2, 1 + i) 573 0.70709209 610 - 0.42035364080*I573 0.70709209 - 0.42035364*I 574 574 sage: gamma_inc(2, 5) 575 0.040427681994512 805575 0.0404276819945127 576 576 """ 577 577 return self.parent()(self._pari_().incgam(t)) … … 608 608 sage: C, i = ComplexField(30).objgen() 609 609 sage: i.sqrt() 610 0.70710678 119 + 0.70710678119*I610 0.70710678 + 0.70710678*I 611 611 sage: (1+i).sqrt() 612 1.0986841 135 + 0.45508986060*I612 1.0986841 + 0.45508986*I 613 613 sage: (C(-1)).sqrt() 614 1.0000000 000*I614 1.0000000*I 615 615 sage: i = ComplexField(200).0 616 616 sage: i.sqrt() 617 0.70710678118654752440084436210484903928483593768847403658833 981 + 0.70710678118654752440084436210484903928483593768847403658833981*I# 32-bit617 0.70710678118654752440084436210484903928483593768847403658833 + 0.70710678118654752440084436210484903928483593768847403658833*I # 32-bit 618 618 0.70710678118654752440084436210484903928483593768847403658833981 + 0.70710678118654752440084436210484903928483593768847403658833981*I # 64-bit 619 619 … … 628 628 sage: i = ComplexField(100).0 629 629 sage: (-i).sqrt() 630 0.70710678118654752440084436210 459 - 0.70710678118654752440084436210459*I630 0.70710678118654752440084436210 - 0.70710678118654752440084436210*I 631 631 """ 632 632 return self.sqrt() … … 640 640 sage: z = 1 + i 641 641 sage: z.zeta() 642 0.58215805 981 - 0.92684856430*I642 0.58215805 - 0.92684856*I 643 643 sage: zeta(z) 644 0.58215805 981 - 0.92684856430*I644 0.58215805 - 0.92684856*I 645 645 """ 646 646 return self.parent()(self._pari_().zeta()) … … 658 658 sage: C = ComplexField() 659 659 sage: z = (1/2)*(1 + sqrt(3) *C.0); z 660 0.500000000000000 00 + 0.86602540378443860*I660 0.500000000000000 + 0.866025403784438*I 661 661 sage: p = z.algdep(5); p 662 x^5 + x^2 # 32-bit 663 x^5 - x^4 + x^3 + x^2 - x + 1 # 64-bit 662 x^5 - x^4 + x^3 + x^2 - x + 1 664 663 sage: p.factor() 665 x^2 * (x^2 - x + 1) * (x + 1) # 32-bit 666 (x + 1) * (x^2 - x + 1)^2 # 64-bit 664 (x^2 - x + 1)^2 * (x + 1) 667 665 sage: z^2 - z + 1 668 0.000000000000000111022302462515 65666 0.000000000000000111022302462515 669 667 """ 670 668 import sage.rings.arith
Note: See TracChangeset
for help on using the changeset viewer.
