[sage-support] Counting of combinations

2024-01-04 Thread Peter Luschny
Hi all, please consider this counting of special combinations: def C(n, k): return Compositions(n, max_part=k, inner=[k]).cardinality() for n in (0..4): print([C(n, k) for k in (0..n)]) [0] [0, 1] [0, 1, 1] [0, 1, 1, 1] [0, 1, 2, 1, 1] Edge cases are

Re: [sage-support] TypeError in SloaneEncyclopedia

2022-10-13 Thread Peter Luschny
> > Broken, indeed. Hardly any tests in sage/databases/sloane.py, no > wonder this happens. > See https://trac.sagemath.org/ticket/34655 > Does > oeis([1,2,3,4,5], 1) not do what you want? Thank you Dima! The Internet variant works. But my use case is not a single search, but a repeated

[sage-support] TypeError in SloaneEncyclopedia

2022-10-11 Thread Peter Luschny
Hello! > SloaneEncyclopedia.find([1,2,3,4,5], 1) TypeError Traceback (most recent call last) /tmp/ipykernel_447/420583060.py in () > 1 SloaneEncyclopedia.find([Integer(1),Integer(2),Integer(3),Integer(4),Integer(5)], Integer(1))

[sage-support] Problem with simplify_hypergeometric().

2021-11-26 Thread Peter Luschny
Please consider def H(n,k): return hypergeometric([-k, -n + k], [-k], -1) def T(n,k): return int(H(n,k).n()) def S(n,k): return H(n,k).simplify_hypergeometric() for n in range(8): print([T(n, k) for k in range(n+1)]) print([S(n, k) for k in range(n+1)]) The

[sage-support] hurwitz_zeta(0, x) = ?

2021-06-20 Thread Peter Luschny
Mathematica: HurwitzZeta[0, x] = 1/2 - x Maple: Zeta(0, 0, x) = -x + 1/2 Sage 9.2:hurwitz_zeta(0, x) = hurwitz_zeta(0, x) --- this is OK: Mathematica: HurwitzZeta[0, 1] = -1/2 Maple: Zeta(0, 0, 1) = -1/2 Sage 9.2:hurwitz_zeta(0, 1) = -1/2 -- You received this

[sage-support] Compositional inverse of multivariate power series

2021-02-10 Thread Peter Luschny
The compositional inverse (with respect to x) of y(t, x) = x - t*(exp(x) - 1) is 1/(1-t)*y + t/(1-t)^3*y^2/2! + (t+2*t^2)/(1-t)^5*y^3/3! + (t+8*t^2+6*t^3)/(1-t)^7*y^4/4! + ... Apparently multivariate power series rings do not know how to reverse a series. Perhaps there is a

[sage-support] Re: Why is f.inverse() so slow?

2020-11-11 Thread Peter Luschny
> > Maybe try to alter that via: > f = prod((1 - x^n + O(x^size))^a(n) for n in (1..size)) > Yes, that is the solution. Thank you so much! -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving

[sage-support] Why is f.inverse() so slow?

2020-11-10 Thread Peter Luschny
Hi all, I wanted to implement the Euler Transformation. https://oeis.org/wiki/Euler_transform My first attempt was: def EulerTransform(size, a): R. = ZZ[[]] f = prod((1 - x^n)^a(n) for n in (1..size)) + O(x^size) return f.inverse().list() print(EulerTransform(6, lambda n:

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread Peter Luschny
Am Di., 25. Juni 2019 um 11:29 Uhr schrieb slelievre < samuel.lelie...@gmail.com>: > So, replace > > sum(binomial(m*n-1, m*k)*OmegaPolynomial(m,k) for k in (0..n-1)) > > by > > sum((binomial(m*n-1, m*k)*OmegaPolynomial(m, k) for k in (0 .. n-1)), > RR['x'].zero()) > Now, this is clever!

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread Peter Luschny
Am Di., 25. Juni 2019 um 10:49 Uhr 'luisfe' : | When n =0, k ranges from 0 to -1 so there is no k and the list constructed in ib(n,m) | is just the empty list. Not an empty list of polynomials, just an empty list. Well, then the way 'sum' is implemented is possibly improvable? The type

Re: [sage-support] The behavior of empty sums

2019-06-25 Thread Peter Luschny
Am Montag, 17. Juni 2019 14:27:40 UTC+2 schrieb luisfe: > > On Mon, Jun 17, 2019 at 5:18 AM Peter Luschny wrote: >> >>> def ib(m, n): return sum(binomial(m*n-1, m*k)*OmegaPolynomial(m,k) for k >>> in (0..n-1)) >>> >>> The terms "b

Re: [sage-support] The behavior of empty sums

