# Ticket #9958: 9958_float_printing.patch

File 9958_float_printing.patch, 85.9 KB (added by jdemeyer, 9 years ago)
• ## doc/en/thematic_tutorials/linear_programming.rst

# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1325776347 -3600
# Node ID a3322bc3df71439c6e98bc5b5b2bc45d1a5b3a9f
# Parent  92c93226b64f933e0af00bbcbd1a8a79c444f43f
Doctest fixes for printing of floating point numbers with less digits in Python-2.7

diff --git a/doc/en/thematic_tutorials/linear_programming.rst b/doc/en/thematic_tutorials/linear_programming.rst
 a :: sage: sum(weight[o] * taken[o] for o in L) 0.69649597966191712 0.6964959796619171 Should we take a flashlight?
• ## sage/calculus/calculus.py

diff --git a/sage/calculus/calculus.py b/sage/calculus/calculus.py
 a sage: n(z,200) 4.6467837624329358733826155674904591885104869874232887508703 sage: float(z) 4.6467837624329356 4.646783762432936 We test pickling:: sage: f(x) = exp(-sqrt(x)) sage: f.nintegral(x, 0, 1) (0.52848223531423055, 4.163...e-11, 231, 0) (0.5284822353142306, 4.163...e-11, 231, 0) We can also use the numerical_integral function, which calls the GSL C library. :: sage: numerical_integral(f, 0, 1) (0.52848223225314706, 6.83928460...e-07) (0.528482232253147, 6.83928460...e-07) Note that in exotic cases where floating point evaluation of the expression leads to the wrong value, then the output can be Now numerically integrating, we see why the answer is wrong:: sage: f.nintegrate(x,0,1) (-480.00000000000006, 5.3290705182007538e-12, 21, 0) (-480.00000000000006, 5.329070518200754e-12, 21, 0) It is just because every floating point evaluation of return -480.0 in floating point.
• ## sage/calculus/test_sympy.py

diff --git a/sage/calculus/test_sympy.py b/sage/calculus/test_sympy.py
 a sage: pi^2 pi^2 sage: float(pi) 3.1415926535897931 3.141592653589793 sage: RealField(200)(pi) 3.1415926535897932384626433832795028841971693993751058209749 sage: float(pi + exp(1))
• ## sage/categories/examples/semigroups.py

diff --git a/sage/categories/examples/semigroups.py b/sage/categories/examples/semigroups.py
 a This is the semigroup that contains all sorts of objects:: sage: S.some_elements() [3, 42, 'a', 3.3999999999999999, 'raton laveur'] [3, 42, 'a', 3.4, 'raton laveur'] with product rule given by $a \times b = a$ for all $a, b$:: EXAMPLES:: sage: Semigroups().example().some_elements() [3, 42, 'a', 3.3999999999999999, 'raton laveur'] [3, 42, 'a', 3.4, 'raton laveur'] """ return [self(i) for i in [3, 42, "a", 3.4, "raton laveur"]]
• ## sage/categories/examples/semigroups_cython.pyx

diff --git a/sage/categories/examples/semigroups_cython.pyx b/sage/categories/examples/semigroups_cython.pyx
 a This is the semigroup which contains all sort of objects:: sage: S.some_elements() [3, 42, 'a', 3.3999999999999999, 'raton laveur'] [3, 42, 'a', 3.4, 'raton laveur'] with product rule is given by $a \times b = a$ for all $a,b$. ::
• ## sage/combinat/e_one_star.py

diff --git a/sage/combinat/e_one_star.py b/sage/combinat/e_one_star.py
 a sage: P = Patch([Face((0,0,0),t,color) for t in [1,2,3]]) sage: P.repaint([(0.9, 0.9, 0.9), (0.65,0.65,0.65), (0.4,0.4,0.4)]) sage: for f in P: f.color() RGB color (0.9000..., 0.9000..., 0.9000...) RGB color (0.6500..., 0.6500..., 0.6500...) RGB color (0.4000..., 0.4000..., 0.4000...) RGB color (0.9, 0.9, 0.9) RGB color (0.65, 0.65, 0.65) RGB color (0.4, 0.4, 0.4) Using a dictionary to color faces according to their type::
• ## sage/ext/fast_callable.pyx

diff --git a/sage/ext/fast_callable.pyx b/sage/ext/fast_callable.pyx
 a sin(add(ipow(v_0, 2), v_1)) sage: fc = fast_callable(expr, domain=float) sage: fc(5, 7) 0.55142668124169059 0.5514266812416906 """ cdef Expression et if isinstance(x, Expression):
• ## sage/finance/fractal.pyx

diff --git a/sage/finance/fractal.pyx b/sage/finance/fractal.pyx
 a sage: N = 2^15 sage: s = [1/math.sqrt(k+1) for k in [0..N]] sage: s[:5] [1.0, 0.70710678118654746, 0.57735026918962584, 0.5, 0.44721359549995793] [1.0, 0.7071067811865475, 0.5773502691896258, 0.5, 0.4472135954999579] We run the simulation::
• ## sage/finance/markov_multifractal.py

diff --git a/sage/finance/markov_multifractal.py b/sage/finance/markov_multifractal.py
 a sage: msm = finance.MarkovSwitchingMultifractal(8,1.4,1,0.95,3) sage: msm.m0() 1.3999999999999999 1.4 """ return self.__m0 sage: msm = finance.MarkovSwitchingMultifractal(8,1.4,0.01,0.95,3) sage: msm.gamma_kbar() 0.94999999999999996 0.95 """ return self.__gamma_kbar sage: msm = finance.MarkovSwitchingMultifractal(8,1.4,1.0,0.95,3) sage: msm.gamma() (0.001368852970712986, 0.0041009402016725094, 0.012252436441829..., 0.03630878209190..., 0.10501923017634..., 0.28312883556311..., 0.6315968501359..., 0.95000000000000...) (0.001368852970712986, 0.004100940201672509, 0.012252436441829..., 0.03630878209190..., 0.10501923017634..., 0.28312883556311..., 0.6315968501359..., 0.95000000000000...) """ try: return self.__gamma
• ## sage/finance/time_series.pyx

diff --git a/sage/finance/time_series.pyx b/sage/finance/time_series.pyx
 a sage: t.standard_deviation() 0.33729638212891383 sage: t.mean() -0.089334255069294391 -0.08933425506929439 sage: t.variance() 0.1137688493972542... sage: v = finance.TimeSeries([1,1,1,2,3]); v [1.0000, 1.0000, 1.0000, 2.0000, 3.0000] sage: v.mean() 1.6000000000000001 1.6 """ return self.sum() / self._length sage: v = finance.TimeSeries([1,1,1,2,3]); v [1.0000, 1.0000, 1.0000, 2.0000, 3.0000] sage: v.moment(1) 1.6000000000000001 1.6 sage: v.moment(2) 3.2000000000000002 3.2 """ if k <= 0: raise ValueError, "k must be positive" sage: v = finance.TimeSeries([1,2,3]) sage: v.central_moment(2) 0.66666666666666663 0.6666666666666666 Note that the central moment is different from the moment here, since the mean is not 0:: sage: mu = v.mean(); mu 2.0 sage: ((1-mu)^2 + (2-mu)^2 + (3-mu)^2) / 3 0.66666666666666663 0.6666666666666666 """ if k == 1: return float(0) sage: mu = v.mean(); sum([(a-mu)^2 for a in v])/len(v) 14.4 sage: v.autocovariance(1) -2.70000000... -2.7 sage: mu = v.mean(); sum([(v[i]-mu)*(v[i+1]-mu) for i in range(len(v)-1)])/len(v) -2.70000000... -2.7 sage: v.autocovariance(1) -2.70000000... -2.7 We illustrate with a random sample that an independently and identically distributed distribution with zero mean and sage: v = finance.TimeSeries([1,1,1,2,3]); v [1.0000, 1.0000, 1.0000, 2.0000, 3.0000] sage: v.variance() 0.80000000000000004 0.8 sage: v.variance(bias=True) 0.64000000000000001 0.64 TESTS:: sage: v.standard_deviation() 0.8944271909... sage: v.standard_deviation(bias=True) 0.8000000000... 0.8 TESTS:: sage: s = a.standard_deviation() sage: len(a.clip_remove(-s,s))/float(len(a)) 0.68309399999999998 0.683094 sage: len(a.clip_remove(-2*s,2*s))/float(len(a)) 0.95455900000000005 0.954559 sage: len(a.clip_remove(-3*s,3*s))/float(len(a)) 0.997228 sage: len(a.clip_remove(-5*s,5*s))/float(len(a)) 0.99999800000000005 0.999998 There were no "six sigma events"::
• ## sage/functions/hyperbolic.py

diff --git a/sage/functions/hyperbolic.py b/sage/functions/hyperbolic.py
 a sage: tanh(3.1415) 0.996271386633702 sage: float(tanh(pi)) 0.996272076220749... 0.99627207622075 sage: tan(3.1415/4) 0.999953674278156 sage: tanh(pi/4) sage: arccoth(2).n(200) 0.54930614433405484569762261846126285232374527891137472586735 sage: float(arccoth(2)) 0.54930614433405489 0.5493061443340549 sage: latex(arccoth(x)) {\rm arccoth}\left(x\right) sage: arccsch(1).n(200) 0.88137358701954302523260932497979230902816032826163541075330 sage: float(arccsch(1)) 0.88137358701954305 0.881373587019543 sage: latex(arccsch(x)) {\rm arccsch}\left(x\right)
