Ask Your Question

Peter Luschny's profile - activity

2021-06-09 16:50:45 +0200 received badge  Popular Question (source)
2021-06-03 10:17:14 +0200 received badge  Notable Question (source)
2021-02-03 18:35:40 +0200 received badge  Popular Question (source)
2020-12-16 15:56:50 +0200 received badge  Popular Question (source)
2020-12-11 20:07:15 +0200 received badge  Popular Question (source)
2020-12-11 20:06:58 +0200 marked best answer Seeking an efficient filter for partitions.

From the docs:

sage: Partitions(4, max_part=2).list()
[[2, 2], [2, 1, 1], [1, 1, 1, 1]]

I find this parlance confusing. Obviously the partition [1, 1, 1, 1] has no max part = 2. Be that as it may, I do want to filter those partitions which greatest part is 2, so in the example would return

[[2, 2], [2, 1, 1]].

What is the most efficient way to implement

P(n,k) = Partitions(n, MAX_PART=k)

where MAX_PART is defined in my sense?

2020-12-11 20:06:39 +0200 received badge  Notable Question (source)
2020-12-11 20:06:39 +0200 received badge  Popular Question (source)
2020-11-09 04:12:52 +0200 received badge  Popular Question (source)
2020-10-30 16:03:25 +0200 received badge  Notable Question (source)
2020-10-01 18:04:02 +0200 received badge  Popular Question (source)
2020-05-07 16:11:38 +0200 received badge  Nice Question (source)
2020-05-06 15:23:44 +0200 asked a question How to compute the alternating Hurwitz zeta function?

Hi all!

What is the best way to compute the alternating Hurwitz zeta function with Sage?

Sage has an implementation of the Hurwitz zeta function, hurwitz_zeta(s,x), where s and x are complex, but not for the alternating Hurwitz zeta function.

There is the formula https://dlmf.nist.gov/25.11#E35 albeit with significant restrictions on the domain of s and x.

Which is a reliable way to implement hurwitz_alt_zeta(s,x) for general complex s and x, based on Sage functions?

2020-04-07 17:19:05 +0200 received badge  Popular Question (source)
2020-02-24 04:48:20 +0200 received badge  Notable Question (source)
2019-10-28 03:59:42 +0200 received badge  Self-Learner (source)
2019-10-21 00:07:22 +0200 answered a question Hypergeometric Bug?

The reason given in the documentation cited in the comment above is debatable. Read this section in DLMF https://dlmf.nist.gov/15.2#ii which deals with a similar case and says: "Because of the analytic properties [...] it is usually legitimate to take limits in formulas involving functions that are undefined for certain values of the parameters."

For instance Maple gives the same values as Maxima.

2019-10-20 20:11:38 +0200 answered a question How do I write and implement a program in Sage for Windows?

Perhaps it is this what you want: After the installation of SageMath you will see a button "SageMath Notebook" on your desktop. Click, your default browser opens what is "Jupyter's home", click the button "New", choose SageMath, a new notebook opens and than you can write and save your programs without using the Console.

This will look similar to https://github.com/davidlowryduda/not...

2019-10-20 13:50:10 +0200 answered a question An analog to Pari's serlaplace

Here a potential solution:

def as_ogf(f, prec):
    S.<z> = PowerSeriesRing(ZZ)
    pari.set_series_precision(prec)
    C = pari("serlaplace(" + str(f(x)) + ")")
    return S(C)

f(x) = ((3*x + 8)*sinh(2*x) + (2*x^2 + 16*(x + 1))*cosh(2*x))/16    
as_ogf(f, 4) returns 1 + 2*z + 5*z^2 + 16*z^3 + 28*z^4 and is of the required type.

It seems to me it would be worthwhile to include such a function in Sage.

EDIT: After an edit this now works also with

f(x) = (3*x + 8)*sinh(2*x)/4; as_ogf(f, 4)

and returns 4z + 3z^2 + 16z^3 + 24z^4 + O(z^5), as desired.

2019-10-20 11:21:38 +0200 asked a question An analog to Pari's serlaplace

With PARI I can do this:

f(x) = ((3*x + 8)*sinh(2*x) + (2*x^2 + 16*(x + 1))*cosh(2*x))/16;
serlaplace(f('x + O('x^5)))

PARI returns 1 + 2x + 5x^2 + 16x^3 + 28x^4 + O(x^5).

How to achieve this with Sage? Note that I want the returned value to live in the 'Power Series Ring' over the 'Integer Ring'.

def serlaplace(f, prec):
    t = taylor(f, x, 0, prec)
    C = [c[0] for c in t.coefficients()]
    R.<u> = PowerSeriesRing(QQ)
    S.<z> = PowerSeriesRing(ZZ)
    return S(R(C).egf_to_ogf())

f(x) = ((3*x + 8)*sinh(2*x) + (2*x^2 + 16*(x + 1))*cosh(2*x))/16    
serlaplace(f, 4) returns 1 + 2*z + 5*z^2 + 16*z^3 + 28*z^4.

The question is: Is there a more direct, more efficient way to achieve this?

2019-10-10 11:44:46 +0200 received badge  Popular Question (source)
2019-09-05 17:30:42 +0200 received badge  Famous Question (source)
2019-04-30 18:43:49 +0200 received badge  Popular Question (source)
2019-03-12 20:01:32 +0200 received badge  Notable Question (source)
2019-01-19 21:41:33 +0200 received badge  Famous Question (source)
2018-10-26 13:02:06 +0200 received badge  Nice Question (source)
2018-10-23 01:46:40 +0200 received badge  Famous Question (source)
2018-10-04 20:53:06 +0200 received badge  Famous Question (source)
2018-04-19 12:49:03 +0200 received badge  Popular Question (source)
2017-10-31 17:46:59 +0200 received badge  Famous Question (source)
2017-10-28 02:37:50 +0200 received badge  Notable Question (source)
2017-10-28 02:37:50 +0200 received badge  Popular Question (source)
2017-10-13 16:34:04 +0200 received badge  Notable Question (source)
2017-08-15 23:39:21 +0200 received badge  Popular Question (source)
2017-08-11 19:56:28 +0200 asked a question Behavior of symbolic_sum changed?

Consider

from sage.calculus.calculus import symbolic_sum
n = var('n')
print 1/(1 + symbolic_sum(factorial(n) * x^n, n, 1, oo))

Answer of Sage 7.4:

1/(x*hypergeometric((1, 2), (), x) + 1)

Answer of Sage 8.0:

ValueError: Computation failed since Maxima requested 
additional constraints; ....
2017-08-06 11:22:02 +0200 received badge  Popular Question (source)
2017-07-29 20:43:13 +0200 received badge  Notable Question (source)
2017-05-09 14:38:11 +0200 received badge  Popular Question (source)
2017-05-09 14:38:11 +0200 received badge  Notable Question (source)
2017-04-27 15:18:10 +0200 received badge  Good Question (source)