diff --git a/src/doc/en/developer/coding_in_other.rst b/src/doc/en/developer/coding_in_other.rst index 6693aed5b8b..e7891af92d7 100644 --- a/src/doc/en/developer/coding_in_other.rst +++ b/src/doc/en/developer/coding_in_other.rst @@ -106,8 +106,7 @@ convert output from PARI to Sage objects: def frobenius(self, flag=0, var='x'): """ - Return the Frobenius form (rational canonical form) of this - matrix. + Return the Frobenius form (rational canonical form) of this matrix. INPUT: @@ -125,7 +124,7 @@ convert output from PARI to Sage objects: - ``var`` -- a string (default: 'x') - ALGORITHM: uses PARI's matfrobenius() + ALGORITHM: uses PARI's :pari:`matfrobenius` EXAMPLES:: @@ -143,15 +142,15 @@ convert output from PARI to Sage objects: raise ArithmeticError("frobenius matrix of non-square matrix not defined.") v = self.__pari__().matfrobenius(flag) - if flag==0: + if flag == 0: return self.matrix_space()(v.python()) - elif flag==1: + elif flag == 1: r = PolynomialRing(self.base_ring(), names=var) retr = [] for f in v: retr.append(eval(str(f).replace("^","**"), {'x':r.gen()}, r.gens_dict())) return retr - elif flag==2: + elif flag == 2: F = matrix_space.MatrixSpace(QQ, self.nrows())(v[0].python()) B = matrix_space.MatrixSpace(QQ, self.nrows())(v[1].python()) return F, B @@ -212,11 +211,13 @@ object. Return the Cartan matrix of given Chevalley type and rank. INPUT: - type -- a Chevalley letter name, as a string, for - a family type of simple Lie algebras - rank -- an integer (legal for that type). - EXAMPLES: + - type -- a Chevalley letter name, as a string, for + a family type of simple Lie algebras + - rank -- an integer (legal for that type). + + EXAMPLES:: + sage: cartan_matrix("A",5) [ 2 -1 0 0 0] [-1 2 -1 0 0] @@ -227,12 +228,11 @@ object. [ 2 -1] [-3 2] """ - - L = gap.SimpleLieAlgebra('"%s"'%type, rank, 'Rationals') + L = gap.SimpleLieAlgebra('"%s"' % type, rank, 'Rationals') R = L.RootSystem() sM = R.CartanMatrix() ans = eval(str(sM)) - MS = MatrixSpace(QQ, rank) + MS = MatrixSpace(QQ, rank) return MS(ans) The output ``ans`` is a Python list. The last two lines convert that @@ -460,50 +460,51 @@ just that. .. CODE-BLOCK:: python - def points_parser(string_points,F): + def points_parser(string_points, F): """ This function will parse a string of points of X over a finite field F returned by Singular's NSplaces command into a Python list of points with entries from F. - EXAMPLES: + EXAMPLES:: + sage: F = GF(5) sage: points_parser(L,F) ((0, 1, 0), (3, 4, 1), (0, 0, 1), (2, 3, 1), (3, 1, 1), (2, 2, 1)) """ - Pts=[] - n=len(L) - #start block to compute a pt - L1=L - while len(L1)>32: - idx=L1.index(" ") - pt=[] - ## start block1 for compute pt - idx=L1.index(" ") - idx2=L1[idx:].index("\n") - L2=L1[idx:idx+idx2] + Pts = [] + n = len(L) + # start block to compute a pt + L1 = L + while len(L1) > 32: + idx =L1.index(" ") + pt = [] + # start block1 for compute pt + idx = L1.index(" ") + idx2 = L1[idx:].index("\n") + L2 = L1[idx:idx+idx2] pt.append(F(eval(L2))) # end block1 to compute pt - L1=L1[idx+8:] # repeat block 2 more times - ## start block2 for compute pt - idx=L1.index(" ") - idx2=L1[idx:].index("\n") - L2=L1[idx:idx+idx2] + L1 = L1[idx+8:] # repeat block 2 more times + # start block2 for compute pt + idx = L1.index(" ") + idx2 = L1[idx:].index("\n") + L2 = L1[idx:idx+idx2] pt.append(F(eval(L2))) # end block2 to compute pt L1=L1[idx+8:] # repeat block 1 more time - ## start block3 for compute pt + # start block3 for compute pt idx=L1.index(" ") if "\n" in L1[idx:]: - idx2=L1[idx:].index("\n") + idx2 = L1[idx:].index("\n") else: - idx2=len(L1[idx:]) - L2=L1[idx:idx+idx2] + idx2 = len(L1[idx:]) + L2 = L1[idx:idx+idx2] pt.append(F(eval(L2))) # end block3 to compute pt - #end block to compute a pt + # end block to compute a pt Pts.append(tuple(pt)) # repeat until no more pts - L1=L1[idx+8:] # repeat block 2 more times + L1 = L1[idx+8:] # repeat block 2 more times return tuple(Pts) Now it is an easy matter to put these ingredients together into a Sage @@ -519,20 +520,23 @@ ourselves to points of degree one. .. CODE-BLOCK:: python - def places_on_curve(f,F): + def places_on_curve(f, F): """ INPUT: - f -- element of F[x,y], defining X: f(x,y)=0 - F -- a finite field of *prime order* + + - f -- element of F[x,y], defining X: f(x,y)=0 + - F -- a finite field of *prime order* OUTPUT: - integer -- the number of places in X of degree d=1 over F - EXAMPLES: - sage: F=GF(5) - sage: R=PolynomialRing(F,2,names=["x","y"]) - sage: x,y=R.gens() - sage: f=y^2-x^9-x + integer -- the number of places in X of degree d=1 over F + + EXAMPLES:: + + sage: F = GF(5) + sage: R = PolynomialRing(F,2,names=["x","y"]) + sage: x,y = R.gens() + sage: f = y^2-x^9-x sage: places_on_curve(f,F) ((0, 1, 0), (3, 4, 1), (0, 0, 1), (2, 3, 1), (3, 1, 1), (2, 2, 1)) """ @@ -600,7 +604,7 @@ function is not required: .. CODE-BLOCK:: python - def places_on_curve(f,F): + def places_on_curve(f, F): p = F.characteristic() if F.degree() > 1: raise NotImplementedError @@ -677,7 +681,7 @@ This uses the class ``Expect`` to set up the Octave interface: """ Set the variable var to the given value. """ - cmd = '%s=%s;'%(var,value) + cmd = '%s=%s;' % (var,value) out = self.eval(cmd) if out.find("error") != -1: raise TypeError("Error executing code in Octave\nCODE:\n\t%s\nOctave ERROR:\n\t%s"%(cmd, out)) @@ -686,7 +690,7 @@ This uses the class ``Expect`` to set up the Octave interface: """ Get the value of the variable var. """ - s = self.eval('%s'%var) + s = self.eval('%s' % var) i = s.find('=') return s[i+1:] @@ -729,16 +733,16 @@ dumps the user into an Octave interactive shell: raise ValueError("dimensions of A and b must be compatible") from sage.matrix.all import MatrixSpace from sage.rings.all import QQ - MS = MatrixSpace(QQ,m,1) - b = MS(list(b)) # converted b to a "column vector" + MS = MatrixSpace(QQ, m, 1) + b = MS(list(b)) # converted b to a "column vector" sA = self.sage2octave_matrix_string(A) sb = self.sage2octave_matrix_string(b) self.eval("a = " + sA ) self.eval("b = " + sb ) soln = octave.eval("c = a \\ b") - soln = soln.replace("\n\n ","[") - soln = soln.replace("\n\n","]") - soln = soln.replace("\n",",") + soln = soln.replace("\n\n ", "[") + soln = soln.replace("\n\n", "]") + soln = soln.replace("\n", ",") sol = soln[3:] return eval(sol) diff --git a/src/doc/en/thematic_tutorials/algebraic_combinatorics/n_cube.rst b/src/doc/en/thematic_tutorials/algebraic_combinatorics/n_cube.rst index a31dff543a2..307291b10cc 100644 --- a/src/doc/en/thematic_tutorials/algebraic_combinatorics/n_cube.rst +++ b/src/doc/en/thematic_tutorials/algebraic_combinatorics/n_cube.rst @@ -19,8 +19,8 @@ The vertices of the `n`-cube can be described by vectors in The distance function measures in how many slots two vectors in `\mathbb{Z}_2^n` differ:: - sage: u=(1,0,1,1,1,0) - sage: v=(0,0,1,1,0,0) + sage: u = (1,0,1,1,1,0) + sage: v = (0,0,1,1,0,0) sage: dist(u,v) 2 diff --git a/src/doc/en/thematic_tutorials/lie/affine.rst b/src/doc/en/thematic_tutorials/lie/affine.rst index 124bf1f2e8d..320ff381783 100644 --- a/src/doc/en/thematic_tutorials/lie/affine.rst +++ b/src/doc/en/thematic_tutorials/lie/affine.rst @@ -381,7 +381,7 @@ The column vector `a` with these entries spans the nullspace of `A`:: sage: RS = RootSystem(['E',6,2]); RS Root system of type ['F', 4, 1]^* - sage: A=RS.cartan_matrix(); A + sage: A = RS.cartan_matrix(); A [ 2 -1 0 0 0] [-1 2 -1 0 0] [ 0 -1 2 -2 0] @@ -471,4 +471,3 @@ It may be constructed in Sage as follows:: See the documentation in :mod:`~sage.combinat.root_system.extended_affine_weyl_group` if you need this. - diff --git a/src/doc/en/thematic_tutorials/lie/branching_rules.rst b/src/doc/en/thematic_tutorials/lie/branching_rules.rst index 8ae0a9591ff..40eaf488f1d 100644 --- a/src/doc/en/thematic_tutorials/lie/branching_rules.rst +++ b/src/doc/en/thematic_tutorials/lie/branching_rules.rst @@ -50,7 +50,7 @@ Sage has a class ``BranchingRule`` for branching rules. The function the natural embedding of `Sp(4)` into `SL(4)` corresponds to the branching rule that we may create as follows:: - sage: b=branching_rule("A3","C2",rule="symmetric"); b + sage: b = branching_rule("A3","C2",rule="symmetric"); b symmetric branching rule A3 => C2 The name "symmetric" of this branching rule will be @@ -62,10 +62,10 @@ Here ``A3`` and ``C2`` are the Cartan types of the groups Now we may see how representations of `SL(4)` decompose into irreducibles when they are restricted to `Sp(4)`:: - sage: A3=WeylCharacterRing("A3",style="coroots") - sage: chi=A3(1,0,1); chi.degree() + sage: A3 = WeylCharacterRing("A3",style="coroots") + sage: chi = A3(1,0,1); chi.degree() 15 - sage: C2=WeylCharacterRing("C2",style="coroots") + sage: C2 = WeylCharacterRing("C2",style="coroots") sage: chi.branch(C2,rule=b) C2(0,1) + C2(2,0) @@ -95,13 +95,13 @@ Observe that we do not have to build the intermediate :: - sage: C4=WeylCharacterRing("C4",style="coroots") - sage: b1=branching_rule("C4","A3","levi")*branching_rule("A3","C2","symmetric"); b1 + sage: C4 = WeylCharacterRing("C4",style="coroots") + sage: b1 = branching_rule("C4","A3","levi")*branching_rule("A3","C2","symmetric"); b1 composite branching rule C4 => (levi) A3 => (symmetric) C2 - sage: b2=branching_rule("C4","C2xC2","orthogonal_sum")*branching_rule("C2xC2","C2","proj1"); b2 + sage: b2 = branching_rule("C4","C2xC2","orthogonal_sum")*branching_rule("C2xC2","C2","proj1"); b2 composite branching rule C4 => (orthogonal_sum) C2xC2 => (proj1) C2 - sage: C2=WeylCharacterRing("C2",style="coroots") - sage: C4=WeylCharacterRing("C4",style="coroots") + sage: C2 = WeylCharacterRing("C2",style="coroots") + sage: C4 = WeylCharacterRing("C4",style="coroots") sage: [C4(2,0,0,1).branch(C2, rule=br) for br in [b1,b2]] [4*C2(0,0) + 7*C2(0,1) + 15*C2(2,0) + 7*C2(0,2) + 11*C2(2,1) + C2(0,3) + 6*C2(4,0) + 3*C2(2,2), 10*C2(0,0) + 40*C2(1,0) + 50*C2(0,1) + 16*C2(2,0) + 20*C2(1,1) + 4*C2(3,0) + 5*C2(2,1)] @@ -187,7 +187,7 @@ Sage has a database of maximal subgroups for every simple Cartan type of rank `\le 8`. You may access this with the ``maximal_subgroups`` method of the Weyl character ring:: - sage: E7=WeylCharacterRing("E7",style="coroots") + sage: E7 = WeylCharacterRing("E7",style="coroots") sage: E7.maximal_subgroups() A7:branching_rule("E7","A7","extended") E6:branching_rule("E7","E6","levi") @@ -212,7 +212,7 @@ as follows:: sage: b = E7.maximal_subgroup("A2"); b miscellaneous branching rule E7 => A2 - sage: [E7,A2]=[WeylCharacterRing(x,style="coroots") for x in ["E7","A2"]] + sage: E7, A2 = [WeylCharacterRing(x,style="coroots") for x in ["E7","A2"]] sage: E7(1,0,0,0,0,0,0).branch(A2,rule=b) A2(1,1) + A2(4,4) @@ -236,8 +236,8 @@ complete up to inner automorphisms. For example, `E_6` has a nontrivial Dynkin diagram automorphism so it has an outer automorphism that is not inner:: - sage: [E6,A2xG2]=[WeylCharacterRing(x,style="coroots") for x in ["E6","A2xG2"]] - sage: b=E6.maximal_subgroup("A2xG2"); b + sage: E6, A2xG2 = [WeylCharacterRing(x,style="coroots") for x in ["E6","A2xG2"]] + sage: b = E6.maximal_subgroup("A2xG2"); b miscellaneous branching rule E6 => A2xG2 sage: E6(1,0,0,0,0,0).branch(A2xG2,rule=b) A2xG2(0,1,1,0) + A2xG2(2,0,0,0) @@ -250,7 +250,7 @@ the `A_2\times G_2` subgroup is changed to a different one by the outer automorphism. To obtain the second branching rule, we compose the given one with this automorphism:: - sage: b1=branching_rule("E6","E6","automorphic")*b; b1 + sage: b1 = branching_rule("E6","E6","automorphic")*b; b1 composite branching rule E6 => (automorphic) E6 => (miscellaneous) A2xG2 .. _levi_branch_rules: @@ -533,8 +533,8 @@ construct the branching rule to `A_5` we may proceed as follows:: sage: b = branching_rule("E6","A5xA1","extended")*branching_rule("A5xA1","A5","proj1"); b composite branching rule E6 => (extended) A5xA1 => (proj1) A5 - sage: E6=WeylCharacterRing("E6",style="coroots") - sage: A5=WeylCharacterRing("A5",style="coroots") + sage: E6 = WeylCharacterRing("E6",style="coroots") + sage: A5 = WeylCharacterRing("A5",style="coroots") sage: E6(0,1,0,0,0,0).branch(A5,rule=b) 3*A5(0,0,0,0,0) + 2*A5(0,0,1,0,0) + A5(1,0,0,0,1) sage: b.describe() @@ -1006,7 +1006,7 @@ representation of `SO(8)` and the two eight-dimensional spin representations. These are permuted by triality:: - sage: D4=WeylCharacterRing("D4",style="coroots") + sage: D4 = WeylCharacterRing("D4",style="coroots") sage: D4(0,0,0,1).branch(D4,rule="triality") D4(1,0,0,0) sage: D4(0,0,0,1).branch(D4,rule="triality").branch(D4,rule="triality") @@ -1021,4 +1021,3 @@ spin representations, as it always does in type `D`:: D4(0,0,1,0) sage: D4(0,0,1,0).branch(D4,rule="automorphic") D4(0,0,0,1) - diff --git a/src/doc/en/thematic_tutorials/numerical_sage/cvxopt.rst b/src/doc/en/thematic_tutorials/numerical_sage/cvxopt.rst index 7b365f60ba4..ba6cfb5fb86 100644 --- a/src/doc/en/thematic_tutorials/numerical_sage/cvxopt.rst +++ b/src/doc/en/thematic_tutorials/numerical_sage/cvxopt.rst @@ -1,11 +1,11 @@ Cvxopt ====== -Cvxopt provides many routines for solving convex optimization +``Cvxopt`` provides many routines for solving convex optimization problems such as linear and quadratic programming packages. It also has a very nice sparse matrix library that provides an interface to -umfpack (the same sparse matrix solver that matlab uses), it also -has a nice interface to lapack. For more details on cvxopt please +``umfpack`` (the same sparse matrix solver that ``matlab`` uses), it also +has a nice interface to ``lapack``. For more details on ``cvxopt`` please refer to its documentation at ``_ Sparse matrices are represented in triplet notation that is as a @@ -32,7 +32,7 @@ by sage: from cvxopt.base import spmatrix # optional - cvxopt sage: from cvxopt.base import matrix as m # optional - cvxopt sage: from cvxopt import umfpack # optional - cvxopt - sage: Integer=int # optional - cvxopt + sage: Integer = int # optional - cvxopt sage: V = [2,3, 3,-1,4, 4,-3,1,2, 2, 6,1] # optional - cvxopt sage: I = [0,1, 0, 2,4, 1, 2,3,4, 2, 1,4] # optional - cvxopt sage: J = [0,0, 1, 1,1, 2, 2,2,2, 3, 4,4] # optional - cvxopt @@ -61,7 +61,7 @@ we could do the following. [ 0 -1.00e+00 -3.00e+00 2.00e+00 0 ] [ 0 0 1.00e+00 0 0 ] [ 0 4.00e+00 2.00e+00 0 1.00e+00] - sage: C=m(B) # optional - cvxopt + sage: C = m(B) # optional - cvxopt sage: umfpack.linsolve(A,C) # optional - cvxopt sage: print(C) # optional - cvxopt [ 5.79e-01] @@ -71,7 +71,7 @@ we could do the following. [-7.89e-01] Note the solution is stored in :math:`B` afterward. also note the -m(B), this turns our numpy array into a format cvxopt understands. +m(B), this turns our numpy array into a format ``cvxopt`` understands. You can directly create a cvxopt matrix using cvxopt's own matrix command, but I personally find numpy arrays nicer. Also note we explicitly set the shape of the numpy array to make it clear it was @@ -81,12 +81,12 @@ We could compute the approximate minimum degree ordering by doing :: - sage: RealNumber=float # optional - cvxopt - sage: Integer=int # optional - cvxopt + sage: RealNumber = float # optional - cvxopt + sage: Integer = int # optional - cvxopt sage: from cvxopt.base import spmatrix # optional - cvxopt sage: from cvxopt import amd # optional - cvxopt - sage: A=spmatrix([10,3,5,-2,5,2],[0,2,1,2,2,3],[0,0,1,1,2,3]) # optional - cvxopt - sage: P=amd.order(A) # optional - cvxopt + sage: A = spmatrix([10,3,5,-2,5,2],[0,2,1,2,2,3],[0,0,1,1,2,3]) # optional - cvxopt + sage: P = amd.order(A) # optional - cvxopt sage: print(P) # optional - cvxopt [ 1] [ 0] @@ -108,8 +108,8 @@ For a simple linear programming example, if we want to solve :: - sage: RealNumber=float # optional - cvxopt - sage: Integer=int # optional - cvxopt + sage: RealNumber = float # optional - cvxopt + sage: Integer = int # optional - cvxopt sage: from cvxopt.base import matrix as m # optional - cvxopt sage: from cvxopt import solvers # optional - cvxopt sage: c = m([-4., -5.]) # optional - cvxopt @@ -130,4 +130,3 @@ For a simple linear programming example, if we want to solve sage: print(sol['x']) # optional - cvxopt # ... below since can get -00 or +00 depending on architecture [ 1.00e...00] [ 1.00e+00] - diff --git a/src/doc/en/thematic_tutorials/numerical_sage/numpy.rst b/src/doc/en/thematic_tutorials/numerical_sage/numpy.rst index 6e2bdbfb0c6..dbc2de71d42 100644 --- a/src/doc/en/thematic_tutorials/numerical_sage/numpy.rst +++ b/src/doc/en/thematic_tutorials/numerical_sage/numpy.rst @@ -15,7 +15,7 @@ create an array. :: - sage: l=numpy.array([1,2,3]) + sage: l = numpy.array([1,2,3]) sage: l array([1, 2, 3]) @@ -34,10 +34,10 @@ hardware float or int. :: - sage: l=numpy.array([2**40, 3**40, 4**40]) + sage: l = numpy.array([2**40, 3**40, 4**40]) sage: l array([1099511627776, 12157665459056928801, 1208925819614629174706176], dtype=object) - sage: a=2.0000000000000000001 + sage: a = 2.0000000000000000001 sage: a.prec() # higher precision than hardware floating point numbers 67 sage: numpy.array([a,2*a,3*a]) @@ -55,7 +55,7 @@ can be operated on much faster. :: - sage: l=numpy.array([1.0, 2.0, 3.0]) + sage: l = numpy.array([1.0, 2.0, 3.0]) sage: l.dtype dtype('float64') @@ -68,7 +68,7 @@ an array. :: - sage: l=numpy.array([1,2,3], dtype=float) + sage: l = numpy.array([1,2,3], dtype=float) sage: l.dtype dtype('float64') @@ -80,7 +80,7 @@ well as take slices :: - sage: l=numpy.array(range(10),dtype=float) + sage: l = numpy.array(range(10),dtype=float) sage: l[3] 3.0 sage: l[3:6] @@ -128,7 +128,7 @@ This is basically equivalent to the following :: - sage: m=numpy.matrix([[1,2],[3,4]]) + sage: m = numpy.matrix([[1,2],[3,4]]) sage: m matrix([[1, 2], [3, 4]]) @@ -184,8 +184,8 @@ NumPy arrays can be sliced as well :: - sage: n=numpy.array(range(25),dtype=float) - sage: n.shape=(5,5) + sage: n = numpy.array(range(25),dtype=float) + sage: n.shape = (5,5) sage: n[2:4,1:3] array([[11., 12.], [16., 17.]]) @@ -197,8 +197,8 @@ the original :: - sage: m=n[2:4,1:3] - sage: m[0,0]=100 + sage: m = n[2:4,1:3] + sage: m[0,0] = 100 sage: n array([[ 0., 1., 2., 3., 4.], [ 5., 6., 7., 8., 9.], @@ -222,7 +222,7 @@ Some particularly useful commands are :: - sage: x=numpy.arange(0,2,.1,dtype=float) + sage: x = numpy.arange(0,2,.1,dtype=float) sage: x array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. , 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9]) @@ -235,13 +235,13 @@ from 0 to 2. There is a useful command :meth:`numpy.r_` that is best explained b :: sage: from numpy import r_ - sage: j=complex(0,1) - sage: RealNumber=float - sage: Integer=int - sage: n=r_[0.0:5.0] + sage: j = complex(0,1) + sage: RealNumber = float + sage: Integer = int + sage: n = r_[0.0:5.0] sage: n array([0., 1., 2., 3., 4.]) - sage: n=r_[0.0:5.0, [0.0]*5] + sage: n = r_[0.0:5.0, [0.0]*5] sage: n array([0., 1., 2., 3., 4., 0., 0., 0., 0., 0.]) @@ -267,7 +267,7 @@ arrays. We can combine all of these techniques :: - sage: n=r_[0.0:5.0:11*j,int(5)*[0.0],-5.0:0.0] + sage: n = r_[0.0:5.0:11*j,int(5)*[0.0],-5.0:0.0] sage: n array([ 0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. , 0. , 0. , 0. , 0. , 0. , -5. , -4. , -3. , -2. , -1. ]) @@ -280,13 +280,13 @@ an equally spaced grid with `\Delta x = \Delta y = .25` for :: sage: import numpy - sage: j=complex(0,1) + sage: j = complex(0,1) sage: def f(x,y): ....: return x**2+y**2 sage: from numpy import meshgrid - sage: x=numpy.r_[0.0:1.0:5*j] - sage: y=numpy.r_[0.0:1.0:5*j] - sage: xx,yy= meshgrid(x,y) + sage: x = numpy.r_[0.0:1.0:5*j] + sage: y = numpy.r_[0.0:1.0:5*j] + sage: xx,yy = meshgrid(x,y) sage: xx array([[0. , 0.25, 0.5 , 0.75, 1. ], [0. , 0.25, 0.5 , 0.75, 1. ], @@ -321,9 +321,9 @@ equation `Ax=b` do sage: import numpy sage: from numpy import linalg - sage: A=numpy.random.randn(5,5) - sage: b=numpy.array(range(1,6)) - sage: x=linalg.solve(A,b) + sage: A = numpy.random.randn(5,5) + sage: b = numpy.array(range(1,6)) + sage: x = linalg.solve(A,b) sage: numpy.dot(A,x) array([1., 2., 3., 4., 5.]) diff --git a/src/doc/en/thematic_tutorials/numerical_sage/scipy.rst b/src/doc/en/thematic_tutorials/numerical_sage/scipy.rst index 8d3e788d87a..1cab99dda26 100644 --- a/src/doc/en/thematic_tutorials/numerical_sage/scipy.rst +++ b/src/doc/en/thematic_tutorials/numerical_sage/scipy.rst @@ -95,8 +95,8 @@ code. ....: return[y[1],-y[0]-10*y[1]*(y[0]**2-1)] sage: def j_1(y,t): ....: return [ [0, 1.0],[-2.0*10*y[0]*y[1]-1.0,-10*(y[0]*y[0]-1.0)] ] - sage: x= numpy.arange(0,100,.1) - sage: y=integrate.odeint(f_1,[1,0],x,Dfun=j_1) + sage: x = numpy.arange(0,100,.1) + sage: y = integrate.odeint(f_1,[1,0],x,Dfun=j_1) We could plot the solution if we wanted by doing diff --git a/src/doc/en/thematic_tutorials/steenrod_algebra_modules.rst b/src/doc/en/thematic_tutorials/steenrod_algebra_modules.rst index 6d6513af258..f038ff7acaa 100644 --- a/src/doc/en/thematic_tutorials/steenrod_algebra_modules.rst +++ b/src/doc/en/thematic_tutorials/steenrod_algebra_modules.rst @@ -92,7 +92,7 @@ The generators are themselves elements of the module:: One can produce an element from a given set of algebra coefficients:: - sage: coeffs=[Sq(15), Sq(10)*Sq(1,1), Sq(8)] + sage: coeffs = [Sq(15), Sq(10)*Sq(1,1), Sq(8)] sage: x = M(coeffs); x Sq(15)*g[0] + (Sq(4,1,1)+Sq(7,0,1)+Sq(11,1))*g[1] + Sq(8)*g[7] @@ -772,4 +772,3 @@ re-ordering of list elements), so the following comparison is reassuring:: True sage: flift[3] == lifts[1] True -