• ## sage/functions/log.py

diff --git a/sage/functions/log.py b/sage/functions/log.py
 a sage: ln(2.0) 0.693147180559945 sage: ln(float(-1)) 3.1415926535897931j 3.141592653589793j sage: ln(complex(-1)) 3.1415926535897931j 3.141592653589793j We do not currently support a hold parameter in functional notation:: sage: log(float(0)) -inf sage: log(float(-1)) 3.1415926535897931j 3.141592653589793j sage: log(x).subs(x=float(-1)) 3.1415926535897931j 3.141592653589793j """ GinacFunction.__init__(self, 'log', latex_name=r'\log', conversions=dict(maxima='log')) sage: complex(polylog(4,2)) (2.4278628067547032-0.17437130002545306j) sage: float(polylog(4,0.5)) 0.51747906167389934 0.5174790616738993 sage: z = var('z') sage: polylog(2,z).series(z==0, 5)
• ## sage/functions/min_max.py

diff --git a/sage/functions/min_max.py b/sage/functions/min_max.py
 a sage: f = max_symbolic(sin(x), cos(x)) sage: r = integral(f, x, 0, 1) sage: r.n() 0.87391244115672628 0.8739124411567263 """ return max_symbolic(args)
• ## sage/functions/special.py

diff --git a/sage/functions/special.py b/sage/functions/special.py
 a sage: float(jacobi("sn",1/2,1/2)) 0.4707504736556572 sage: float(inverse_jacobi("sn",0.47,1/2)) 0.49909823132221959 0.4990982313222196 sage: float(inverse_jacobi("sn",0.4707504,0.5)) 0.49999991146655481 0.4999999114665548 sage: P = plot(inverse_jacobi('sn', x, 0.5), 0, 1, plot_points=20) Now to view this, just type show(P).
• ## sage/functions/spike_function.py

diff --git a/sage/functions/spike_function.py b/sage/functions/spike_function.py
 a sage: from sage.functions.spike_function import SpikeFunction sage: S = SpikeFunction([(0,1),(1,2),(pi,-5)]) sage: S A spike function with spikes at [0.0, 1.0, 3.1415926535897931] A spike function with spikes at [0.0, 1.0, 3.141592653589793] sage: S.support [0.0, 1.0, 3.1415926535897931] [0.0, 1.0, 3.141592653589793] """ def __init__(self, v, eps=0.0000001): """ A spike function with spikes at [-3.0, -1.0, 2.0] sage: P = S.plot_fft_abs(8) sage: p = P[0]; p.ydata [5.0, 5.0, 3.3679586919241769, 3.3679586919241769, 4.1231056256176606, 4.1231056256176606, 4.7599216642180551, 4.7599216642180551] [5.0, 5.0, 3.367958691924177, 3.367958691924177, 4.123105625617661, 4.123105625617661, 4.759921664218055, 4.759921664218055] """ w = self.vector(samples = samples, xmin=xmin, xmax=xmax) xmin, xmax = self._ranges(xmin, xmax)
• ## sage/functions/transcendental.py

diff --git a/sage/functions/transcendental.py b/sage/functions/transcendental.py
 a EXAMPLES:: sage: exponential_integral_1(2) 0.048900510708061118 0.04890051070806112 sage: w = exponential_integral_1(2,4); w [0.048900510708061118, 0.0037793524098489067, 0.00036008245216265873, 3.7665622843924751e-05] # 32-bit [0.048900510708061118, 0.0037793524098489063, 0.00036008245216265873, 3.7665622843924534e-05] # 64-bit [0.04890051070806112, 0.003779352409848906..., 0.00036008245216265873, 3.7665622843924...e-05] IMPLEMENTATION: We use the PARI C-library functions eint1 and veceint1.
• ## sage/functions/trig.py

diff --git a/sage/functions/trig.py b/sage/functions/trig.py
 a sage: maxima.atan2(1,-1) 3*%pi/4 sage: math.atan2(1,-1) 2.3561944901923448 2.356194490192345 More examples::
• ## sage/geometry/polyhedra.py

diff --git a/sage/geometry/polyhedra.py b/sage/geometry/polyhedra.py
 a sage: proj = p.projection() sage: filled_poly = proj.render_fill_2d() sage: filled_poly.axes_width() 0.8000... 0.8 """ poly = [polygon2d(self.coordinates_of(p), **kwds) for p in self.polygons]
• ## sage/geometry/toric_plotter.py

diff --git a/sage/geometry/toric_plotter.py b/sage/geometry/toric_plotter.py
 a sage: from sage.geometry.toric_plotter import color_list sage: color_list("grey", 1) [RGB color (0.50196078431372548, 0.50196078431372548, 0.50196078431372548)] [RGB color (0.5019607843137255, 0.5019607843137255, 0.5019607843137255)] sage: len(color_list("grey", 3)) 3 sage: color_list("rainbow", 3)
• ## sage/graphs/generic_graph.py

diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
 a EXAMPLES:: sage: (graphs.FruchtGraph()).clustering_coeff().values() [0.33333333333333331, 0.33333333333333331, 0.0, 0.33333333333333331, 0.33333333333333331, 0.33333333333333331, 0.33333333333333331, 0.33333333333333331, 0.0, 0.33333333333333331, 0.33333333333333331, 0.0] [0.3333333333333333, 0.3333333333333333, 0.0, 0.3333333333333333, 0.3333333333333333, 0.3333333333333333, 0.3333333333333333, 0.3333333333333333, 0.0, 0.3333333333333333, 0.3333333333333333, 0.0] sage: (graphs.FruchtGraph()).clustering_coeff() {0: 0.33333333333333331, 1: 0.33333333333333331, 2: 0.0, 3: 0.33333333333333331, 4: 0.33333333333333331, 5: 0.33333333333333331, 6: 0.33333333333333331, 7: 0.33333333333333331, 8: 0.0, 9: 0.33333333333333331, 10: 0.33333333333333331, 11: 0.0} {0: 0.3333333333333333, 1: 0.3333333333333333, 2: 0.0, 3: 0.3333333333333333, 4: 0.3333333333333333, 5: 0.3333333333333333, 6: 0.3333333333333333, 7: 0.3333333333333333, 8: 0.0, 9: 0.3333333333333333, 10: 0.3333333333333333, 11: 0.0} sage: (graphs.FruchtGraph()).clustering_coeff(weights=True) ({0: 0.33333333333333331, 1: 0.33333333333333331, 2: 0.0, 3: 0.33333333333333331, 4: 0.33333333333333331, 5: 0.33333333333333331, 6: 0.33333333333333331, 7: 0.33333333333333331, 8: 0.0, 9: 0.33333333333333331, 10: 0.33333333333333331, 11: 0.0}, {0: 0.083333333333333329, 1: 0.083333333333333329, 2: 0.083333333333333329, 3: 0.083333333333333329, 4: 0.083333333333333329, 5: 0.083333333333333329, 6: 0.083333333333333329, 7: 0.083333333333333329, 8: 0.083333333333333329, 9: 0.083333333333333329, 10: 0.083333333333333329, 11: 0.083333333333333329}) ({0: 0.3333333333333333, 1: 0.3333333333333333, 2: 0.0, 3: 0.3333333333333333, 4: 0.3333333333333333, 5: 0.3333333333333333, 6: 0.3333333333333333, 7: 0.3333333333333333, 8: 0.0, 9: 0.3333333333333333, 10: 0.3333333333333333, 11: 0.0}, {0: 0.08333333333333333, 1: 0.08333333333333333, 2: 0.08333333333333333, 3: 0.08333333333333333, 4: 0.08333333333333333, 5: 0.08333333333333333, 6: 0.08333333333333333, 7: 0.08333333333333333, 8: 0.08333333333333333, 9: 0.08333333333333333, 10: 0.08333333333333333, 11: 0.08333333333333333}) sage: (graphs.FruchtGraph()).clustering_coeff(nbunch=[0,1,2]) {0: 0.33333333333333331, 1: 0.33333333333333331, 2: 0.0} {0: 0.3333333333333333, 1: 0.3333333333333333, 2: 0.0} sage: (graphs.FruchtGraph()).clustering_coeff(nbunch=[0,1,2],weights=True) ({0: 0.33333333333333331, 1: 0.33333333333333331, 2: 0.0}, {0: 0.33333333333333331, 1: 0.33333333333333331, 2: 0.33333333333333331}) ({0: 0.3333333333333333, 1: 0.3333333333333333, 2: 0.0}, {0: 0.3333333333333333, 1: 0.3333333333333333, 2: 0.3333333333333333}) """ import networkx return networkx.clustering(self.networkx_graph(copy=False), nbunch, weights)
• ## sage/graphs/graph.py

diff --git a/sage/graphs/graph.py b/sage/graphs/graph.py
 a EXAMPLES:: sage: (graphs.ChvatalGraph()).centrality_betweenness() {0: 0.069696969696969688, 1: 0.069696969696969688, 2: 0.060606060606060601, 3: 0.060606060606060601, 4: 0.069696969696969688, 5: 0.069696969696969688, 6: 0.060606060606060601, 7: 0.060606060606060601, 8: 0.060606060606060601, 9: 0.060606060606060601, 10: 0.060606060606060601, 11: 0.060606060606060601} {0: 0.06969696969696969, 1: 0.06969696969696969, 2: 0.0606060606060606, 3: 0.0606060606060606, 4: 0.06969696969696969, 5: 0.06969696969696969, 6: 0.0606060606060606, 7: 0.0606060606060606, 8: 0.0606060606060606, 9: 0.0606060606060606, 10: 0.0606060606060606, 11: 0.0606060606060606} sage: (graphs.ChvatalGraph()).centrality_betweenness(normalized=False) {0: 3.833333333333333, 1: 3.833333333333333, 2: 3.333333333333333, 3: 3.333333333333333, 4: 3.833333333333333, 5: 3.833333333333333, 6: 3.333333333333333, 7: 3.333333333333333, 8: 3.333333333333333, 9: 3.333333333333333, 10: 3.333333333333333, 11: 3.333333333333333} sage: D = DiGraph({0:[1,2,3], 1:[2], 3:[0,1]}) sage: D = D.to_undirected() sage: D.show(figsize=[2,2]) sage: D.centrality_degree() {0: 1.0, 1: 1.0, 2: 0.66666666666666663, 3: 0.66666666666666663} {0: 1.0, 1: 1.0, 2: 0.6666666666666666, 3: 0.6666666666666666} sage: D.centrality_degree(v=1) 1.0 """