2019-06-17 Thread Peter Luschny
> Are you saying, the error message it spits out, >> > AttributeError: 'int' object has no attribute 'list', > is misleading? > As I see it the problem is that the sum runs over (0..n-1). Thus for n = 0 it returns by convention the integer 0 for the empty sum (is this correct?) which of

Re: [sage-support] The behavior of empty sums

2019-06-17 Thread Peter Luschny
> > I don't know what OmegaPolynomial is. However, if you replace it by > cyclotomic_polynomial, > it seems to work as expected, doesn't it? > No, it does not. You missed the question. > > sage: *def* *ib*(m, n): *return* sum(binomial(m*n-*1*, > m*k)*cyclotomic_polynomial(m*(k+*1*)) *for*

[sage-support] The behavior of empty sums

2019-06-17 Thread Peter Luschny
Hi, I think we should be confident that the sum of integers is again an integer, the sum of rational numbers a rational number and that the sum of polynomials is a polynomial. With Sage this is not the case. def ib(m, n): return sum(binomial(m*n-1, m*k)*OmegaPolynomial(m,k) for k in

Re: [sage-support] primes -- enhancement request

2019-03-12 Thread Peter Luschny
> > You did not say what command you were using. > Oh, I thought that was clear from the error message: prime_range. The function (implementing the factorial) is on GitHub

[sage-support] primes -- enhancement request

2019-03-12 Thread Peter Luschny
ValueError: Cannot compute primes beyond 436273290 I think SageMath should do better. Cheers, Peter /opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/rings/fast_arith.pyx in sage.rings.fast_arith.prime_range (build/cythonized/sage/rings/fast_arith.c:3390)() 46 from

[sage-support] Re: taylor versus series

2018-12-30 Thread Peter Luschny
> In the mean time, you can accomplish your computations without using SR: > sage: R.=QQ[[]] > sage: (1 - x - sqrt(1 - 6*x + x^2))/(2*x) > 1 + 2*x + 6*x^2 + 22*x^3 + 90*x^4 + 394*x^5 + ... Does this only work in interactive mode? As soon as I try to capture it in a function it doesn't work

[sage-support] Re: taylor versus series

2018-12-30 Thread Peter Luschny
Thank you Simon for your detailed explanations. I'm pretty sure it's a bug. Sage doesn't like little Schroeder either. LittleSchroeder = (1 + x - sqrt(1 - 6*x + x^2))/(4*x) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe

[sage-support] taylor versus series

2018-12-30 Thread Peter Luschny
Hi, I get with Maple: LargeSchroeder := (1 - x - sqrt(1 - 6*x + x^2))/(2*x); series(LargeSchroeder, x, 6); taylor(LargeSchroeder, x=0, 6); 1+2*x+6*x^2+22*x^3+90*x^4+394*x^5+O(x^6) 1+2*x+6*x^2+22*x^3+90*x^4+394*x^5+O(x^6) Both functions give the same result. Not so with

[sage-support] Matrix Multiplication

2018-12-13 Thread Peter Luschny
>From Sage Quick Reference: Linear Algebra, Robert A. Beezer: Matrix Multiplication u = vector(QQ, [1,2,3]), v = vector(QQ, [1,2]) A = matrix(QQ, [[1,2,3],[4,5,6]]) B = matrix(QQ, [[1,2],[3,4]]) u*A, A*v, B*A, B^6, B^(-3) all possible However u*A or A*v give: TypeError:

Re: [sage-support] Quaternions, how to speed up computation

2018-11-19 Thread Peter Luschny
You say: "hijack vs shut up, which one is more serious? Accusing someone hijacking something is a very serious accusation." I certainly didn't mean it as a 'very serious accusation' like hijacking people or planes. I used the term "hijacked" as a technical term like it is defined in the urban

Re: [sage-support] Quaternions, how to speed up computation

2018-11-19 Thread Peter Luschny
Kolen Cheung: > > And if anyone is dictating this, that one is surely not you, even if > you're the OP. Shut up. > You reconfirm the obvious, namely that you cannot behave. > On Monday, November 19, 2018 at 4:43:44 AM UTC-8, Peter Luschny wrote: >> >> > Hi, I’m

Re: [sage-support] Quaternions, how to speed up computation

2018-11-19 Thread Peter Luschny
> Hi, I’m trying to translate this Sage syntax to Python syntax (i.e. using sage as a Python library.) But I got stuck even on the first command. Why do you hijack this thread with a completely different topic? I'm sure that your question and the answers of the experts are of interest to many,

Re: [sage-support] Quaternions, how to speed up computation

2018-09-14 Thread Peter Luschny
merci beaucoup! Peter -- 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] Quaternions, how to speed up computation

2018-09-14 Thread Peter Luschny
How can I speed up this computation? H. = QuaternionAlgebra(SR, -1, -1) def Q(a, b, c, d): return H(a + b*i + c*j + d*k) def P(n): return Q(x+1,1,1,1)*P(n-1) if n > 0 else Q(1,0,0,0) def p(n): return P(n)[0].list() for n in (0..20): print [n], p(n) [0] [1] [1] [1, 1]

Re: [sage-support] Re: Possible bug in numerical integration

2016-06-07 Thread Peter Luschny
> > > on SMC terminal > > $ sage-develop > > > > gives you 7.3.beta2 > > Now how can I use this kernel in my yupyter notebook? > Ahh, it's there also! Is this new? Anyway thanks for this hint! > This was perhaps not a good idea. It's been long since I got so many ugly error messages.

Re: [sage-support] Re: Possible bug in numerical integration

2016-06-07 Thread Peter Luschny
> on SMC terminal > $ sage-develop > > gives you 7.3.beta2 Now how can I use this kernel in my yupyter notebook? Ahh, it's there also! Is this new? Anyway thanks for this hint! Peter -- You received this message because you are subscribed to the Google Groups "sage-support" group. To

Re: [sage-support] Re: Possible bug in numerical integration

2016-06-07 Thread Peter Luschny
> Your Sage is too old, this Pynac bug (existing for years) was fixed > months ago and should be in 7.2. Thanks Ralf! As I said I work on SMC. So I have to wait until William updates the cloud. Peter -- You received this message because you are subscribed to the Google Groups "sage-support"

[sage-support] Re: Possible bug in numerical integration

2016-05-31 Thread Peter Luschny
Further investigation shows that things work with the integrand defined as: def f(t): return exp(x*exp(i*t)-v*i*t)*(exp(exp(i*t))/cosh(exp(i*t))-1) So the source of the trouble seems to be related to the identity (exp(exp(I*t))/cosh(exp(I*t))-1) = tanh(exp(I*t)) Peter -- You received

[sage-support] Possible bug in numerical integration

2016-05-31 Thread Peter Luschny
Hi, I tested on SMC, SageMath 6.10. Consider the numerical integral: def T(v): def f(t): return (tanh(exp(i*t))/exp(i*t*v)).real() c = integral_numerical(f(t), 0, 2*pi)[0] return (c*gamma(v+1)/(2*pi)).n() print [round(T(n)) for n in range(10)] Sage returned: [0, 1, 0, -1, 0, 8, 0,

Re: [sage-support] Re: The results of some integration test.

2013-09-07 Thread Peter Luschny
I have put the test suite in a Sage worksheet and added some comments. I have moved the worksheet. It is now the public project 'CharlwoodFifty' at https://cloud.sagemath.com/ Unfortunately I do not know how to give a link to this project. Peter -- You received this message because you

Re: [sage-support] The results of some integration test.

2013-09-07 Thread Peter Luschny
Your methodology for diffs back assumes correctly computing the derivative and correctly comparing symbolic expressions and for the latter counterexamples are known Yes. This is just an indicator of possible problems, nothing more. diffs back checks f == 0 which is incorrect a priori, it should

Re: [sage-support] Re: The results of some integration test.

2013-09-06 Thread Peter Luschny
It would be great to have them in a file similar to wester.py. Can you open a ticket? I have put the test suite in a Sage worksheet and added some comments. Perhaps this is useful? http://www.luschny.de/math/quad/CharlwoodIntegrationTest.sws Peter -- You received this message because you

[sage-support] The results of some integration test.

2013-09-04 Thread Peter Luschny
Recently two integration test suites were discussed at sci.math.symbolic [1], [2]. I executed the tests with Sage and put the results on my webpage [3]. Not all results are favorable for Sage. Maybe this is worth to be noted by some Sage developers. Peter [1]

[sage-support] coefficients(x) throws TypeError

2012-01-26 Thread Peter Luschny
Hi, with Sage Notebook Version 4.7.2: Z0 = 1118557440*x^5 + 180204024*x^4 + 15195180*x^3 + 523250*x^2 + 4095*x + 1 Z1 = 4115105280L*x^6 + 1118557440*x^5 + 180204024*x^4 + 15195180*x^3 + 523250*x^2 + 4095*x + 1 print Z0.coefficients(x) # this works; print Z1.coefficients(x) #

[sage-support] Re: coefficients(x) throws TypeError

2012-01-26 Thread Peter Luschny
Hi, with Sage Notebook Version 4.7.2: Z0 =                   1118557440*x^5 + 180204024*x^4 + 15195180*x^3 + 523250*x^2 + 4095*x + 1 Z1 = 4115105280L*x^6 + 1118557440*x^5 + 180204024*x^4 + 15195180*x^3 +                           ^ Was this L intentional? No, it was not. Your