ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 16 Mar 2019 10:41:49 -0500A problem in powerserieshttp://ask.sagemath.org/question/45792/a-problem-in-powerseries/It seems there is a problem when expanding tan(t), sinh(t), cosh(t) using PowerSeries. The following works fine
R.<t> = PowerSeriesRing(QQ)
sin(t)/cos(t)
t + 1/3*t^3 + 2/15*t^5 + 17/315*t^7 + 62/2835*t^9 + 1382/155925*t^11 + 21844/6081075*t^13 + 929569/638512875*t^15 + 6404582/10854718875*t^17 + 443861162/1856156927625*t^19 + O(t^20)
However, `tan(t)` returns
TypeError: cannot coerce arguments: no canonical coercion from Power Series Ring in t over Rational Field to Symbolic RingirizosSat, 16 Mar 2019 10:41:49 -0500http://ask.sagemath.org/question/45792/Bug in series expansion?http://ask.sagemath.org/question/45198/bug-in-series-expansion/ I'm trying to expand $(q + 1)/(q - 3)$ at $q=\infty$.
This doesn't work:
sage: f=(q + 1)/(q - 3)
sage: f.series(q==infinity,3)
Order(-Infinity)
This also doesn't:
sage: f.subs(q==1/q).series(q==0,3).subs(q==1/q)
-1/2/q - 1/2
(the value is wrong, it should be 1 as $q$ goes to infinity, not $-1/2$).
This works:
sage: f.subs(q==1/q).simplify_rational().series(q==0,3).subs(q==1/q)
4/q + 12/q^2 + 1
But is not very friendly. Any ideas?
parzanSun, 27 Jan 2019 06:00:00 -0600http://ask.sagemath.org/question/45198/can series make mistakes?http://ask.sagemath.org/question/39909/can-series-make-mistakes/ series seems to make errors . luckily, taylor works correctly.
start with L_F=(exp(-s)-1+s)/(s^2/2) (laplace transform of the "equilibrium" uniform density)
and switch to Pollaczek laplace transform L_F /(1- epsilon * L_F);
You can check that the moments expansions t, t1 differ
var('s');n=2
L_F=(exp(-s)-1+s)/(s^2/2) #satisfies L_F(s=0)=1
L_L=L_F/(1-L_F/3)
t = L_L.series(s,2*n+2)
t1= taylor(L_L,s,0,2*n+2)
print t1florinSat, 02 Dec 2017 04:16:35 -0600http://ask.sagemath.org/question/39909/How to get series expansion of function with symbolic parameter.http://ask.sagemath.org/question/37804/how-to-get-series-expansion-of-function-with-symbolic-parameter/Let
$$h(t) = \frac{\sinh(t)}{t}.$$
Let
$$
f_i(t) = h\left(\frac{t}{2^i} \right)^{2^i},
$$
where $i\ge 0$ is an integer.
Is there anyway to get a series expansion of $f_i(t)$ without replacing $i$ with a fixed integer?ablmfTue, 06 Jun 2017 03:38:46 -0500http://ask.sagemath.org/question/37804/series solutions of higher order ODEshttp://ask.sagemath.org/question/8717/series-solutions-of-higher-order-odes/I'm trying to use Sage to find the general series solution to [$y^{(4)}=\frac{y'y''}{1+x}$](http://math.stackexchange.com/questions/109189/basic-reference-material-about-odes-such-as-saparability-with-calculations-and-e "a posted math question"). So far my best efforts to derive the coefficient recurrence relations, inspired by a good [book draft](http://wdjoyner.com/teach/DiffyQ/des-book.pdf "David Joyner (2007), Introductory Differential Equations using SAGE"), have been along these lines:
R10 = QQ['a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10']
a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10 = R10.gens()
R.<x> = PowerSeriesRing(R10)
y = a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 + a5*x^5 + \
a6*x^6 + a7*x^7 + a8*x^8 + a9*x^9 + a10*x^10 + O(x^11)
y1 = y.derivative()
y2 = y1.derivative()
y3 = y2.derivative()
y4 = y3.derivative()
f = (1+x)*y4-y1*y2
i = ideal(f)
# g = i.groebner_fan(); g.reduced_groebner_bases() # a wish
# q = R.quotient(i) # works, but not so useful by itself
and my other approaches ended in tracebacks:
x = var('x'); y = function('y', x)
desolve(diff(y,x,4)-diff(y,x)*diff(y,x,2)/(1 + x), y, contrib_ode=True)
# NotImplementedError: Maxima was unable to solve this ODE.
desolve_laplace(diff(y,x,4) - diff(y,x)*diff(y,x,2)/(1 + x), y)
# TypeError: unable to make sense of Maxima expression
I would like to at least solve that and determine the radius of convergence. *Ideally* (more generally), it would be nice to have a good bag of tricks for working with series DEs such as I imagine [others](http://ask.sagemath.org/question/441/writing-re-usable-sage-scripts#785 "Writing re-usable sage scripts") have [already](file:///home/mike/Projects/Sage/Differential_Equations/series.sage "Are you the right mike?") created. For this, I would like to find or develop techniques to incorporate:
- more convenient coefficients, e.g. from [this thread](http://ask.sagemath.org/question/611/implicitly-defining-a-sequence-of-variables "implicitly-defining-a-sequence-of-variables")
- a way to derive the recurrence relations using Python's lambda operator or this [nice trick](http://ask.sagemath.org/question/142/generating-series#308 "LazyPowerSeriesRing.product_generator.compute_coefficients")
- a solver for higher order ODEs such as above
Any hints, links, references or suggestions would be appreciated.bginsWed, 15 Feb 2012 01:33:26 -0600http://ask.sagemath.org/question/8717/Sage incorrectly evaluates serieshttp://ask.sagemath.org/question/35839/sage-incorrectly-evaluates-series/It incorrectly evaluates $\displaystyle\sum_{n=0}^{\infty}\frac{1}{((2n+1)^2-4)^2}=\frac{\pi^2}{64}-\frac{1}{12}$, but correct answer is $\displaystyle\frac{\pi^2}{64}$proy87Thu, 01 Dec 2016 02:50:57 -0600http://ask.sagemath.org/question/35839/Sage incorrectly evaluates serieshttp://ask.sagemath.org/question/35838/sage-incorrectly-evaluates-series/ It incorrectly evaluates $\displaystyle\sum_{n=0}^{\infty}\frac{1}{((2n+1)^2-4)^2}=\frac{\pi^2}{64}-\frac{1}{12}$, but correct answer is $\displaystyle\frac{\pi^2}{64}$proy87Thu, 01 Dec 2016 02:50:06 -0600http://ask.sagemath.org/question/35838/Coefficients of serieshttp://ask.sagemath.org/question/35774/coefficients-of-series/Consider the sequence of polynomials:
g = lambda x, n: ((1 + x^2)^n + n*x*(1 + x^2)^(n - 1))
for n in (0..4):
print g(x,n).series(x,3*n)
1
1 + 1*x + 1*x^2
1 + 2*x + 2*x^2 + 2*x^3 + 1*x^4
1 + 3*x + 3*x^2 + 6*x^3 + 3*x^4 + 3*x^5 + 1*x^6
1 + 4*x + 4*x^2 + 12*x^3 + 6*x^4 + 12*x^5 + 4*x^6 + 4*x^7 + 1*x^8
for n in (0..4):
print g(x,n).list()
[1]
[1, 1, 1]
[1, 2, 2, 2, 1]
[1, 3, 3, 6, 3, 3, 1]
[1, 4, 4, 12, 6, 12, 4, 4, 1]
These are obviously the coefficients of the polynomials.
So I expected that I could also write instead
for n in (0..4):
print g(x,n).series(x,3*n).coefficients()
But this is not the case. What I get is:
[]
[[1, 0], [1, 1]]
[[1, 0], [2, 1], [2, 2], [2, 3]]
[[1, 0], [3, 1], [3, 2], [6, 3], [3, 4], [3, 5]]
[[1, 0], [4, 1], [4, 2], [12, 3], [6, 4], [12, 5], [4, 6], [4, 7]]
Here the term 1*x^(2*n) is missing. Is this a bug?Peter LuschnyTue, 29 Nov 2016 04:10:51 -0600http://ask.sagemath.org/question/35774/How can I get the coefficient of a Dirichlet series?http://ask.sagemath.org/question/26537/how-can-i-get-the-coefficient-of-a-dirichlet-series/Hello.
Let's see this example.
g(x)=(1-3^(-x))*(f(x))^2
where f(x) is the Riemann zeta function and x is complex variable.
If Re(s) is sufficiently large then g(x) is converges.
We only view this g(x) as a formal Dirichlet series.
What I want is coefficients.
The Riemann zeta function is rewritten by
f(x)=1+2^(-x)+3^(-x)+ ...
We can also rewrite the g(x) by the sum of `a_n * n^(-x)`.
g(x)=sum{a_n * n^(-x) | n=1,2,...}
For given `n`, how can I get `a_n` ??
Is there any helpful sage command ??
Thanks.SeminWed, 15 Apr 2015 11:10:04 -0500http://ask.sagemath.org/question/26537/Defining Dirichlet serieshttp://ask.sagemath.org/question/10082/defining-dirichlet-series/In basic analytic number theory, before one really starts talking about crazy L-functions of elliptic curves and the like, you can introduce so-called [Dirichlet series](http://en.wikipedia.org/wiki/Dirichlet_series). It is especially nice because the concepts really are accessible to anyone who has had a good calculus course and knows some elementary number theory (you don't have to talk about complex numbers, at first).
I have wanted to use these in Sage for a long time, but never seem to quite find the right command. For example, for the series defined by Moebius $\mu$, I want to use
L = Dokchitser(conductor=1, gammaV=[0], weight=1, eps=1)
L.init_coeffs('moebius(k)')
and the documentation for `Dokchitser` seems to indicate this might be valid. But the numbers I get are wrong.
Since I don't really know that much about L-functions in general, it's possible that the $\mu$ function's series has a different conductor or weight or something. But it wasn't easy to find any connections to this more general theory. Can someone help?
Bonus: if we can wrap this (or some other Sage) functionality to provide Dirichlet series for all kinds of things, including the Dirichlet L-functions for showing off the theorem on primes in an arithmetic progression and so forth, it would make a nice patch.kcrismanThu, 02 May 2013 07:45:54 -0500http://ask.sagemath.org/question/10082/Series and Sequences (Sage x Mathematica)http://ask.sagemath.org/question/25685/series-and-sequences-sage-x-mathematica/Hello, all.
I am trying to move from Mathematica to Sage Math but I'm facing basic issues. I had read the manual and searched for the answer in many results from google and found no answer to things like this:
In Mathematica, if I want to generate a sequence of integers I do the following (just an example):
Table[4*n^2 + 3, {n, 0, 50}] **or** Array[4 #^2 + 3 &, 44, 0]
and it will output the following:
{3, 7, 19, 39, 67, 103, 147, 199, 259, 327, 403, 487, 579, 679, 787, 903, 1027, 1159, 1299, 1447, 1603, 1767, 1939, 2119, 2307, 2503, 2707, 2919, 3139, 3367, 3603, 3847, 4099, 4359, 4627, 4903, 5187, 5479, 5779, 6087, 6403, 6727, 7059, 7399}
I saw the command range() but it doesn't accept a formula. Also, there is a mix of commands between Maxima and Python ... I'm really lost.
How can I generate the same list using Sage?
Thank you.LRMMon, 02 Feb 2015 21:50:47 -0600http://ask.sagemath.org/question/25685/Can I express a function as a series of another set of functionshttp://ask.sagemath.org/question/10596/can-i-express-a-function-as-a-series-of-another-set-of-functions/Let me give an example
Suppose I want to expand $\cos(x)^{4}$ as in a series of functions $C_{k}=(1/2-\cos(kx))$.
That is $\cos(4x)=k_0 C_0+k_1 C_1 + k_2 C_2 \cdots$ and I am looking for coefficients $k$
Now, I can use trig_reduce() to express $\cos(x)^{4}$ as a sum $\cos(kx)$, but how do I get get $\cos(x)^4$ in terms of $C_{k}$. ShashankMon, 07 Oct 2013 19:01:30 -0500http://ask.sagemath.org/question/10596/Unexpected result for the sum of a serieshttp://ask.sagemath.org/question/9537/unexpected-result-for-the-sum-of-a-series/I typed
n = var('n')
sum(1/((2*n-1)^2*(2*n+1)^2*(2*n+3)^2), n, 0, oo)
sage answered
3/256*pi^2 - 1/32
By hand computation (via Fourier series), and by WolframAlpha I got
3/256*pi^2
Why?
[Link to WolframAlpha's result](http://www.wolframalpha.com/input/?i=sum%281%2F%28%282*n-1%29%5E2*%282*n%2B1%29%5E2*%282*n%2B3%29%5E2%29%2C+n%2C+0%2C+oo%29).
(This is my first question. If it is inappropriate here, please tell me where I should ask it. I used the tag "bug", but I of course mean "potential bug". Thank you very much in advance!)
Pierre-Yves GaillardWed, 14 Nov 2012 19:48:43 -0600http://ask.sagemath.org/question/9537/Recover general formula for fourier series?http://ask.sagemath.org/question/8600/recover-general-formula-for-fourier-series/Hi,
Is there a way to recover the general formula for a fourier series? That is, f.fourier_series_sine_coefficient(9,pi) will give me the 9th sine coefficient, but I'd like to know more generally how I can construct the Nth sine coefficient.
I'm doing some complicated (to me) fourier series, and I'm having trouble figuring out the formula for the Nth.
Thanks for any help.
Andrewgopher13Thu, 29 Dec 2011 08:52:24 -0600http://ask.sagemath.org/question/8600/Detecting series divergence automaticallyhttp://ask.sagemath.org/question/8481/detecting-series-divergence-automatically/I'm writing an interact to let my students see graphs of sequences and of sequences of partial sums. But, I also want the interact to print the sum of the infinite series, if it converges.
Is there a way I can detect whether the sum converges within the interact? I need some automation here. I don't see that the "sum" command returns any sort of error value that flags whether the series converges or not. It just produces lots of errors.
Thanks!
calc314Wed, 16 Nov 2011 08:27:41 -0600http://ask.sagemath.org/question/8481/tseriesChaos package for R from Sage Notebookhttp://ask.sagemath.org/question/8129/tserieschaos-package-for-r-from-sage-notebook/Hello!
I need some nonlinear time series analysis functionality, which, as I've learnt from Internet, is provided by the 'tseriesChaos' package for R. I tried to use it from inside the Sage Notebook (one of the public servers) like this:
r.library('tseriesChaos')
and got the following error message:
Traceback (click to the left of this block for traceback)
...
there is no package called 'tseriesChaos'
This variant:
%r
library(tseriesChaos)
gave almost the same:
Error in library(tseriesChaos) :
there is no package called 'tseriesChaos'
So it looks like there is no 'tseriesChaos' package in a default Sage installation. So, how is it possible to use it? And how is it probable for the 'tseriesChaos' package to be included into Sage by default?
Thanks.v_2eWed, 25 May 2011 06:12:51 -0500http://ask.sagemath.org/question/8129/Time series analysishttp://ask.sagemath.org/question/8086/time-series-analysis/Being new to TSA, I have some basic questions.
I have 5 minute interval sales data that I want to plot. The plot should have lower, higher and current estimate along with new 1 day prediction.
I understand I can use Holt Winters formula or ARIMA. Can someone help me achieve this (steps and methods) using SAGE?NIshantWed, 20 Apr 2011 02:31:25 -0500http://ask.sagemath.org/question/8086/creating a fourier series animationhttp://ask.sagemath.org/question/8062/creating-a-fourier-series-animation/Hello,
I want to create an animation of sum((-1)^(n-1)*sin(n*x)/n,n,1 , k)
and show that as the number of terms 'k' in the partial sums increase, the sum converges to x/2 i.e looks more and more like the graph of x/2.
My first try is
**a = animate([(sum((-1)^(n-1)*sin(n*x)/n,n,1 , k))] for k in range (1,50,1))**
But that returns me an error
*Traceback (click to the left of this block for traceback)
...
AttributeError: 'int' object has no attribute '_maxima_'*
Also I want to include a static graph of x/2 in the background of the animation so that it is easy to observe that the series converges to x/2. how to do this?ebsFri, 08 Apr 2011 22:04:43 -0500http://ask.sagemath.org/question/8062/