• ## sage/graphs/graph_editor.py

diff --git a/sage/graphs/graph_editor.py b/sage/graphs/graph_editor.py
 a sage: from sage.graphs.graph_editor import graph_to_js sage: G = graphs.CompleteGraph(4) sage: graph_to_js(G) 'num_vertices=4;edges=[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]];pos=[[0.5,0.0],[0.0,0.49999999999999989],[0.49999999999999989,1.0],[1.0,0.50000000000000011]];' 'num_vertices=4;edges=[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]];pos=[[0.5,0.0],[0.0,0.4999999999999999],[0.4999999999999999,1.0],[1.0,0.5000000000000001]];' sage: graph_to_js(graphs.StarGraph(2)) 'num_vertices=3;edges=[[0,1],[0,2]];pos=[[0.75,0.5],[1.0,0.0],[0.0,1.0]];' """
• ## sage/gsl/integration.pyx

diff --git a/sage/gsl/integration.pyx b/sage/gsl/integration.pyx
 a To integrate the function $x^2$ from 0 to 1, we do :: sage: numerical_integral(x^2, 0, 1, max_points=100) (0.33333333333333331, 3.7007434154171879e-15) (0.3333333333333333, 3.700743415417188e-15) To integrate the function $\sin(x)^3 + \sin(x)$ we do :: sage: numerical_integral(sin(x)^3 + sin(x),  0, pi) (3.333333333333333, 3.7007434154171883e-14) (3.333333333333333, 3.700743415417188e-14) The input can be any callable:: sage: numerical_integral(lambda x: sin(x)^3 + sin(x),  0, pi) (3.333333333333333, 3.7007434154171883e-14) (3.333333333333333, 3.700743415417188e-14) We check this with a symbolic integration:: sage: f = x^2 sage: numerical_integral(f, 0, 1, max_points=200, eps_abs=1e-7, eps_rel=1e-7, rule=4) (0.33333333333333331, 3.7007434154171879e-15) (0.3333333333333333, 3.700743415417188e-15) For a Python function with parameters:: function (which uses GSL) or the native integration (which uses Maxima):: sage: exp(-1/x).nintegral(x, 1, 2)  # via maxima (0.50479221787318396, 5.6043194293440752e-15, 21, 0) (0.504792217873184, 5.604319429344075e-15, 21, 0) sage: numerical_integral(exp(-1/x), 1, 2) (0.50479221787318..., 5.60431942934407...e-15)
• ## sage/gsl/probability_distribution.pyx

diff --git a/sage/gsl/probability_distribution.pyx b/sage/gsl/probability_distribution.pyx
 a sage: for _ in range(10000): ...       counts[X.get_random_element()] += 1 sage: float(counts[1]/counts[0]) 3.0420371867421179 3.042037186742118 """
• ## sage/interfaces/maxima.py

diff --git a/sage/interfaces/maxima.py b/sage/interfaces/maxima.py
 a sage: a = maxima('(1 + sqrt(2))^5') sage: float(a) 82.012193308819747 82.01219330881975 sage: a.numer() 82.01219330881975
• ## sage/interfaces/maxima_abstract.py

diff --git a/sage/interfaces/maxima_abstract.py b/sage/interfaces/maxima_abstract.py
 a sage: t(2) sin(2) sage: float(t(2)) 0.90929742682568171 0.9092974268256817 sage: loads(t.dumps()) gamma(x)*sin(x) """ EXAMPLES:: sage: float(maxima("3.14")) 3.1400000000000001 3.14 sage: float(maxima("1.7e+17")) 1.7e+17 sage: float(maxima("1.7e-17")) 1.6999999999999999e-17 1.7e-17 """ try: return float(repr(self.numer()))
• ## sage/interfaces/r.py

diff --git a/sage/interfaces/r.py b/sage/interfaces/r.py
 a sage: rr = r.dnorm(r.seq(-3,3,0.1)) sage: sum(rr._sage_()) 9.97721251689810... 9.9772125168981... Or you get a dictionary to be able to access all the information::
• ## sage/lfunctions/dokchitser.py

diff --git a/sage/lfunctions/dokchitser.py b/sage/lfunctions/dokchitser.py
 a 0.998583063162746 sage: a = delta_qexp(1000) sage: sum(a[n]/float(n)^14 for n in range(1,1000)) 0.99858306316274592 0.9985830631627459 Illustrate that one can give a list of complex numbers for v (see trac 10937)::
• ## sage/libs/mpmath/ext_impl.pyx

diff --git a/sage/libs/mpmath/ext_impl.pyx b/sage/libs/mpmath/ext_impl.pyx
 a sage: from sage.libs.mpmath.ext_impl import exp_fixed sage: y = exp_fixed(1<<53, 53) sage: float(y) / 2^53 2.7182818284590442 2.718281828459044 """ cdef Integer v
• ## sage/libs/mwrank/interface.py

diff --git a/sage/libs/mwrank/interface.py b/sage/libs/mwrank/interface.py
 a sage: E = mwrank_EllipticCurve([0, 0, 0, -1002231243161, 0]) sage: E.silverman_bound() 18.295452104682472 18.29545210468247 sage: E = mwrank_EllipticCurve([0,0,1,-7,6]) sage: E.silverman_bound() 6.2848333699724028 6.284833369972403 """ return self.__curve.silverman_bound() sage: E = mwrank_EllipticCurve([0,0,1,-7,6]) sage: E.regulator() 0.41714355875838399 0.417143558758384 """ return self.__mw.regulator()
• ## sage/libs/mwrank/mwrank.pyx

diff --git a/sage/libs/mwrank/mwrank.pyx b/sage/libs/mwrank/mwrank.pyx
 a sage: D2.getbasis() '[[1:-1:1], [-2:3:1], [-14:25:8]]' sage: D2.regulator() 0.41714355875838399 0.417143558758384 """ sig_on() return float(string_sigoff(two_descent_regulator(self.x)))
• ## sage/libs/pari/gen.pyx

diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
 a sage: g = pari(-1.0)^(1/5); g 0.809016994374947 + 0.587785252292473*I sage: g.__complex__() (0.80901699437494745+0.58778525229247314j) (0.8090169943749475+0.5877852522924731j) sage: complex(g) (0.80901699437494745+0.58778525229247314j) (0.8090169943749475+0.5877852522924731j) ::
• ## sage/matrix/matrix_double_dense.pyx

diff --git a/sage/matrix/matrix_double_dense.pyx b/sage/matrix/matrix_double_dense.pyx
 a sage: M=matrix(CDF, [[10.234r + 34.2343jr, 34e10r]]) sage: M [10.234 + 34.2343*I     340000000000.0] [10.234 + 34.2343*I     3.4e+11] sage: M.round(2) [10.23 + 34.23*I  340000000000.0] [10.23 + 34.23*I        3.4e+11] sage: M.round() [ 10.0 + 34.0*I 340000000000.0] [10.0 + 34.0*I       3.4e+11] """ global numpy cdef Matrix_double_dense M
• ## sage/matrix/matrix_mod2_dense.pyx

diff --git a/sage/matrix/matrix_mod2_dense.pyx b/sage/matrix/matrix_mod2_dense.pyx
 a 62483/125000 sage: float(d) 0.499863999... 0.499864 sage: A.density(approx=True) 0.499864000... sage: float(len(A.nonzero_positions())/1000^2) 0.49986399... 0.499864 """ if approx: from sage.rings.real_mpfr import create_RealNumber
• ## sage/matrix/matrix_mod2e_dense.pyx

diff --git a/sage/matrix/matrix_mod2e_dense.pyx b/sage/matrix/matrix_mod2e_dense.pyx
 a sage: K. = GF(2^4) sage: A = random_matrix(K,1000,1000,density=0.1) sage: float(A.density()) 0.099738... 0.099739... sage: A = random_matrix(K,1000,1000,density=1.0) sage: float(A.density()) sage: A = random_matrix(K,1000,1000,density=0.5) sage: float(A.density()) 0.499759... 0.49976... Note, that the matrix is updated and not zero-ed out before being randomized::
• ## sage/misc/explain_pickle.py

