Changeset 7471:88bbf02feb71
- Timestamp:
- 12/01/07 18:46:25 (5 years ago)
- Branch:
- default
- Location:
- sage
- Files:
-
- 21 edited
-
calculus/calculus.py (modified) (7 diffs)
-
calculus/wester.py (modified) (1 diff)
-
functions/constants.py (modified) (1 diff)
-
gsl/dft.py (modified) (1 diff)
-
interfaces/gp.py (modified) (1 diff)
-
misc/functional.py (modified) (1 diff)
-
modular/dirichlet.py (modified) (2 diffs)
-
rings/arith.py (modified) (1 diff)
-
rings/complex_interval.pyx (modified) (1 diff)
-
rings/complex_number.pyx (modified) (1 diff)
-
rings/contfrac.py (modified) (1 diff)
-
rings/fraction_field_element.py (modified) (1 diff)
-
rings/integer.pyx (modified) (1 diff)
-
rings/number_field/number_field.py (modified) (2 diffs)
-
rings/polynomial/complex_roots.py (modified) (1 diff)
-
rings/polynomial/polynomial_element.pyx (modified) (1 diff)
-
rings/polynomial/real_roots.pyx (modified) (1 diff)
-
rings/qqbar.py (modified) (3 diffs)
-
rings/rational.pyx (modified) (1 diff)
-
rings/real_mpfi.pyx (modified) (14 diffs)
-
rings/real_mpfr.pyx (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/calculus/calculus.py
r7458 r7471 4322 4322 4323 4323 sage: RR(sin(pi)) 4324 0.0000000000000001224646799147354325 4324 1.22464679914735e-16 4325 4326 4326 sage: type(RR(sqrt(163)*pi)) 4327 4327 <type 'sage.rings.real_mpfr.RealNumber'> … … 4604 4604 x 4605 4605 sage: a = floor(5.4 + x); a 4606 floor(x + 0.400000000000000 4) + 54606 floor(x + 0.400000000000000) + 5 4607 4607 sage: a(2) 4608 4608 7 … … 4807 4807 pi/6 4808 4808 sage: asin(1 + I*1.0) 4809 1.061275061905036*I + 0.666239432492515 34809 1.061275061905036*I + 0.666239432492515 4810 4810 """ 4811 4811 def _repr_(self, simplify=True): … … 4831 4831 asinh(1/2) 4832 4832 sage: asinh(1 + I*1.0) 4833 0.666239432492515 3*I + 1.0612750619050364833 0.666239432492515*I + 1.061275061905036 4834 4834 """ 4835 4835 def _repr_(self, simplify=True): … … 4853 4853 acosh(1/2) 4854 4854 sage: acosh(1 + I*1.0) 4855 0.904556894302381 3*I + 1.0612750619050364855 0.904556894302381*I + 1.061275061905036 4856 4856 4857 4857 Warning: If the input is real the output will be real or NaN: … … 4886 4886 atanh(1/2) 4887 4887 sage: atanh(1 + I*1.0) 4888 1.017221967897851*I + 0.402359478108525 14888 1.017221967897851*I + 0.402359478108525 4889 4889 """ 4890 4890 def _repr_(self, simplify=True): … … 4910 4910 pi/3 4911 4911 sage: acos(1 + I*1.0) 4912 0.904556894302381 3- 1.061275061905036*I4912 0.904556894302381 - 1.061275061905036*I 4913 4913 """ 4914 4914 def _repr_(self, simplify=True): -
sage/calculus/wester.py
r7352 r7471 26 26 e^(sqrt(163)*pi) 27 27 sage: print RealField(150)(a) 28 2 62537412640768743.9999999999992500725971981928 2.6253741264076874399999999999925007259719819e17 29 29 30 30 sage: # Evaluate the Bessel function J[2] numerically at z=1+I. -
sage/functions/constants.py
r7430 r7471 540 540 2*%i 541 541 sage: 1e8*I 542 1 00000000.000000*I542 1.00000000000000e8*I 543 543 """ 544 544 def __init__(self): -
sage/gsl/dft.py
r4063 r7471 331 331 sage: A = [exp(-2*pi*i*I/5) for i in J] 332 332 sage: s = IndexedSequence(A,J) 333 333 334 sage: s.dst() # discrete sine 334 Indexed sequence: [ 0.000000000000000111022302462516 - 2.50000000000000*I, 0.000000000000000111022302462516 - 2.50000000000000*I, 0.000000000000000111022302462516 - 2.50000000000000*I, 0.000000000000000111022302462516 - 2.50000000000000*I, 0.000000000000000111022302462516 - 2.50000000000000*I]335 indexed by [0, 1, 2, 3, 4] 335 Indexed sequence: [1.11022302462516e-16 - 2.50000000000000*I, 1.11022302462516e-16 - 2.50000000000000*I, 1.11022302462516e-16 - 2.50000000000000*I, 1.11022302462516e-16 - 2.50000000000000*I, 1.11022302462516e-16 - 2.50000000000000*I] 336 indexed by [0, 1, 2, 3, 4] 336 337 """ 337 338 F = self.base_ring() ## elements must be coercible into RR -
sage/interfaces/gp.py
r7315 r7471 366 366 11243.9812000000 + 15.0000000000000*I 367 367 sage: ComplexField(10)(gp(11243.9812+15*I)) 368 1 .1e4+ 15.*I368 11000. + 15.*I 369 369 """ 370 370 GP = self.parent() -
sage/misc/functional.py
r7470 r7471 714 714 12.5878862295484 715 715 sage: n(pi^2 + e, digits=50) 716 12.58788622954840385419477847122881363307094650094 07716 12.587886229548403854194778471228813633070946500941 717 717 718 718 You can also usually use method notation: -
sage/modular/dirichlet.py
r5477 r7471 669 669 sage: e = G.0 670 670 sage: e.gauss_sum_numerical() 671 0.000000000000000555111512312578+ 1.73205080756888*I671 5.55111512312578e-16 + 1.73205080756888*I 672 672 sage: abs(e.gauss_sum_numerical()) 673 673 1.73205080756888 … … 675 675 1.73205080756888 676 676 sage: e.gauss_sum_numerical(a=2) 677 - 0.00000000000000111022302462516- 1.73205080756888*I677 -1.11022302462516e-15 - 1.73205080756888*I 678 678 sage: e.gauss_sum_numerical(a=2, prec=100) 679 0.0000000000000000000000000000047331654313260708324703713917- 1.7320508075688772935274463415*I679 4.7331654313260708324703713917e-30 - 1.7320508075688772935274463415*I 680 680 sage: G = DirichletGroup(13) 681 681 sage: e = G.0 -
sage/rings/arith.py
r7457 r7471 71 71 (x + 1) * x^2 * (x^2 - x + 1) 72 72 sage: z^2 - z + 1 73 0.00000000000000011102230246251673 1.11022302462516e-16 74 74 75 75 This example involves a $p$-adic number. -
sage/rings/complex_interval.pyx
r7425 r7471 483 483 sage: a = ~(5+I) 484 484 sage: a * (5+I) 485 [0.99999999999999988 .. 1.0000000000000003] + [- 0.000000000000000027755575615628914 .. 0.000000000000000055511151231257828]*I485 [0.99999999999999988 .. 1.0000000000000003] + [-2.7755575615628914e-17 .. 5.5511151231257828e-17]*I 486 486 """ 487 487 cdef ComplexIntervalFieldElement x -
sage/rings/complex_number.pyx
r7425 r7471 874 874 (x + 1) * x^2 * (x^2 - x + 1) 875 875 sage: z^2 - z + 1 876 0.000000000000000111022302462516876 1.11022302462516e-16 877 877 """ 878 878 import sage.rings.arith -
sage/rings/contfrac.py
r4257 r7471 30 30 245850922/78256779 31 31 sage: RealField(200)(QQ(c) - pi) 32 - 0.00000000000000007817936619907543540015211305991089148115398144810719593095032 -7.8179366199075435400152113059910891481153981448107195930950e-17 33 33 34 34 We can also create matrices, polynomials, vectors, etc., over the continued -
sage/rings/fraction_field_element.py
r6528 r7471 126 126 (1.0000*x^4 + 4.0000*x^2 + 1.0000*x + 3.0000)/(1.0000*x^5 - 1.0000*x^4 + 4.0000*x^3 - 4.0000*x^2 + 4.0000*x - 4.0000) 127 127 sage: whole, parts = q.partial_fraction_decomposition(); parts 128 [(- 0.0000076294*x^2 + 1.0000)/(1.0000*x^4 + 4.0000*x^2 + 4.0000), 1.0000/(1.0000*x - 1.0000)]128 [(-7.6294e-6*x^2 + 1.0000)/(1.0000*x^4 + 4.0000*x^2 + 4.0000), 1.0000/(1.0000*x - 1.0000)] 129 129 sage: sum(parts) 130 (1.0000*x^4 - 0.0000076294*x^3 + 4.0000*x^2 + 1.0000*x + 3.0000)/(1.0000*x^5 - 1.0000*x^4 + 4.0000*x^3 - 4.0000*x^2 + 4.0000*x - 4.0000) 131 130 (1.0000*x^4 - 7.6294e-6*x^3 + 4.0000*x^2 + 1.0000*x + 3.0000)/(1.0000*x^5 - 1.0000*x^4 + 4.0000*x^3 - 4.0000*x^2 + 4.0000*x - 4.0000) 132 131 AUTHOR: 133 132 -- Robert Bradshaw (2007-05-31) -
sage/rings/integer.pyx
r7317 r7471 69 69 sage: RR = RealField(200) 70 70 sage: RR(n) 71 9 390823.000000000000000000000000000000000000000000000000000071 9.3908230000000000000000000000000000000000000000000000000000e6 72 72 73 73 """ -
sage/rings/number_field/number_field.py
r7442 r7471 3773 3773 To: Complex Field with 58 bits of precision 3774 3774 Defn: a |--> -0.62996052494743676 - 1.0911236359717214*I 3775 b |--> -0.00000000000000019428902930940239 + 1.0000000000000000*I, 3776 ... 3775 b |--> -1.9428902930940239e-16 + 1.0000000000000000*I, Relative number field morphism: 3776 ... 3777 From: Number Field in a with defining polynomial x^3 - 2 over its base field 3777 3778 To: Complex Field with 58 bits of precision 3778 3779 Defn: a |--> 1.2599210498948731 3779 3780 b |--> -0.99999999999999999*I] 3780 3781 sage: f[0](a)^3 3781 2.0000000000000002 - 0.00000000000000086389229103644993*I3782 2.0000000000000002 - 8.6389229103644993e-16*I 3782 3783 sage: f[0](b)^2 3783 -1.0000000000000001 - 0.00000000000000038857805861880480*I3784 -1.0000000000000001 - 3.8857805861880480e-16*I 3784 3785 sage: f[0](a+b) 3785 3786 -0.62996052494743693 - 0.091123635971721295*I … … 4427 4428 sage: C.complex_embeddings() 4428 4429 [Ring morphism: 4429 From: Cyclotomic Field of order 4 and degree 24430 To: Complex Field with 53 bits of precision4431 Defn: zeta4 |--> 6.12323399573677e-17 + 1.00000000000000*I, Ring morphism:4432 From: Cyclotomic Field of order 4 and degree 24433 To: Complex Field with 53 bits of precision4434 Defn: zeta4 |--> -0.000000000000000183697019872103- 1.00000000000000*I]4430 From: Cyclotomic Field of order 4 and degree 2 4431 To: Complex Field with 53 bits of precision 4432 Defn: zeta4 |--> 6.12323399573677e-17 + 1.00000000000000*I, Ring morphism: 4433 From: Cyclotomic Field of order 4 and degree 2 4434 To: Complex Field with 53 bits of precision 4435 Defn: zeta4 |--> -1.83697019872103e-16 - 1.00000000000000*I] 4435 4436 """ 4436 4437 CC = sage.rings.complex_field.ComplexField(prec) -
sage/rings/polynomial/complex_roots.py
r7469 r7471 50 50 [0.76604444311897801 .. 0.76604444311897802] + [0.64278760968653925 .. 0.64278760968653926]*I 51 51 sage: ip(irt) 52 [- 0.0000000000000013322676295501879 .. 0.00000000000000066613381477509393] + [-0.0000000000000012212453270876722 .. 0.00000000000000066613381477509393]*I52 [-1.3322676295501879e-15 .. 6.6613381477509393e-16] + [-1.2212453270876722e-15 .. 6.6613381477509393e-16]*I 53 53 sage: ipd(irt) 54 54 [6.8943999880707931 .. 6.8943999880708056] - [5.7850884871788474 .. 5.7850884871788600]*I -
sage/rings/polynomial/polynomial_element.pyx
r7469 r7471 1076 1076 sage: f = y^10 - 1.393493*y + 0.3 1077 1077 sage: f._mul_karatsuba(f) 1078 1.00000000000000*y^20 - 2.78698600000000*y^11 + 0.600000000000000*y^10 + 0.000000000000000111022302462516*y^8 - 0.000000000000000111022302462516*y^6 - 0.000000000000000111022302462516*y^3 + 1.94182274104900*y^2 - 0.836095800000000*y + 0.09000000000000001078 1.00000000000000*y^20 - 2.78698600000000*y^11 + 0.600000000000000*y^10 + 1.11022302462516e-16*y^8 - 1.11022302462516e-16*y^6 - 1.11022302462516e-16*y^3 + 1.94182274104900*y^2 - 0.836095800000000*y + 0.0900000000000000 1079 1079 sage: f._mul_fateman(f) 1080 1080 1.00000000000000*y^20 - 2.78698600000000*y^11 + 0.600000000000000*y^10 + 1.94182274104900*y^2 - 0.836095800000000*y + 0.0900000000000000 -
sage/rings/polynomial/real_roots.pyx
r7428 r7471 2733 2733 sage: bps = split_for_targets(ctx, bp, [(rr_gap(1/1234567893, 1/1234567892, 1), rr_gap(1/1234567891, 1/1234567890, 1), 12), (rr_gap(1/3, 1/2, -1), rr_gap(2/3, 3/4, -1), 6)]) 2734 2734 sage: str(bps[0]) 2735 '<IBP: (999992, 999992, 999992) + [0 .. 15) over [8613397477114467984778830327/10633823966279326983230456482242756608 .. 591908168025934394813836527495938294787/730750818665451459101842416358141509827966271488]; level 2; slope_err [-1 92592590990.49338 .. 192592590990.49338]>'2735 '<IBP: (999992, 999992, 999992) + [0 .. 15) over [8613397477114467984778830327/10633823966279326983230456482242756608 .. 591908168025934394813836527495938294787/730750818665451459101842416358141509827966271488]; level 2; slope_err [-1.9259259099049338e11 .. 1.9259259099049338e11]>' 2736 2736 sage: str(bps[1]) 2737 2737 '<IBP: (-1562500, -1875001, -2222223, -2592593, -2969137, -3337450) + [0 .. 4) over [1/2 .. 2863311531/4294967296]>' -
sage/rings/qqbar.py
r7428 r7471 273 273 [2.6420403358193503e44 .. 2.6420403358193520e44] 274 274 sage: lhs - rhs 275 [-7 9344219392947342000000000000. .. 81800756658404269000000000000.]275 [-7.9344219392947342e28 .. 8.1800756658404269e28] 276 276 sage: lhs == rhs 277 277 True … … 1930 1930 x^4 - 10*x^2 + 1 1931 1931 sage: p(RR(v.real())) 1932 0.00000000000001310063169057681932 1.31006316905768e-14 1933 1933 """ 1934 1934 try: … … 2956 2956 x^6 + 2*x^5 + 4*x^4 + 8*x^3 + 16*x^2 + 32*x + 64 2957 2957 sage: a.minpoly()(a) 2958 [- 0.00000000000000031918911957973251 .. 0.00000000000000034694469519536142] + [-0.00000000000000033133218391157016 .. 0.00000000000000032786273695961655]*I2958 [-3.1918911957973251e-16 .. 3.4694469519536142e-16] + [-3.3133218391157016e-16 .. 3.2786273695961655e-16]*I 2959 2959 sage: a.minpoly()(a) == 0 2960 2960 True -
sage/rings/rational.pyx
r7455 r7471 565 565 1.29099444873581 566 566 sage: (990829038092384908234098239048230984/4).sqrt_approx() 567 4 97701978620837137.47374920870362581922510725585130996993055116540856385567 4.9770197862083713747374920870362581922510725585130996993055116540856385e17 568 568 sage: (5/3).sqrt_approx(prec=200) 569 569 1.2909944487358056283930884665941332036109739017638636088625 -
sage/rings/real_mpfi.pyx
r7428 r7471 266 266 1.38777878078144e-17 267 267 sage: outward.upper() - nearest.upper() 268 0.000000000000000111022302462516268 1.11022302462516e-16 269 269 270 270 Some examples with a real interval field of higher precision: … … 1023 1023 0.666666666666667 1024 1024 sage: RIF(pi).diameter() 1025 0.0000000000000001413579858428231025 1.41357985842823e-16 1026 1026 sage: RIF(pi).absolute_diameter() 1027 0.0000000000000004440892098500631027 4.44089209850063e-16 1028 1028 sage: RIF(pi).relative_diameter() 1029 0.0000000000000001413579858428231029 1.41357985842823e-16 1030 1030 sage: (RIF(pi) - RIF(3, 22/7)).diameter() 1031 1031 0.142857142857144 … … 1317 1317 EXAMPLES: 1318 1318 sage: RIF(1.0) << 32 1319 [4 294967296.0000000 .. 4294967296.0000000]1319 [4.2949672960000000e9 .. 4.2949672960000000e9] 1320 1320 """ 1321 1321 if isinstance(x, RealIntervalFieldElement) and isinstance(y, (int,long, Integer)): … … 2045 2045 True 2046 2046 sage: r.sqrt()^2 - r 2047 [- 0.00000000000090949470177292824 .. 0.0000000000018189894035458565]2047 [-9.0949470177292824e-13 .. 1.8189894035458565e-12] 2048 2048 2049 2049 sage: r = RIF(-2.0) … … 2235 2235 sage: r = RIF(32.3) 2236 2236 sage: a = r.exp(); a 2237 [1 06588847274864.46 .. 106588847274864.49]2237 [1.0658884727486446e14 .. 1.0658884727486449e14] 2238 2238 sage: a.log() 2239 2239 [32.299999999999990 .. 32.300000000000005] … … 2241 2241 sage: r = RIF(-32.3) 2242 2242 sage: r.exp() 2243 [ 0.0000000000000093818445884986834 .. 0.0000000000000093818445884986851]2243 [9.3818445884986834e-15 .. 9.3818445884986851e-15] 2244 2244 """ 2245 2245 cdef RealIntervalFieldElement x … … 2261 2261 sage: r = RIF(32.0) 2262 2262 sage: r.exp2() 2263 [4 294967296.0000000 .. 4294967296.0000000]2263 [4.2949672960000000e9 .. 4.2949672960000000e9] 2264 2264 2265 2265 sage: r = RIF(-32.3) 2266 2266 sage: r.exp2() 2267 [0.00000000018911724825302069 .. 0.00000000018911724825302073] 2268 2267 [1.8911724825302069e-10 .. 1.8911724825302073e-10] 2269 2268 """ 2270 2269 cdef RealIntervalFieldElement x … … 2337 2336 sage: t=RIF(pi)/2 2338 2337 sage: t.cos() 2339 [- 0.00000000000000016081226496766367 .. 0.000000000000000061232339957367661]2338 [-1.6081226496766367e-16 .. 6.1232339957367661e-17] 2340 2339 sage: t.cos().cos() 2341 2340 [0.99999999999999988 .. 1.0000000000000000] … … 2426 2425 False 2427 2426 sage: q - q2 2428 [- 0.00000000000000044408920985006262 .. 0.00000000000000044408920985006262]2427 [-4.4408920985006262e-16 .. 4.4408920985006262e-16] 2429 2428 sage: q in q2 2430 2429 True … … 2455 2454 False 2456 2455 sage: q - q2 2457 [- 0.00000000000000022204460492503131 .. 0.00000000000000022204460492503131]2456 [-2.2204460492503131e-16 .. 2.2204460492503131e-16] 2458 2457 sage: q in q2 2459 2458 True … … 2484 2483 False 2485 2484 sage: q - q2 2486 [- 0.00000000000000022204460492503131 .. 0.00000000000000022204460492503131]2485 [-2.2204460492503131e-16 .. 2.2204460492503131e-16] 2487 2486 sage: q in q2 2488 2487 True … … 2568 2567 [0.46401763049299088 .. 0.46401763049299106] 2569 2568 sage: i.asinh() - q 2570 [- 0.00000000000000016653345369377349 .. 0.00000000000000016653345369377349]2569 [-1.6653345369377349e-16 .. 1.6653345369377349e-16] 2571 2570 """ 2572 2571 cdef RealIntervalFieldElement x … … 2586 2585 [0.42091124104853488 .. 0.42091124104853501] 2587 2586 sage: i.atanh() - q 2588 [- 0.00000000000000016653345369377349 .. 0.00000000000000016653345369377349]2587 [-1.6653345369377349e-16 .. 1.6653345369377349e-16] 2589 2588 """ 2590 2589 cdef RealIntervalFieldElement x … … 2841 2840 [1.000000000000000000000000000000000000 .. 1.000000000000000000000000000000000000] 2842 2841 sage: RealInterval(29308290382930840239842390482, 3^20) 2843 [3 486784401.00000000000000000000 .. 29308290382930840239842390482.0]2842 [3.48678440100000000000000000000e9 .. 2.93082903829308402398423904820e28] 2844 2843 """ 2845 2844 if not isinstance(s, str): -
sage/rings/real_mpfr.pyx
r7470 r7471 18 18 19 19 sage: RR(sys.maxint) 20 9 223372036854780000.# 64-bit21 2 147483647.00000# 32-bit20 9.22337203685478e18 # 64-bit 21 2.14748364700000e9 # 32-bit 22 22 23 23 TESTS: … … 853 853 sage: b = 2.0^99 854 854 sage: b.str() 855 '6 33825300114115000000000000000.'855 '6.33825300114115e29' 856 856 sage: b.str(no_sci=False) 857 857 '6.33825300114115e29' 858 858 sage: b.str(no_sci=True) 859 '6 33825300114115000000000000000.'859 '6.33825300114115e29' 860 860 sage: c = 2.0^100 861 861 sage: c.str() … … 868 868 '1267650600228230000000000000000.' 869 869 sage: 0.5^53 870 0.000000000000000111022302462516870 1.11022302462516e-16 871 871 sage: 0.5^54 872 872 5.55111512312578e-17 … … 928 928 t = str(s) 929 929 mpfr_free_str(s) 930 931 930 932 931 cdef int digits … … 1028 1027 A big number with no decimal point: 1029 1028 sage: a = RR(10^17); a 1030 1 00000000000000000.1029 1.00000000000000e17 1031 1030 sage: a.integer_part() 1032 1031 100000000000000000 … … 1156 1155 EXAMPLES: 1157 1156 sage: 1.0 << 32 1158 4 294967296.000001157 4.29496729600000e9 1159 1158 sage: 1.5 << 2.5 1160 1159 Traceback (most recent call last): … … 2080 2079 sage: r = -119.0 2081 2080 sage: r.cube_root()^3 - r # illustrates precision loss 2082 - 0.00000000000001421085471520202081 -1.42108547152020e-14 2083 2082 """ 2084 2083 cdef RealNumber x … … 2226 2225 sage: r = 32.3 2227 2226 sage: a = r.exp(); a 2228 1 06588847274864.2227 1.06588847274864e14 2229 2228 sage: a.log() 2230 2229 32.3000000000000 … … 2232 2231 sage: r = -32.3 2233 2232 sage: r.exp() 2234 0.000000000000009381844588498692233 9.38184458849869e-15 2235 2234 """ 2236 2235 cdef RealNumber x … … 2252 2251 sage: r = 32.0 2253 2252 sage: r.exp2() 2254 4 294967296.000002253 4.29496729600000e9 2255 2254 2256 2255 sage: r = -32.3 2257 2256 sage: r.exp2() 2258 0.0000000001891172482530212257 1.89117248253021e-10 2259 2258 2260 2259 """
Note: See TracChangeset
for help on using the changeset viewer.
