Changeset 1730:e85c22bdb6e5


Ignore:
Timestamp:
10/30/06 03:21:50 (7 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

Fixed doctests for complex_number.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/rings/complex_number.py

    r1674 r1730  
    147147            sage: C, i = ComplexField(20).objgen() 
    148148            sage: a = i^2; a 
    149             -1.0000000 
     149            -1.0000 
    150150            sage: a.parent() 
    151151            Complex Field with 20 bits of precision 
    152152            sage: a = (1+i)^i; a 
    153             0.42882919 + 0.15487170*I 
     153            0.42882 + 0.15487*I 
    154154            sage: (1+i)^(1+i) 
    155             0.27395725 + 0.58370113*I 
     155            0.27395 + 0.58370*I 
    156156            sage: a.parent() 
    157157            Complex Field with 20 bits of precision 
    158158            sage: i^i 
    159             0.20787954 
     159            0.20787 
    160160            sage: (2+i)^(0.5) 
    161             1.4553471 + 0.34356070*I 
     161            1.4553 + 0.34356*I 
    162162        """ 
    163163        if isinstance(right, (int, long, integer.Integer)): 
     
    188188            sage: z = 2 + 3*i 
    189189            sage: x = z.real(); x 
    190             2.0000000000000000000000000000000 
     190            2.0000000000000000000000000000 
    191191            sage: x.parent() 
    192192            Real Field with 100 bits of precision             
     
    202202            sage: z = 2 + 3*i 
    203203            sage: x = z.imag(); x 
    204             3.0000000000000000000000000000000 
     204            3.0000000000000000000000000000 
    205205            sage: x.parent() 
    206206            Real Field with 100 bits of precision 
     
    226226            sage: a = ~(5+I) 
    227227            sage: a * (5+I) 
    228             1.0000000000000002 + 0.000000000000000027755575615628914*I 
     228            1.00000000000000 - 0.0000000000000000555111512312578*I 
    229229        """ 
    230230        a = abs(self)*abs(self) 
     
    274274            Infinity 
    275275            sage: w = (1+sqrt(-3))/2; w 
    276             0.50000000000000000 + 0.86602540378443860*I 
     276            0.500000000000000 + 0.866025403784438*I 
    277277            sage: abs(w) 
    278             0.99999999999999989 
     278            0.999999999999999 
    279279            sage: w.multiplicative_order() 
    280280            Traceback (most recent call last): 
     
    307307        EXAMPLES: 
    308308            sage: (1+I).acos() 
    309             0.90455689430238140 - 1.0612750619050357*I 
     309            0.904556894302381 - 1.06127506190503*I 
    310310        """ 
    311311        return self.parent()(self._pari_().acos()) 
     
    315315        EXAMPLES: 
    316316            sage: (1+I).acosh() 
    317             1.0612750619050357 + 0.90455689430238140*I 
     317            1.06127506190503 + 0.904556894302381*I 
    318318        """ 
    319319        return self.parent()(self._pari_().acosh()) 
     
    323323        EXAMPLES: 
    324324            sage: (1+I).asin() 
    325             0.66623943249251527 + 1.0612750619050357*I 
     325            0.666239432492515 + 1.06127506190503*I 
    326326        """ 
    327327        return self.parent()(self._pari_().asin()) 
     
    331331        EXAMPLES: 
    332332            sage: (1+I).asinh() 
    333             1.0612750619050357 + 0.66623943249251527*I 
     333            1.06127506190503 + 0.666239432492515*I 
    334334        """ 
    335335        return self.parent()(self._pari_().asinh()) 
     
    339339        EXAMPLES: 
    340340            sage: (1+I).atan() 
    341             1.0172219678978514 + 0.40235947810852507*I 
     341            1.01722196789785 + 0.402359478108525*I 
    342342        """ 
    343343        return self.parent()(self._pari_().atan()) 
     
    347347        EXAMPLES: 
    348348            sage: (1+I).atanh() 
    349             0.40235947810852507 + 1.0172219678978514*I 
     349            0.402359478108525 + 1.01722196789785*I 
    350350        """ 
    351351        return self.parent()(self._pari_().atanh()) 
     
    355355        EXAMPLES: 
    356356            sage: (1+I).cotan() 
    357             0.21762156185440268 - 0.86801414289592493*I 
     357            0.217621561854402 - 0.868014142895925*I 
    358358            sage: i = ComplexField(200).0 
    359359            sage: (1+i).cotan() 
    360             0.21762156185440268136513424360523807352075436916785404091068128 - 0.86801414289592494863584920891627388827343874994609327121115055*I   # 32-bit 
    361             0.21762156185440268136513424360523807352075436916785404091068128 - 0.86801414289592494863584920891627388827343874994609327121115055*I   # 64-bit 
     360            0.21762156185440268136513424360523807352075436916785404091068 - 0.86801414289592494863584920891627388827343874994609327121115*I      # 32-bit 
     361            0.21762156185440268136513424360523807352075436916785404091068112 - 0.86801414289592494863584920891627388827343874994609327121115117*I   # 64-bit 
    362362            sage: i = ComplexField(220).0 
    363363            sage: (1+i).cotan() 
    364             0.21762156185440268136513424360523807352075436916785404091068124239250 - 0.86801414289592494863584920891627388827343874994609327121115071646235*I     # 32-bit 
    365             0.21762156185440268136513424360523807352075436916785404091068124239250 - 0.86801414289592494863584920891627388827343874994609327121115071646235*I   # 64-bit 
     364            0.21762156185440268136513424360523807352075436916785404091068124239 - 0.86801414289592494863584920891627388827343874994609327121115071646*I        # 32-bit 
     365            0.21762156185440268136513424360523807352075436916785404091068124239235 - 0.86801414289592494863584920891627388827343874994609327121115071646235*I   # 64-bit 
    366366        """ 
    367367        return self.parent()(self._pari_().cotan()) 
     
    371371        EXAMPLES: 
    372372            sage: (1+I).cos() 
    373             0.83373002513114902 - 0.98889770576286506*I 
     373            0.833730025131149 - 0.988897705762865*I 
    374374        """ 
    375375        return self.parent()(self._pari_().cos()) 
     
    379379        EXAMPLES: 
    380380            sage: (1+I).cosh() 
    381             0.83373002513114902 + 0.98889770576286506*I 
     381            0.833730025131149 + 0.988897705762865*I 
    382382        """ 
    383383        return self.parent()(self._pari_().cosh()) 
     
    409409            sage: i = CC.0 
    410410            sage: z = 1+i; z.eta() 
    411             0.74204877583656470 + 0.19883137022991071*I 
     411            0.742048775836564 + 0.198831370229910*I 
    412412             
    413413        We compute eta to low precision directly from the definition. 
    414414            sage: z = 1 + i; z.eta() 
    415             0.74204877583656470 + 0.19883137022991071*I 
     415            0.742048775836564 + 0.198831370229910*I 
    416416            sage: exp(pi * i * z / 12) * prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) 
    417             0.74204877583656470 + 0.19883137022991068*I 
     417            0.742048775836563 + 0.198831370229910*I 
    418418 
    419419        The optional argument allows us to omit the fractional part: 
    420420            sage: z = 1 + i 
    421421            sage: z.eta(omit_frac=True) 
    422             0.99812906992595851 - 0.00000000000000000000081276931900000004*I  # 32-bit 
    423             0.99812906992595851 - 0.00000000000000000000081276931878173961*I  # 64-bit 
     422            0.998129069925958 - 0.000000000000000000000812769319000000*I  # 32-bit 
     423            0.998129069925958 - 0.00000000000000000000081276931878173961*I  # 64-bit 
    424424            sage: prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) 
    425             0.99812906992595840 + 0.00000000000000000052001876663675507*I  # 32-bit 
    426             0.99812906992595840 + 0.00000000000000000052001876674058408*I  # 64-bit 
     425            0.998129069925956 + 0.0000000000000000123489424448887*I      # 32-bit 
     426            0.998129069925956 + 0.00000000000000000052001876674058408*I  # 64-bit 
    427427 
    428428         
     
    437437        You can also use functional notation. 
    438438            sage: eta(1+I) 
    439             0.74204877583656470 + 0.19883137022991071*I 
     439            0.742048775836564 + 0.198831370229910*I 
    440440        """ 
    441441        try: 
     
    449449        EXAMPLES: 
    450450            sage: (1+I).sin() 
    451             1.2984575814159773 + 0.63496391478473613*I 
     451            1.29845758141597 + 0.634963914784736*I 
    452452        """ 
    453453        return self.parent()(self._pari_().sin()) 
     
    457457        EXAMPLES: 
    458458            sage: (1+I).sinh() 
    459             0.63496391478473613 + 1.2984575814159773*I 
     459            0.634963914784736 + 1.29845758141597*I             
    460460        """ 
    461461        return self.parent()(self._pari_().sinh()) 
     
    465465        EXAMPLES: 
    466466            sage: (1+I).tan() 
    467             0.27175258531951174 + 1.0839233273386946*I 
     467            0.271752585319511 + 1.08392332733869*I 
    468468        """ 
    469469        return self.parent()(self._pari_().tan()) 
     
    473473        EXAMPLES: 
    474474            sage: (1+I).tanh() 
    475             1.0839233273386946 + 0.27175258531951174*I 
     475            1.08392332733869 + 0.271752585319511*I 
    476476        """ 
    477477        return self.parent()(self._pari_().tanh()) 
     
    482482        EXAMPLES: 
    483483            sage: (1+I).agm(2-I) 
    484             1.6278054848727066 + 0.13682754839736855*I 
     484            1.62780548487270 + 0.136827548397368*I 
    485485        """ 
    486486        t = self.parent()(right)._pari_() 
     
    496496            sage: i = CC.0 
    497497            sage: (i^2).argument() 
    498             3.1415926535897931 
     498            3.14159265358979 
    499499            sage: (1+i).argument() 
    500             0.78539816339744828 
     500            0.785398163397448 
    501501            sage: i.argument() 
    502             1.5707963267948966 
     502            1.57079632679489 
    503503            sage: (-i).argument() 
    504             -1.5707963267948966 
     504            -1.57079632679489 
    505505            sage: (RR('-0.001') - i).argument() 
    506             -1.5717963264615635 
     506            -1.57179632646156 
    507507        """ 
    508508        return self.parent()(self._pari_().arg()) 
     
    515515            sage: i = CC.0 
    516516            sage: (i^2).arg() 
    517             3.1415926535897931 
     517            3.14159265358979 
    518518        """ 
    519519        return self.argument() 
     
    526526            sage: i = CC.0 
    527527            sage: (1+i).conjugate() 
    528             1.0000000000000000 - 1.0000000000000000*I 
     528            1.00000000000000 - 1.00000000000000*I 
    529529        """ 
    530530        return ComplexNumber(self.parent(), self.__re, -self.__im) 
     
    541541            sage: z = 1 + i 
    542542            sage: z.exp() 
    543             1.4686939399158851571389675973266042613269567366290087227976756763109369658595121387227244973 + 2.2873552871788423912081719067005018089555862566683556809386581141036471601893454092673448521*I   # 32-bit 
     543            1.46869393991588515713896759732660426132695673662900872279767567631093696585951213872272449 + 2.28735528717884239120817190670050180895558625666835568093865811410364716018934540926734485*I     # 32-bit 
    544544            1.4686939399158851571389675973266042613269567366290087227976756763109369658595121387227244973 + 2.2873552871788423912081719067005018089555862566683556809386581141036471601893454092673448521*I   # 64-bit 
    545545        """ 
     
    553553            sage: i = ComplexField(30).0 
    554554            sage: (1+i).gamma() 
    555             0.49801566824 - 0.15494982828*I 
     555            0.49801566 - 0.15494982*I 
    556556        """ 
    557557        return self.parent()(self._pari_().gamma()) 
     
    565565            sage: C, i = ComplexField(30).objgen() 
    566566            sage: (1+i).gamma_inc(2 + 3*i) 
    567             0.0020969148645 - 0.059981913655*I 
     567            0.0020969148 - 0.059981913*I 
    568568            sage: (1+i).gamma_inc(5) 
    569             -0.0013781309353 + 0.0065198200246*I 
     569            -0.0013781309 + 0.0065198200*I 
    570570            sage: C(2).gamma_inc(1 + i) 
    571             0.70709209610 - 0.42035364080*I 
     571            0.70709209 - 0.42035364*I 
    572572            sage: gamma_inc(2, 1 + i)     
    573             0.70709209610 - 0.42035364080*I 
     573            0.70709209 - 0.42035364*I 
    574574            sage: gamma_inc(2, 5) 
    575             0.040427681994512805 
     575            0.0404276819945127 
    576576        """ 
    577577        return self.parent()(self._pari_().incgam(t)) 
     
    608608            sage: C, i = ComplexField(30).objgen() 
    609609            sage: i.sqrt() 
    610             0.70710678119 + 0.70710678119*I 
     610            0.70710678 + 0.70710678*I 
    611611            sage: (1+i).sqrt() 
    612             1.0986841135 + 0.45508986060*I 
     612            1.0986841 + 0.45508986*I 
    613613            sage: (C(-1)).sqrt() 
    614             1.0000000000*I 
     614            1.0000000*I 
    615615            sage: i = ComplexField(200).0 
    616616            sage: i.sqrt() 
    617             0.70710678118654752440084436210484903928483593768847403658833981 + 0.70710678118654752440084436210484903928483593768847403658833981*I   # 32-bit 
     617            0.70710678118654752440084436210484903928483593768847403658833 + 0.70710678118654752440084436210484903928483593768847403658833*I         # 32-bit 
    618618            0.70710678118654752440084436210484903928483593768847403658833981 + 0.70710678118654752440084436210484903928483593768847403658833981*I   # 64-bit 
    619619 
     
    628628            sage: i = ComplexField(100).0 
    629629            sage: (-i).sqrt() 
    630             0.70710678118654752440084436210459 - 0.70710678118654752440084436210459*I 
     630            0.70710678118654752440084436210 - 0.70710678118654752440084436210*I 
    631631        """ 
    632632        return self.sqrt() 
     
    640640            sage: z = 1 + i 
    641641            sage: z.zeta() 
    642             0.58215805981 - 0.92684856430*I 
     642            0.58215805 - 0.92684856*I 
    643643            sage: zeta(z) 
    644             0.58215805981 - 0.92684856430*I 
     644            0.58215805 - 0.92684856*I 
    645645        """ 
    646646        return self.parent()(self._pari_().zeta()) 
     
    658658            sage: C = ComplexField() 
    659659            sage: z = (1/2)*(1 + sqrt(3) *C.0); z 
    660             0.50000000000000000 + 0.86602540378443860*I 
     660            0.500000000000000 + 0.866025403784438*I 
    661661            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 
    664663            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) 
    667665            sage: z^2 - z + 1 
    668             0.00000000000000011102230246251565 
     666            0.000000000000000111022302462515 
    669667        """ 
    670668        import sage.rings.arith 
Note: See TracChangeset for help on using the changeset viewer.