diff --git a/sage/misc/explain_pickle.py b/sage/misc/explain_pickle.py
 a sage: from sage.misc.explain_pickle import * sage: test_pickle(float(pi)) 0: \x80 PROTO      2 2: G    BINFLOAT   3.1415926535897931 2: G    BINFLOAT   3.141592653589793 11: .    STOP highest protocol among opcodes = 2 explain_pickle in_current_sage=True/False: float(RR(3.1415926535897931)) result: 3.1415926535897931 result: 3.141592653589793 """ self.push(self.sib(f))
• ## sage/misc/prandom.py

diff --git a/sage/misc/prandom.py b/sage/misc/prandom.py
 a EXAMPLES: sage: [random() for i in [1 .. 4]] [0.111439293741037, 0.51434751341916773, 0.044689685248156419, 0.33249060644241302] [0.111439293741037, 0.5143475134191677, 0.04468968524815642, 0.332490606442413] """ return _pyrand().random() sage: uniform(0, 1) 0.111439293741037 sage: uniform(e, pi) 0.51434751341916773*pi + 0.48565248658083227*e 0.5143475134191677*pi + 0.48565248658083227*e sage: RR(_) 2.93601069876846 """ sage: [expovariate(1.0) for i in range(3)] [1.10114367058632, 0.652772818610748, 1.69983589896220] sage: [expovariate(1000) for i in range(3)] [0.00035543583938093908, 0.0025254102812587195, 0.0001175899408167489] [0.0003554358393809391, 0.0025254102812587195, 0.0001175899408167489] """ return _pyrand().expovariate(lambd) EXAMPLES: sage: [gauss(0, 1) for i in range(3)] [0.91910117576579153, 0.77445267562464837, 0.86389968668008765] [0.9191011757657915, 0.7744526756246484, 0.8638996866800877] sage: [gauss(0, 100) for i in range(3)] [24.916051749154448, -62.992720615792727, -8.1993122536718...] [24.916051749154448, -62.99272061579273, -8.1993122536718...] sage: [gauss(1000, 10) for i in range(3)] [998.75907000456607, 996.10873385116918, 1010.1256817458031] [998.7590700045661, 996.1087338511692, 1010.1256817458031] """ return _pyrand().gauss(mu, sigma) EXAMPLES: sage: [lognormvariate(100, 10) for i in range(3)] [2.9410355688290246e+37, 2.2257548162070125e+38, 4.1422994517174461e+43] [2.9410355688290246e+37, 2.2257548162070125e+38, 4.142299451717446e+43] """ return _pyrand().lognormvariate(mu, sigma) EXAMPLES: sage: [normalvariate(0, 1) for i in range(3)] [-1.3725589805594069, -1.1701670364898928, 0.043241005551101427] [-1.372558980559407, -1.1701670364898928, 0.04324100555110143] sage: [normalvariate(0, 100) for i in range(3)] [37.456958750417691, 159.63477432332979, 124.10293211240089] [37.45695875041769, 159.6347743233298, 124.1029321124009] sage: [normalvariate(1000, 10) for i in range(3)] [1008.5303090383741, 989.86248926448945, 985.77289211502421] [1008.5303090383741, 989.8624892644895, 985.7728921150242] """ return _pyrand().normalvariate(mu, sigma) EXAMPLES: sage: [vonmisesvariate(1.0r, 3.0r) for i in range(1, 5)] [0.89832863935542584, 0.67180300070412846, 2.0308777524813397, 1.714325253725145...] [0.8983286393554258, 0.6718030007041285, 2.0308777524813397, 1.714325253725145...] """ return _pyrand().vonmisesvariate(mu, kappa) EXAMPLES: sage: [weibullvariate(1, 3) for i in range(1, 5)] [0.49069775546342537, 0.89721855646112125, 0.35757384653194202, 0.73937725551684697] [0.49069775546342537, 0.8972185564611213, 0.357573846531942, 0.739377255516847] """ return _pyrand().weibullvariate(alpha, beta)
• ## sage/misc/preparser.py

diff --git a/sage/misc/preparser.py b/sage/misc/preparser.py
 a sage: z = 3.1415R sage: z 3.1415000000000002 3.1415 sage: type(z)
• ## sage/misc/randstate.pyx

diff --git a/sage/misc/randstate.pyx b/sage/misc/randstate.pyx
 a sage: set_random_seed(0) sage: rtest() (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.96619117347084138)  # 32-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.96619117347084138)  # 64-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.9661911734708414)  # 32-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.9661911734708414)  # 64-bit sage: set_random_seed(1) sage: rtest() (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.83350776541997362)  # 64-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.8335077654199736)  # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.8335077654199736)  # 64-bit sage: set_random_seed(2) sage: rtest() (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ],  637693405, 27695, 0.19982565117278328)  # 32-bit (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ], 1642898426, 27695, 0.19982565117278328)  # 64-bit sage: set_random_seed(0) sage: rtest() (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.96619117347084138)  # 32-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.96619117347084138)  # 64-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.9661911734708414)  # 32-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.9661911734708414)  # 64-bit sage: set_random_seed(1) sage: rtest() (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.83350776541997362)  # 64-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.8335077654199736)  # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.8335077654199736)  # 64-bit sage: set_random_seed(2) sage: rtest() (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ],  637693405, 27695, 0.19982565117278328)  # 32-bit sage: initial_seed() 12345L sage: rtest() (720, 0.0216737401150802, x^2 - x, (), [ 1, 0, 0, 0, 0 ], 912534076, 14005, 0.92053315995181839)   # 32-bit (720, 0.0216737401150802, x^2 - x, (), [ 1, 0, 0, 0, 0 ], 1911581957, 14005, 0.92053315995181839)  # 64-bit (720, 0.0216737401150802, x^2 - x, (), [ 1, 0, 0, 0, 0 ], 912534076, 14005, 0.9205331599518184)   # 32-bit (720, 0.0216737401150802, x^2 - x, (), [ 1, 0, 0, 0, 0 ], 1911581957, 14005, 0.9205331599518184)  # 64-bit sage: initial_seed() 12345L (0.111439293741037, 539332L, 8.26785106378383, 1.3893337539828183) sage: set_random_seed(1) sage: random(), getrandbits(20), uniform(5.0, 10.0), normalvariate(0, 1) (0.82940228518742587, 624859L, 5.77894484361117, -0.42013668263087578) (0.8294022851874259, 624859L, 5.77894484361117, -0.4201366826308758) sage: set_random_seed(0) sage: random(), getrandbits(20), uniform(5.0, 10.0), normalvariate(0, 1) (0.111439293741037, 539332L, 8.26785106378383, 1.3893337539828183) sage: set_random_seed(0) sage: r1 = rtest(); r1 (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.96619117347084138)  # 32-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.96619117347084138)  # 64-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.9661911734708414)  # 32-bit (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.9661911734708414)  # 64-bit sage: r2 = rtest(); r2 (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 14082860, 1271, 0.001767155077382232)  # 32-bit (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 53231108, 1271, 0.001767155077382232)  # 64-bit sage: r1 == rtest() True sage: with seed(1): rtest() (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.83350776541997362)  # 64-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.8335077654199736)  # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.8335077654199736)  # 64-bit sage: r2m = rtest(); r2m (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 14082860, 19769, 0.001767155077382232)  # 32-bit (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 53231108, 19769, 0.001767155077382232)  # 64-bit sage: with seed(1): ...       rtest(); ...       rtest(); (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit (138, -0.247578366457583, 2*x - 24, (), [ 1, 1, 1, 0, 1 ], 1966097838, 10234, 0.0033332230808060803)       # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 807447831, 60359, 0.83350776541997362)   # 64-bit (138, -0.247578366457583, 2*x - 24, (), [ 1, 1, 1, 0, 1 ], 1010791326, 10234, 0.0033332230808060803)       # 64-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.8335077654199736)  # 32-bit (138, -0.247578366457583, 2*x - 24, (), [ 1, 1, 1, 0, 1 ], 1966097838, 10234, 0.0033332230808060803)      # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 807447831, 60359, 0.8335077654199736)   # 64-bit (138, -0.247578366457583, 2*x - 24, (), [ 1, 1, 1, 0, 1 ], 1010791326, 10234, 0.0033332230808060803)      # 64-bit sage: r2m == rtest() True ... finally: ...       ctx.__exit__(None, None, None) (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.83350776541997362)  # 64-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.8335077654199736)  # 32-bit (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.8335077654199736)  # 64-bit False sage: r2m == rtest() True
• ## sage/modules/free_module_element.pyx

diff --git a/sage/modules/free_module_element.pyx b/sage/modules/free_module_element.pyx
 a sage: type(vec) sage: answers [(0.5, 5.5511151231257843e-15, 21, 0), (0.3333333333333..., 3.7007434154171903e-15, 21, 0), (0.45969769413186..., 5.1036696439228408e-15, 21, 0)] [(0.5, 5.551115123125784e-15, 21, 0), (0.3333333333333..., 3.70074341541719e-15, 21, 0), (0.45969769413186..., 5.103669643922841e-15, 21, 0)] sage: r=vector([t,0,1], sparse=True) sage: r.nintegral(t,0,1) ((0.5, 0.0, 1.0), {0: (0.5, 5.5511151231257843e-15, 21, 0), 2: (1.0, 1.11022302462515...e-14, 21, 0)}) ((0.5, 0.0, 1.0), {0: (0.5, 5.551115123125784e-15, 21, 0), 2: (1.0, 1.11022302462515...e-14, 21, 0)}) """ # If Cython supported lambda functions, we would just do
• ## sage/numerical/optimize.py

diff --git a/sage/numerical/optimize.py b/sage/numerical/optimize.py
 a sage: R. = QQ[] sage: f = (x+17)*(x-3)*(x-1/8)^3 sage: find_root(f, 0,4) 2.9999999999999951 2.999999999999995 sage: find_root(f, 0,1)  # note -- precision of answer isn't very good on some machines. 0.124999... sage: find_root(f, -20,-10)
