[sage-support] Re: Solving recursion formula?
Hi Simon, Simon King wrote: > Coincidentally, William Stein today advertised a multi author book on > doing computations with Sage, and it has a chapter on solving > recurrences, also pointing to sympy. Well, I'm not responsible for that part ;-) -- Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Solving recursion formula?
Simon King wrote: > What about > a more complicated recurrence, such as the one given by > x_(n+1) = 1 + x_n*2/n > Any chances to solve those and similar recurrences automatically? You can try sympy's rsolve() or Maxima's solve_rec(). I don't know how powerful they are. -- Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Solving recursion formula?
Simon King wrote: > That's not what I am looking for. No data are given. Given is some > recursion formula; what we want to know is a corresponding closed > formula. Example: The recursion x_0=1 and x_(n+1) := f(x_n) = 2*x_n > should result in the closed formula x_n = 2^n. ore_algebra also has some limited support for solving linear recurrences with polynomial coefficients. Specifically, it can find polynomial and rational closed forms or prove that none exists. A related and perhaps more interesting feature is the ability to compute a basis of asymptotic expansions of solutions as n → ∞. On your example: sage: from ore_algebra import OreAlgebra sage: Pols. = QQ[] sage: RecOps. = OreAlgebra(Pols) sage: (Sn - 2).generalized_series_solutions() [2^n*(1 + O(n^(-5)))] A slightly more complicated one: sage: (Sn^2 + Sn - 2*(n^2+1)).generalized_series_solutions(2) [(n/e)^n*(1.414213562373095?)^n*n^(-1.353553390593274?) *(1 + 0.010110028629970214?*n^(-1) + O(n^(-2))), (n/e)^n*(-1.414213562373095?)^n*n^(-0.6464466094067262?) *(1 - 0.3434433619633035?*n^(-1) + O(n^(-2)))] In Sage itself, CFiniteSequence.closed_form() should be able to solve linear recurrence with constant coefficients. -- Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Issue compiling Cython code that uses Sage
Hi, Can anyone explain why the following works: - 8< - 8< - 8< - 8< - 8< - 8< - 8< - 8< - $ ~/co/sage/sage --version SageMath version 8.2.beta8, Release Date: 2018-03-10 $ head foo.pyx setup.py ==> foo.pyx <== from sage.libs.gmp.types cimport mpz_t ==> setup.py <== import setuptools, sage.env from Cython.Build import cythonize from distutils.core import Extension ext = Extension("foo", ["foo.pyx"], include_dirs=sage.env.sage_include_directories()) setuptools.setup(ext_modules=cythonize(ext)) $ ~/co/sage/sage -python setup.py build Compiling foo.pyx because it changed. [1/1] Cythonizing foo.pyx running build running build_ext building 'foo' extension gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -fPIC -I/home/marc/co/sage/local/include - I/home/marc/co/sage/local/include/python2.7 -I/home/marc/co/sage/local/lib/python2.7/site-packages/numpy/core/include - I/home/marc/co/sage/local/lib/python2.7/site-packages -I/home/marc/co/sage/local/lib/python2.7/site-packages/sage/ext - I/home/marc/co/sage/local/include/python2.7 -c foo.c -o build/temp.linux-x86_64-2.7/foo.o gcc -pthread -shared -L/home/marc/co/sage/local/lib -Wl,-rpath,/home/marc/co/sage/local/lib -L/home/marc/co/sage/local/lib -Wl,- rpath,/home/marc/co/sage/local/lib build/temp.linux-x86_64-2.7/foo.o -L/home/marc/co/sage/local/lib -lpython2.7 -o build/lib.linux-x86_64-2.7/foo.so - 8< - 8< - 8< - 8< - 8< - 8< - 8< - 8< - but the variant below doesn't? - 8< - 8< - 8< - 8< - 8< - 8< - 8< - 8< - $ head foo.pyx setup.py ==> foo.pyx <== from sage.libs.mpfr.types cimport mpfr_t # changed ==> setup.py <== import setuptools, sage.env from Cython.Build import cythonize from distutils.core import Extension ext = Extension("foo", ["foo.pyx"], include_dirs=sage.env.sage_include_directories()) setuptools.setup(ext_modules=cythonize(ext)) $ ~/co/sage/sage -python setup.py build foo.pyx: cannot find cimported module 'sage.libs.mpfr.types' Compiling foo.pyx because it changed. [1/1] Cythonizing foo.pyx Error compiling Cython file: ... from sage.libs.mpfr.types cimport mpfr_t ^ foo.pyx:1:0: 'sage/libs/mpfr/types.pxd' not found Error compiling Cython file: ... from sage.libs.mpfr.types cimport mpfr_t ^ foo.pyx:1:0: 'sage/libs/mpfr/types/mpfr_t.pxd' not found Traceback (most recent call last): File "setup.py", line 7, in setuptools.setup(ext_modules=cythonize(ext)) File "/home/marc/co/sage/local/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 1039, in cythonize cythonize_one(*args) File "/home/marc/co/sage/local/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 1161, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: foo.pyx (exit 1) - 8< - 8< - 8< - 8< - 8< - 8< - 8< - 8< - Thanks, -- Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Displaying graphics from a Sage script
John H Palmieri wrote: > This question comes from > http://stackoverflow.com/questions/41638257/graphics-in-sage-script: > if I have a file "foo.sage" and I want to run "sage foo.sage" and have > it pop up a window displaying a plot, how do I do this? Running sage < foo.sage instead of sage foo.sage works for me. Another option (not really satisfying either!) is as follows: ~/tmp$ cat foo.sage from sage.repl.interpreter import get_test_shell from sage.repl.rich_output import get_display_manager from sage.repl.rich_output.backend_ipython import \ BackendIPythonCommandline get_display_manager().switch_backend( BackendIPythonCommandline(), shell=get_test_shell()) plot(sin(x)).show() ~/tmp$ sage foo.sage Launched png viewer for Graphics object consisting of 1 graphics primitive -- Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: embedding of number field element encapseled in symbolic ring
Nils Bruin wrote: > If a field embeds into QQbar, then there should be an implied coercion > into CC, though: QQbar as implemented in sage is a subfield of the > field of complex numbers (as you can see from how the elements print). Let me add that there are long-standing tickets (#5355, #12715) for making number field embeddings go into AA/QQbar instead of RR/CC. Quite a bit of progress has been made towards that goal, but we're not quite there yet. -- Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: splitting field vs. Galois closure
Simon King wrote: > Wouldn't it be better to [...] or change the > arithmetic operations by *avoiding* a call to __init__()? That's what the branch I pointed to tries to do, to some extent at least. But the structure of generic polynomial classes (with many operations implemented in an abstract a base class, then a Cython subclass for the generic dense data structure, and a hierarchy of Python sub-subclasses that uses multiple inheritance) doesn't make it easy to avoid the calls to __init__() entirely without deeper changes. -- Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: splitting field vs. Galois closure
Nils Bruin wrote: > polynomial aritmetic over ZZ and QQ is so much more optimized than > over number fields, Yes, polynomial arithmetic over number fields is painfully slow. The branch trac:u/mmezzarobba/speed_up_generic_polynomials (not fully tested yet) may help a little. Another trick you can use if you are creating the polynomial rings yourself and only need to do basic arithmetic is to define them by PolynomialRing_field(base, var, element_class=Polynomial_generic_dense) instead of PolynomialRing(base, var). You then loose a few features specific to polynomial rings over fields, but you're basically saving a call to Polynomial_absolute_number_field_dense.__init__() after every operation, which can make basic arithmetic operations quite a bit faster. -- Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Multivariate division with remainder of polynomials
Jeroen Demeyer wrote: > I don't get what you mean. What I am saying is that the following two > should return the same answer: > > p.mod([q]) > p.quo_rem(q)[1] I was mixing up several things, sorry. Yes, that makes sense. I guess quo_rem() for multivariate polynomials must predate the introduction of Groebner bases in Sage... -- Marc Mezzarobba -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Re: Multivariate division with remainder of polynomials
Jeroen Demeyer wrote: > Is there any reason that quo_rem is not consistent with .mod()? That > is no longer arbitrary and would also extend the Euclidean division of > univariate polynomials. Not quite: you'd have to return a tuple of quotients. -- Marc Mezzarobba -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Multivariate division with remainder of polynomials
Hi Jeroen, (Disclaimer: what follows is based on what I gathered while writing the French Sage book a few years ago and may non longer be accurate!) Jeroen Demeyer wrote: > I am having a hard time understanding the precise semantics of > multivariate polynomial quo_rem(). The documentation only says > "Returns quotient and remainder of self and right" which is absolutely > not helpful. I think it is just a more or less arbitrary function that satisfies quo*q + rem == p and extends the Euclidean division of univariate polynomials. (But // can still be useful for exact divisions or divisions by monomials...) > Is multivariate division in the sense of > https://en.wikipedia.org/wiki/Gr%C3%B6bner_basis#Reduction implemented > somewhere in Sage? Yes: p.mod(ideal) or ideal.reduce(p). -- Marc Mezzarobba -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Conversion to float taking forever
Nico Van Cleemput wrote: Looking at the implementation of the float conversion, the problem seems to come from the following: sage: AA(ge) So apparently Sage is trying to prove that the imaginary part of the algebraic result is exactly zero. Is there another way to get a good float approximation of that value? Yes: sage: float(CDF(ge)) 19.870922489880776 -- Marc -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: finding and contacting an author of a function ?
Hi Dror, dror fidler wrote: i recently used is_distance_regular() in the graph package. however the definition of the function in the documentation page does not fit the definition of distance regular graphs. i would be very interested to find the source of the information the author used for this alternative definition. the wikipedia page they refer to does not trivially show this relation. To find who added some particular piece of code to Sage, use git blame on the file containing the code. In our case, $ git blame src/sage/graphs/distances_all_pairs.pyx reveals that is_distance_regular() was added by Nathann Cohen as part of commit 4d84feb2a, implementing trac ticket #14619. You can then find more information on the ticket's page: http://trac.sagemath.org/ticket/14619 Hope this helps, -- Marc -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: bug/feature in subs() for polynomials in a polynomial ring over a polynomial ring
Dima Pasechnik wrote: sage: r0=QQ['a1,a2'] sage: a1,a2=r0.gens() sage: r=r0['x1,x2'] [...] I am using such a ring as I want to treat ai as parameters, i.e. I would like monomial expansions in xi alone. Perhaps there is a better way to accomplish this? The best I can think of is p.map_coefficients(lambda a: a.subs(a1=2,a2=1)) -- Marc -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: trouble with polynomial functions, change of variables, and coefficients
Ben a écrit : I'm trying to take a rational map on P^1 (i.e. f(x,y) = [deg 2 poly, deg 2 poly] and conjugate, but I can't seem to get sage to cooperate. I would like to take a generic degree 2 map on P^1, and conjugate by an element of PGL_2. For example, I can do R.X,Y = PolynomialRing(QQ,2) def f(A,B): return A[0]*B[0]^2 + A[1]*B[1]^2 + A[2]*B[0]*B[1],A[3]*B[0]^2 + A[4]*B[1]^2 + A[5]*B[0]*B[1] x1,x2,x3,y1,y2,y3=var('x1,x2,x3,y1,y2,y3') Avar=[x1,x2,x3,y1,y2,y3] M= matrix([[0, -1],[1, -1]]) Z=f(Avar,M*vector([R.0,R.1])) ZZ=M.inverse()*vector(Z) Where ZZ is now a 2-tuple where I have conjugated f by M. Now, I would like to extract the coefficients of the monomials (X^2,XY,Y^2) from each entry of ZZ, but I can't seem to get that done using the .coefficients() functions. I think I'm not doing a good job with difference between symbolic expressions, functions, and polynomials. I think what you want is to replace the first line by R.X,Y = PolynomialRing(SR, 2) Then the elements of R will be allowed to contain symbolic variables. -- Marc Mezzarobba -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: power series -- rational function conversion?
John Cremona a écrit : I have a power series f(x) in F[[x]] (where F is a finite field) which I know to be a rational function p(x)/q(x) where p,q in F[x] have degree at most n, and I want to find p and q. There is an algorithm for this, like rational reconstruction to go from a real to a rational using continued fraction. I could not find this implemented though there are quite a lot of power series utilities and I might not recognise this if it has an unfamiliar name. Does any one know if it is implemented? It is, but for polynomials, not power series: sage: x = polygen(GF(17)) sage: (1-x+x^2-x^3).rational_reconstruct(x^4, 1, 1) (1, x + 1) -- Marc Mezzarobba -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is it possible to generate the documentation in any other language than English
Patrick ABOU BAKAR a écrit : So I am wondering if it possible to generate the documentation in French as of the current version of Sage when you install from source. Some documentation is indeed available in French: try sage -docbuild fr/tutorial html or have a look at http://www.sagemath.fr/ I am sending you a more detailed reply in French (this is much easier for me) off-list. -- Marc Mezzarobba -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org