• ## sage/plot/colors.py

diff --git a/sage/plot/colors.py b/sage/plot/colors.py
 a sage: html_to_float('#fff') (1.0, 1.0, 1.0) sage: html_to_float('#abcdef') (0.6705882352941176, 0.80392156862745101, 0.93725490196078431) (0.6705882352941176, 0.803921568627451, 0.9372549019607843) sage: html_to_float('#123xyz') Traceback (most recent call last): ... sage: from sage.plot.colors import rgbcolor sage: rgbcolor(Color(0.25, 0.4, 0.9)) (0.25, 0.40000000000000002, 0.90000000000000002) (0.25, 0.4, 0.9) sage: rgbcolor('purple') (0.50196078431372548, 0.0, 0.50196078431372548) (0.5019607843137255, 0.0, 0.5019607843137255) sage: rgbcolor('#fa0') (1.0, 0.66666666666666663, 0.0) (1.0, 0.6666666666666666, 0.0) sage: rgbcolor('#ffffff') (1.0, 1.0, 1.0) sage: rgbcolor((1,1/2,1/3)) (1.0, 0.5, 0.33333333333333331) (1.0, 0.5, 0.3333333333333333) sage: rgbcolor([1,1/2,1/3]) (1.0, 0.5, 0.33333333333333331) (1.0, 0.5, 0.3333333333333333) sage: rgbcolor((1,1,1), space='hsv') (1.0, 0.0, 0.0) sage: rgbcolor((0.5,0.75,1), space='hls') (0.5, 0.99999999999999989, 1.0) (0.5, 0.9999999999999999, 1.0) sage: rgbcolor((0.5,1.0,0.75), space='hsl') (0.5, 0.99999999999999989, 1.0) (0.5, 0.9999999999999999, 1.0) sage: rgbcolor([1,2,255])   # WARNING -- numbers are reduced mod 1!! (1.0, 0.0, 0.0) sage: rgbcolor('#abcd') EXAMPLES:: sage: Color('purple') RGB color (0.50196078431372548, 0.0, 0.50196078431372548) RGB color (0.5019607843137255, 0.0, 0.5019607843137255) sage: Color('#8000ff') RGB color (0.50196078431372548, 0.0, 1.0) RGB color (0.5019607843137255, 0.0, 1.0) sage: Color(0.5,0,1) RGB color (0.5, 0.0, 1.0) sage: Color(0.5, 1.0, 1, space='hsv') RGB color (0.0, 1.0, 1.0) sage: Color(0.25, 0.5, 0.5, space='hls') RGB color (0.50000000000000011, 0.75, 0.25) RGB color (0.5000000000000001, 0.75, 0.25) sage: Color(1, 0, 1/3, space='hsl') RGB color (0.33333333333333331, 0.33333333333333331, 0.33333333333333331) RGB color (0.3333333333333333, 0.3333333333333333, 0.3333333333333333) sage: from sage.plot.colors import chocolate sage: Color(chocolate) RGB color (0.82352941176470584, 0.41176470588235292, 0.11764705882352941) RGB color (0.8235294117647058, 0.4117647058823529, 0.11764705882352941) """ if g is None and b is None: self.__rgb = rgbcolor(r) EXAMPLES:: sage: Color('#8000ff').__repr__() 'RGB color (0.50196078431372548, 0.0, 1.0)' 'RGB color (0.5019607843137255, 0.0, 1.0)' sage: Color(1, 0.5, 1/16, space='hsl').__repr__() 'RGB color (0.09375, 0.03125, 0.03125)' """ sage: red.blend(blue, fraction=1.0) RGB color (0.0, 0.0, 1.0) sage: lime.blend((0.3, 0.5, 0.7)) RGB color (0.14999999999999999, 0.75, 0.34999999999999998) RGB color (0.15, 0.75, 0.35) sage: blue.blend(blue) RGB color (0.0, 0.0, 1.0) sage: red.blend(lime, fraction=0.3) RGB color (0.69999999999999996, 0.29999999999999999, 0.0) RGB color (0.7, 0.3, 0.0) sage: blue.blend((0.0, 0.9, 0.2), fraction=0.2) RGB color (0.0, 0.18000000000000002, 0.84000000000000008) RGB color (0.0, 0.18000000000000002, 0.8400000000000001) sage: red.blend(0.2) Traceback (most recent call last): ... ... TypeError: 0.100000000000000 must be a Color or float-convertible 3-tuple/list sage: c2 + [0.5, 0.2, 0.9] RGB color (0.57199999999999995, 0.44999999999999996, 0.66000000000000003) RGB color (0.572, 0.44999999999999996, 0.66) sage: c1.__add__(red).__add__((0.9, 0.2, 1/3)) RGB color (0.72500000000000009, 0.22500000000000001, 0.3666666666666667) RGB color (0.7250000000000001, 0.225, 0.3666666666666667) sage: c1 + c2 RGB color (0.37199999999999994, 0.59999999999999998, 0.60999999999999999) RGB color (0.37199999999999994, 0.6, 0.61) """ return self.blend(right) sage: from sage.plot.colors import olive, orchid sage: olive + orchid RGB color (0.67843137254901964, 0.47058823529411764, 0.41960784313725491) RGB color (0.6784313725490196, 0.47058823529411764, 0.4196078431372549) sage: d1 = Color(0.1, 0.5, 0.8, space='hls'); d2 = Color(0.2, 0.4, 0.7) sage: [0.5, 0.2, 0.9] + d2 RGB color (0.34999999999999998, 0.30000000000000004, 0.80000000000000004) RGB color (0.35, 0.30000000000000004, 0.8) sage: 0.1 + d1 Traceback (most recent call last): ... TypeError: 0.100000000000000 must be a Color or float-convertible 3-tuple/list sage: d2.__radd__(Color('brown')).__radd__((0.9, 0.2, 1/3)) RGB color (0.66176470588235303, 0.2411764705882353, 0.38284313725490193) RGB color (0.661764705882353, 0.2411764705882353, 0.38284313725490193) """ return self + left RGB color (0.125, 0.125, 0.0) sage: from sage.plot.colors import cyan, grey, indianred sage: cyan * 0.3 + grey * 0.1 + indianred * 0.6 RGB color (0.25372549019607843, 0.19578431372549021, 0.19578431372549021) RGB color (0.25372549019607843, 0.1957843137254902, 0.1957843137254902) sage: indianred.__mul__(42) RGB color (0.76470588235294201, 0.15294117647058769, 0.15294117647058769) RGB color (0.764705882352942, 0.1529411764705877, 0.1529411764705877) """ right = float(right) return Color([x * right for x in self.__rgb]) sage: from sage.plot.colors import aqua, cornsilk, tomato sage: 0.3 * aqua RGB color (0.0, 0.29999999999999999, 0.29999999999999999) RGB color (0.0, 0.3, 0.3) sage: Color('indianred').__rmul__(42) RGB color (0.76470588235294201, 0.15294117647058769, 0.15294117647058769) RGB color (0.764705882352942, 0.1529411764705877, 0.1529411764705877) """ return self * left sage: yellow.__div__(4) RGB color (0.25, 0.25, 0.0) sage: (papayawhip + Color(0.5, 0.5, 0.1) + yellow) / 3.0 RGB color (0.29166666666666663, 0.28643790849673201, 0.077941176470588236) RGB color (0.29166666666666663, 0.286437908496732, 0.07794117647058824) sage: vector((papayawhip / 2).rgb()) == vector((papayawhip * 0.5).rgb()) True sage: yellow.__div__(1/4) sage: r 0.11764705882352941 sage: g 0.56470588235294117 0.5647058823529412 sage: b 1.0 sage: vector(maroon) == vector(Color(maroon)) == vector(Color('maroon')) sage: from sage.plot.colors import crimson, midnightblue sage: Color('#badfad')[0] 0.72941176470588232 0.7294117647058823 sage: (crimson[0], crimson[1], crimson[2]) == crimson.rgb() True sage: midnightblue[2] == midnightblue[-1] EXAMPLES:: sage: Color(0.3, 0.5, 0.7).rgb() (0.29999999999999999, 0.5, 0.69999999999999996) (0.3, 0.5, 0.7) sage: Color('#8000ff').rgb() (0.50196078431372548, 0.0, 1.0) (0.5019607843137255, 0.0, 1.0) sage: from sage.plot.colors import orange sage: orange.rgb() (1.0, 0.6470588235294118, 0.0) sage: Color('magenta').rgb() (1.0, 0.0, 1.0) sage: Color(1, 0.7, 0.9, space='hsv').rgb() (0.90000000000000002, 0.27000000000000007, 0.27000000000000007) (0.9, 0.2700000000000001, 0.2700000000000001) """ return self.__rgb EXAMPLES:: sage: Color(0.3, 0.5, 0.7, space='hls').hls() (0.30000000000000004, 0.5, 0.69999999999999996) (0.30000000000000004, 0.5, 0.7) sage: Color(0.3, 0.5, 0.7, space='hsl').hls() (0.30000000000000004, 0.69999999999999996, 0.50000000000000011) (0.30000000000000004, 0.7, 0.5000000000000001) sage: Color('#aabbcc').hls() (0.58333333333333337, 0.73333333333333339, 0.25000000000000017) (0.5833333333333334, 0.7333333333333334, 0.25000000000000017) sage: from sage.plot.colors import orchid sage: orchid.hls() (0.83962264150943389, 0.64705882352941169, 0.58888888888888891) (0.8396226415094339, 0.6470588235294117, 0.5888888888888889) """ return tuple(map(float, rgb_to_hls(*self.__rgb))) (0.0, 1.0, 0.5) sage: from sage.plot.colors import orchid sage: orchid.hsl() (0.83962264150943389, 0.58888888888888891, 0.64705882352941169) (0.8396226415094339, 0.5888888888888889, 0.6470588235294117) sage: Color('#aabbcc').hsl() (0.58333333333333337, 0.25000000000000017, 0.73333333333333339) (0.5833333333333334, 0.25000000000000017, 0.7333333333333334) """ h, l, s = tuple(map(float, rgb_to_hls(*self.__rgb))) return (h, s, l) sage: Color(1,1,1).hsv() (0.0, 0.0, 1.0) sage: Color('gray').hsv() (0.0, 0.0, 0.50196078431372548) (0.0, 0.0, 0.5019607843137255) """ return tuple(map(float, rgb_to_hsv(*self.__rgb))) sage: from sage.plot.colors import khaki sage: khaki.lighter() RGB color (0.96078431372549034, 0.934640522875817, 0.69934640522875824) RGB color (0.9607843137254903, 0.934640522875817, 0.6993464052287582) sage: Color('white').lighter().darker() RGB color (0.66666666666666674, 0.66666666666666674, 0.66666666666666674) RGB color (0.6666666666666667, 0.6666666666666667, 0.6666666666666667) sage: Color('#abcdef').lighter(1/4) RGB color (0.75294117647058822, 0.85294117647058831, 0.95294117647058818) RGB color (0.7529411764705882, 0.8529411764705883, 0.9529411764705882) sage: Color(1, 0, 8/9, space='hsv').lighter() RGB color (0.92592592592592604, 0.92592592592592604, 0.92592592592592604) RGB color (0.925925925925926, 0.925925925925926, 0.925925925925926) """ return self.blend((1.0, 1.0, 1.0), fraction) sage: vector(black.darker().rgb()) == vector(black.rgb()) True sage: Color(0.4, 0.6, 0.8).darker(0.1) RGB color (0.36000000000000004, 0.54000000000000004, 0.72000000000000008) RGB color (0.36000000000000004, 0.54, 0.7200000000000001) sage: Color(.1,.2,.3,space='hsl').darker() RGB color (0.24000000000000002, 0.20800000000000002, 0.16) """ (0.0, 0.40000000000000036, 1.0) sage: from sage.plot.colors import royalblue sage: royalblue RGB color (0.25490196078431371, 0.41176470588235292, 0.88235294117647056) RGB color (0.2549019607843137, 0.4117647058823529, 0.8823529411764706) sage: hue(*royalblue.hsv()) (0.25490196078431371, 0.41176470588235292, 0.88235294117647056) (0.2549019607843137, 0.4117647058823529, 0.8823529411764706) sage: hue(.5, .5, .5) (0.25, 0.5, 0.5) sage: rainbow(7) ['#ff0000', '#ffda00', '#48ff00', '#00ff91', '#0091ff', '#4800ff', '#ff00da'] sage: rainbow(7, 'rgbtuple') [(1.0, 0.0, 0.0), (1.0, 0.8571428571428571, 0.0), (0.28571428571428581, 1.0, 0.0), (0.0, 1.0, 0.57142857142857117), (0.0, 0.57142857142857162, 1.0), (0.2857142857142847, 0.0, 1.0), (1.0, 0.0, 0.85714285714285765)] [(1.0, 0.0, 0.0), (1.0, 0.8571428571428571, 0.0), (0.2857142857142858, 1.0, 0.0), (0.0, 1.0, 0.5714285714285712), (0.0, 0.5714285714285716, 1.0), (0.2857142857142847, 0.0, 1.0), (1.0, 0.0, 0.8571428571428577)] AUTHORS:
• ## sage/plot/misc.py

diff --git a/sage/plot/misc.py b/sage/plot/misc.py
 a sage: sage.plot.misc.setup_for_eval_on_grid([x+y], [(x,-1,1),(y,-2,2)]) ((,), [(-1.0, 1.0, 2.0), (-2.0, 2.0, 4.0)]) sage: sage.plot.misc.setup_for_eval_on_grid(x+y, [(x,-1,1),(y,-1,1)], plot_points=[4,9]) (, [(-1.0, 1.0, 0.66666666666666663), (-1.0, 1.0, 0.25)]) (, [(-1.0, 1.0, 0.6666666666666666), (-1.0, 1.0, 0.25)]) sage: sage.plot.misc.setup_for_eval_on_grid(x+y, [(x,-1,1),(y,-1,1)], plot_points=[4,9,10]) Traceback (most recent call last): ...
• ## sage/plot/plot.py

diff --git a/sage/plot/plot.py b/sage/plot/plot.py
• ## sage/plot/plot3d/base.pyx

diff --git a/sage/plot/plot3d/base.pyx b/sage/plot/plot3d/base.pyx
 a sage: G.scale(4).bounding_box() ((-2.0, -2.0, -2.0), (2.0, 2.0, 2.0)) sage: G.rotateZ(pi/4).bounding_box() ((-0.70710678118654746, -0.70710678118654746, -0.5), (0.70710678118654746, 0.70710678118654746, 0.5)) ((-0.7071067811865475, -0.7071067811865475, -0.5), (0.7071067811865475, 0.7071067811865475, 0.5)) """ try: return self._bounding_box
• ## sage/plot/plot3d/index_face_set.pyx

diff --git a/sage/plot/plot3d/index_face_set.pyx b/sage/plot/plot3d/index_face_set.pyx
 a sage: x,y=var('x,y') sage: p=plot3d(sqrt(sin(x)*sin(y)), (x,0,2*pi),(y,0,2*pi)) sage: p.bounding_box() ((0.0, 0.0, -0.0), (6.2831853071795862, 6.2831853071795862, 0.9991889981715697)) ((0.0, 0.0, -0.0), (6.283185307179586, 6.283185307179586, 0.9991889981715697)) """ if self.vcount == 0: return ((0,0,0),(0,0,0))
• ## sage/plot/plot3d/parametric_surface.pyx

diff --git a/sage/plot/plot3d/parametric_surface.pyx b/sage/plot/plot3d/parametric_surface.pyx
 a sage: from sage.plot.plot3d.parametric_surface import MobiusStrip sage: M = MobiusStrip(7,3,2) sage: M.bounding_box() ((-10.0, -7.53907349250478..., -2.9940801852848145), (10.0, 7.5390734925047846, 2.9940801852848145)) ((-10.0, -7.53907349250478..., -2.9940801852848145), (10.0, 7.53907349250478..., 2.9940801852848145)) """ # We must triangulate before computing the bounding box; otherwise # we'll get an empty bounding box, as the bounding box is computed
• ## sage/plot/plot3d/shapes.pyx

diff --git a/sage/plot/plot3d/shapes.pyx b/sage/plot/plot3d/shapes.pyx
 a sage: from sage.plot.plot3d.shapes import Sphere sage: Sphere(1).get_grid(100) ([-10.0, ..., 0.0, ..., 10.0], [0.0, ..., 3.1415926535897931, ..., 0.0]) [0.0, ..., 3.141592653589793, ..., 0.0]) """ cdef int K, u_res, v_res u_res = min(max(int(M_PI*self.radius/ds), 6), 20) sage: from sage.plot.plot3d.shapes import Torus sage: Torus(2, 1).get_grid(100) ([0.0, -1.047..., -3.1415926535897931, ..., 0.0], [0.0, 1.047..., 3.1415926535897931, ..., 0.0]) ([0.0, -1.047..., -3.141592653589793, ..., 0.0], [0.0, 1.047..., 3.141592653589793, ..., 0.0]) """ cdef int k, u_divs, v_divs u_divs = min(max(int(4*M_PI * self.R/ds), 6), 37)
• ## sage/plot/plot3d/shapes2.py

diff --git a/sage/plot/plot3d/shapes2.py b/sage/plot/plot3d/shapes2.py
 a sage: from sage.plot.plot3d.shapes2 import Line sage: L = Line([(i,i^2-1,-2*ln(i)) for i in [10,20,30]]) sage: L.bounding_box() ((10.0, 99.0, -6.8023947633243109), (30.0, 899.0, -4.6051701859880918)) ((10.0, 99.0, -6.802394763324311), (30.0, 899.0, -4.605170185988092)) """ try: return self.__bounding_box
• ## sage/rings/complex_number.pyx

diff --git a/sage/rings/complex_number.pyx b/sage/rings/complex_number.pyx
 a sage: a.__abs__() 2.23606797749979 sage: float(sqrt(2^2 + 1^1)) 2.2360679774997898 2.23606797749979 ::
• ## sage/rings/contfrac.py

diff --git a/sage/rings/contfrac.py b/sage/rings/contfrac.py
 a sage: a = CFF(-17/389); a [-1, 1, 21, 1, 7, 2] sage: float(a) -0.043701799485861177 -0.04370179948586118 """ return float(self._rational_()) sage: b.value() 4508361/9825745 sage: float(b.value()^2 - a) -5.4514925256726876e-16 -5.451492525672688e-16 sage: b = a.sqrt(prec=100); b [0, 2, 5, 1, 1, 2, 1, 16, 1, 2, 1, 1, 5, 4, 5, 1, 1, 2, 1, 16, 1, 2, 1, 1, 5, 4, 5, 1, 1, 2, 1, 16, 1, 2, 1, 1, 5] sage: b^2
• ## sage/rings/integer.pyx

diff --git a/sage/rings/integer.pyx b/sage/rings/integer.pyx
 a sage: n = Integer(17); float(n) 17.0 sage: n = Integer(902834098234908209348209834092834098); float(n) 9.0283409823490813e+35 9.028340982349081e+35 sage: n = Integer(-57); float(n) -57.0 sage: n.__float__()
• ## sage/rings/number_field/totallyreal.pyx

diff --git a/sage/rings/number_field/totallyreal.pyx b/sage/rings/number_field/totallyreal.pyx
 a EXAMPLES:: sage: [sage.rings.number_field.totallyreal.odlyzko_bound_totallyreal(n) for n in range(1,5)] [1.0, 2.2229999999999999, 3.6099999999999999, 5.0670000000000002] [1.0, 2.223, 3.61, 5.067] AUTHORS:
• ## sage/rings/polynomial/real_roots.pyx

diff --git a/sage/rings/polynomial/real_roots.pyx b/sage/rings/polynomial/real_roots.pyx
 a sage: from sage.rings.polynomial.real_roots import * sage: max_abs_doublevec(vector(RDF, [0.1, -0.767, 0.3, 0.693])) 0.76700000000000002 0.767 """ cdef numpy.ndarray[double, ndim=1] cd = c._vector_numpy
• ## sage/rings/qqbar.py

diff --git a/sage/rings/qqbar.py b/sage/rings/qqbar.py
 a ...               return None ...       return map(convert_test, all_vals) sage: convert_test_all(float) [42.0, 3.1428571428571432, 1.6180339887498949, -13.0, 1.6181818181818182, -2.6457513110645907, None] [42.0, 3.1428571428571432, 1.618033988749895, -13.0, 1.6181818181818182, -2.6457513110645907, None] sage: convert_test_all(complex) [(42+0j), (3.1428571428571432+0j), (1.6180339887498949+0j), (-13+0j), (1.6181818181818182+0j), (-2.6457513110645907+0j), (0.30901699437494745+0.95105651629515364j)] [(42+0j), (3.1428571428571432+0j), (1.618033988749895+0j), (-13+0j), (1.6181818181818182+0j), (-2.6457513110645907+0j), (0.30901699437494745+0.9510565162951536j)] sage: convert_test_all(RDF) [42.0, 3.14285714286, 1.61803398875, -13.0, 1.61818181818, -2.64575131106, None] sage: convert_test_all(CDF) EXAMPLES:: sage: QQbar(sqrt(2)).__float__() 1.4142135623730949 1.414213562373095 sage: float(QQbar(-22/7)) -3.1428571428571432 sage: float(QQbar.zeta(3)) EXAMPLES:: sage: QQbar(sqrt(2)).__complex__() (1.4142135623730949+0j) (1.414213562373095+0j) sage: complex(QQbar.zeta(3)) (-0.5+0.8660254037844386j) """ EXAMPLES:: sage: AA(golden_ratio).__float__() 1.6180339887498949 1.618033988749895 sage: float(AA(sqrt(11))) 3.3166247903553998 3.3166247903554 """ return float(RR(self))
• ## sage/rings/quotient_ring_element.py

diff --git a/sage/rings/quotient_ring_element.py b/sage/rings/quotient_ring_element.py
 a sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) sage: float(S(2/3)) 0.66666666666666663 0.6666666666666666 sage: float(a) Traceback (most recent call last): ...
• ## sage/rings/real_lazy.pyx

diff --git a/sage/rings/real_lazy.pyx b/sage/rings/real_lazy.pyx
 a sage: from sage.rings.real_lazy import LazyConstant sage: a = LazyConstant(RLF, 'pi') sage: float(a) 3.1415926535897931 3.141592653589793 """ interval_field = self._parent.interval_field() return self.eval(interval_field._middle_field())
• ## sage/rings/real_mpfr.pyx

diff --git a/sage/rings/real_mpfr.pyx b/sage/rings/real_mpfr.pyx
 a EXAMPLES:: sage: RR(pi).__float__() 3.1415926535897931 3.141592653589793 sage: type(RR(pi).__float__()) """ EXAMPLES:: sage: RR(pi).__complex__() (3.1415926535897931+0j) (3.141592653589793+0j) sage: type(RR(pi).__complex__()) """
• ## sage/schemes/elliptic_curves/ell_rational_field.py

diff --git a/sage/schemes/elliptic_curves/ell_rational_field.py b/sage/schemes/elliptic_curves/ell_rational_field.py
 a sage: F Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 + 1376*x - 130 over Rational Field sage: F.CPS_height_bound() 0.65551583769728516 0.6555158376972852 IMPLEMENTATION: Call the corresponding mwrank C++ library function.  Note that sage: E=EllipticCurve('37a1') sage: E.silverman_height_bound() 4.8254007581809182 4.825400758180918 sage: E.silverman_height_bound(algorithm='mwrank') 4.8254007581809182 4.825400758180918 sage: E.CPS_height_bound() 0.16397076103046915 """
• ## sage/stats/basic_stats.py

diff --git a/sage/stats/basic_stats.py b/sage/stats/basic_stats.py
 a 2.5 sage: x = finance.TimeSeries([1..100]) sage: variance(x) 841.66666666666663 841.6666666666666 sage: variance(x, bias=True) 833.25 sage: class MyClass:
• ## sage/stats/hmm/chmm.pyx

diff --git a/sage/stats/hmm/chmm.pyx b/sage/stats/hmm/chmm.pyx
 a of states produced obs:: sage: m.viterbi(obs) ([1, 0, 1, 0, 1, 1, 0, 1, 0, 1], -16.677382701707881) ([1, 0, 1, 0, 1, 1, 0, 1, 0, 1], -16.67738270170788) We use the Baum-Welch iterative algorithm to find another model for which our observation sequence is more likely:: sage: m[0] (1.0, 0.5) sage: m[1] (-2.0, 0.29999999999999999) (-2.0, 0.3) sage: m[-1] (-2.0, 0.29999999999999999) (-2.0, 0.3) sage: m[3] Traceback (most recent call last): ... sage: m = hmm.GaussianHiddenMarkovModel([[.1,.9],[.5,.5]], [(1,.5), (-1,3)], [.1,.9]) sage: m.log_likelihood([1,1,1]) -4.2978807660724856 -4.297880766072486 sage: set_random_seed(0); s = m.sample(20) sage: m.log_likelihood(s) -40.115714129484... sage: m.viterbi([-2,-1,.1,0.1]) ([1, 1, 0, 1], -9.61823698847639...) sage: m.viterbi([-2,-1,.1,0.3]) ([1, 1, 1, 0], -9.5660236533785135) ([1, 1, 1, 0], -9.566023653378513) """ cdef TimeSeries _obs if not isinstance(obs, TimeSeries): sage: m = hmm.GaussianHiddenMarkovModel([[.1,.9],[.5,.5]], [(1,.5), (-1,3)], [.1,.9]) sage: m.log_likelihood([-2,-1,.1,0.1]) -8.8582822159862751 -8.858282215986275 sage: m.baum_welch([-2,-1,.1,0.1]) (22.164539478647512, 8) sage: m.log_likelihood([-2,-1,.1,0.1])
• ## sage/stats/hmm/distributions.pyx

diff --git a/sage/stats/hmm/distributions.pyx b/sage/stats/hmm/distributions.pyx
 a sage: P = hmm.GaussianMixtureDistribution([(.3,1,2),(.7,-1,1)]); P 0.3*N(1.0,2.0) + 0.7*N(-1.0,1.0) sage: P[0] (0.29999999999999999, 1.0, 2.0) (0.3, 1.0, 2.0) sage: P.is_fixed() False sage: P.fix(1) sage: P = hmm.GaussianMixtureDistribution([(.2,-10,.5),(.6,1,1),(.2,20,.5)]) sage: P[0] (0.20000000000000001, -10.0, 0.5) (0.2, -10.0, 0.5) sage: P[2] (0.20000000000000001, 20.0, 0.5) (0.2, 20.0, 0.5) sage: [-1] [-1] sage: P[-1] (0.20000000000000001, 20.0, 0.5) (0.2, 20.0, 0.5) sage: P[3] Traceback (most recent call last): ... sage: P = hmm.GaussianMixtureDistribution([(.2,-10,.5),(.6,1,1),(.2,20,.5)]) sage: P.sample() 19.658243610875129 19.65824361087513 sage: P.sample(1) [-10.4683] sage: P.sample(5) sage: P = hmm.GaussianMixtureDistribution([(.2,-10,.5),(.6,1,1),(.2,20,.5)]) sage: P.prob_m(.5, 0) 2.760811768050888...e-97 2.7608117680508...e-97 sage: P.prob_m(.5, 1) 0.21123919605857971 sage: P.prob_m(.5, 2)
• ## sage/stats/hmm/hmm.pyx

diff --git a/sage/stats/hmm/hmm.pyx b/sage/stats/hmm/hmm.pyx
 a sage: m.log_likelihood([0,1,0,1,0,1]) -4.66693474691329... sage: m.viterbi([0,1,0,1,0,1]) ([1, 1, 1, 1, 1, 1], -5.3788328422087481) ([1, 1, 1, 1, 1, 1], -5.378832842208748) sage: m.baum_welch([0,1,0,1,0,1]) (0.0, 22) sage: m sage: m.log_likelihood([0, 1, 0, 1, 1, 0, 1, 0, 0, 0]) -7.3301308009370825 sage: m.log_likelihood([0, 1, 0, 1, 1, 0, 1, 0, 0, 0], scale=False) -7.3301308009370816 -7.330130800937082 sage: m.log_likelihood([]) 0.0 sage: m = hmm.DiscreteHiddenMarkovModel([[0.4,0.6],[0.1,0.9]], [[0.1,0.9],[0.5,0.5]], [.2,.8]) sage: m.log_likelihood([0,1]*1000, scale=True) -1433.8206666527281 -1433.820666652728 sage: m.log_likelihood([0,1]*1000, scale=False) -inf """ non-scaled algorithm:: sage: m._forward_scale(stats.IntList([0,1]*1000)) -1433.8206666527281 -1433.820666652728 sage: m._forward(stats.IntList([0,1]*1000)) -inf sage: set_random_seed(0); v = m.sample(1000) sage: m._forward_scale(v) -686.87531893650555 -686.8753189365056 """ # This is just like self._forward(obs) above, except at every step of the # algorithm, we rescale the vector alpha so that the sum of sage: m = hmm.DiscreteHiddenMarkovModel([[0.1,0.9],[0.9,0.1]], [[1,0],[0,1]], [.2,.8]) sage: m._viterbi(stats.IntList([1]*5)) ([1, 1, 1, 1, 1], -9.4334839232903924) ([1, 1, 1, 1, 1], -9.433483923290392) sage: m._viterbi(stats.IntList([0]*5)) ([0, 0, 0, 0, 0], -10.819778284410283) sage: m = hmm.DiscreteHiddenMarkovModel([[0.1,0.9],[0.9,0.1]], [[.5,.5],[0,1]], [.2,.8]) sage: m._viterbi_scale(stats.IntList([1]*10)) ([1, 0, 1, 0, 1, 0, 1, 0, 1, 0], -4.6371240950343733) ([1, 0, 1, 0, 1, 0, 1, 0, 1, 0], -4.637124095034373) Long sequences should not overflow:: sage: m = hmm.DiscreteHiddenMarkovModel([[0.1,0.9],[0.9,0.1]], [[.5,.5],[.2,.8]], [.2,.8]) sage: set_random_seed(0); v = m.sample(100) sage: m.baum_welch(v,fix_emissions=True) (-66.986308569187742, 100) (-66.98630856918774, 100) sage: m.emission_matrix() [0.5 0.5] [0.2 0.8]
• ## sage/structure/coerce_dict.pyx

diff --git a/sage/structure/coerce_dict.pyx b/sage/structure/coerce_dict.pyx
 a sage: len(L) 1 sage: L.stats()             # min, avg, max (bucket length) (0, 0.032258064516129031, 1) (0, 0.03225806451612903, 1) sage: L.bucket_lens()       # random layout [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] sage: for i in range(1000):
• ## sage/symbolic/constants.py

diff --git a/sage/symbolic/constants.py b/sage/symbolic/constants.py
 a EXAMPLES:: sage: float(pi) 3.1415926535897931 3.141592653589793 """ return math.pi sage: grm + grm sqrt(5)+1 sage: float(grm + grm) 3.2360679774997898 3.23606797749979 """ def __init__(self, name='golden_ratio'): """ EXAMPLES:: sage: float(golden_ratio) 1.6180339887498949 1.618033988749895 sage: golden_ratio.__float__() 1.6180339887498949 1.618033988749895 """ return float(0.5)*(float(1.0)+math.sqrt(float(5.0))) sage: log2 log2 sage: float(log2) 0.69314718055994529 0.6931471805599453 sage: RR(log2) 0.693147180559945 sage: R = RealField(200); R EXAMPLES:: sage: float(log2) 0.69314718055994529 0.6931471805599453 sage: log2.__float__() 0.69314718055994529 0.6931471805599453 """ return math.log(2) EXAMPLES:: sage: float(euler_gamma) 0.57721566490153287 0.5772156649015329 """ return 0.57721566490153286060651209008 EXAMPLES:: sage: float(catalan) 0.91596559417721901 0.915965594177219 """ return 0.91596559417721901505460351493252 EXAMPLES:: sage: float(twinprime) 0.66016181584686962 0.6601618158468696 sage: twinprime.n(digits=60) 0.660161815846869573927812110014555778432623360284733413319448 EXAMPLES:: sage: float(twinprime) 0.66016181584686962 0.6601618158468696 """ return 0.66016181584686957392781211001
• ## sage/symbolic/expression.pyx

diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
 a sage: float(SR(12)) 12.0 sage: float(SR(2/3)) 0.66666666666666663 0.6666666666666666 sage: float(sqrt(SR(2))) 1.4142135623730951 sage: float(x^2 + 1) sage: cmp(sin(SR(2)), sin(SR(1))) 1 sage: float(sin(SR(2))) 0.90929742682568171 0.9092974268256817 sage: float(sin(SR(1))) 0.8414709848078965 """ sage: int(2)^x 2^x sage: float(2.3)^(x^3 - x^2 + 1/3) 2.2999999999999998^(x^3 - x^2 + 1/3) 2.3^(x^3 - x^2 + 1/3) sage: complex(1,3)^(sqrt(2)) (1+3j)^sqrt(2) """ sage: maxima('atan2(0.7,0.6)') .862170054667226... sage: float(SR(0.7).arctan2(-0.6)) 2.2794225989225669 2.279422598922567 sage: maxima('atan2(0.7,-0.6)') 2.279422598922567 sage: float(SR(-0.7).arctan2(0.6)) sage: maxima('atan2(-0.7,0.6)') -.862170054667226... sage: float(SR(-0.7).arctan2(-0.6)) -2.2794225989225669 -2.279422598922567 sage: maxima('atan2(-0.7,-0.6)') -2.279422598922567 sage: float(SR(0).arctan2(-0.6)) 3.1415926535897931 3.141592653589793 sage: maxima('atan2(0,-0.6)') 3.141592653589793 sage: float(SR(0).arctan2(0.6)) sage: SR(0.5).log().exp() 0.500000000000000 sage: math.log(0.5) -0.69314718055994529 -0.6931471805599453 sage: plot(lambda x: SR(x).log(), 0.1,10) To prevent automatic evaluation use the hold argument:: An example with a square root:: sage: f = 1 + x + sqrt(x+2); f.find_root(-2,10) -1.6180339887498949 -1.618033988749895 Some examples that Ted Kosan came up with::
• ## sage/symbolic/function.pyx

diff --git a/sage/symbolic/function.pyx b/sage/symbolic/function.pyx
 a sage: cot(0.5) #indirect doctest 1.83048772171245 sage: cot(complex(1,2)) (0.032797755533752602-0.98432922645819...j) (0.0327977555337526-0.98432922645819...j) """ if isinstance(x, (int, long)): return None sage: arctan(1) 1/4*pi sage: arctan(float(1)) 0.78539816339744828 0.7853981633974483 Precision of the result depends on the precision of the input:: sage: ff.is_pure_c() False sage: ff(1.5) 0.96610514647531076 0.9661051464753108 sage: erf(1.5) 0.966105146475311 """
• ## sage/symbolic/integration/integral.py

diff --git a/sage/symbolic/integration/integral.py b/sage/symbolic/integration/integral.py
 a sage: res.subs(y=2).n() 1.46383232641443 sage: nres = numerical_integral(f.subs(y=.5), 0.0001414, 1.); nres (-0.66951170887280698, 7.7686781108547113e-15) (-0.669511708872807, 7.768678110854711e-15) sage: res.subs(y=.5).n() -0.669511708872807
• ## sage/symbolic/pynac.pyx

diff --git a/sage/symbolic/pynac.pyx b/sage/symbolic/pynac.pyx
 a TESTS:: sage: sin(float(2)) #indirect doctest 0.90929742682568171 0.9092974268256817 sage: sin(2.) 0.909297426825682 sage: sin(2.*I) """ TESTS:: sage: cos(float(2)) #indirect doctest -0.41614683654714241 -0.4161468365471424 sage: cos(2.) -0.416146836547142 sage: cos(2.*I) sage: py_log(float(0)) -inf sage: py_log(float(-1)) 3.1415926535897931j 3.141592653589793j sage: py_log(int(1)) 0.0 sage: py_log(long(1))
• ## sage/symbolic/random_tests.py

diff --git a/sage/symbolic/random_tests.py b/sage/symbolic/random_tests.py
 a sage: B = [(1, 'B1'), (2, 'B2'), (2, 'B3')] sage: top = [(50, A, 'Group A'), (50, B, 'Group B')] sage: normalize_prob_list(top) [(0.250000000000000, 'A1', 'Group A'), (0.250000000000000, 'A2', 'Group A'), (0.10000000000000001, 'B1', 'Group B'), (0.20000000000000001, 'B2', 'Group B'), (0.20000000000000001, 'B3', 'Group B')] [(0.250000000000000, 'A1', 'Group A'), (0.250000000000000, 'A2', 'Group A'), (0.1, 'B1', 'Group B'), (0.2, 'B2', 'Group B'), (0.2, 'B3', 'Group B')] """ if len(pl) == 0: return pl
• ## sage/symbolic/relation.py

diff --git a/sage/symbolic/relation.py b/sage/symbolic/relation.py
 a sage: (x == sin(x)).find_root(-2,2) 0.0 sage: (x^5 + 3*x + 2 == 0).find_root(-2,2,x) -0.63283452024215225 -0.6328345202421523 sage: (cos(x) == sin(x)).find_root(10,20) 19.634954084936208