ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 05 Jan 2019 08:23:28 -0600Working with sums/products of listshttps://ask.sagemath.org/question/44906/working-with-sumsproducts-of-lists/I need to work symbolically with expressions such as this
$L(x; a,b) = \prod_{i=1}^n{abx_i^{a-1}(1-x_i^a)^{b-1}}$
where $x$ would be a random sample of size $n$.
I don't know of any way to express the indexing of the sample $x$ by each element...
The closest I got was defining the variables $n$ and $i$ and representing $x$ as a function
var('a','b','x','n','i')
assume(x>0,a>0,b>0,i>0,n>0)
X = function('X',nargs=1)
L = product(a*b*X(i)^(a-1)*(1-X(i)^a)^(b-1), i, 1, n)
But this seems to inmediately assume that $X(i) = i$ and $L$ is represented as:
$-\frac{\left(-1\right)^{n} a^{n} b^{n} X\left(0\right) X\left(-1\right) X\left(-2\right) X\left(-3\right) X\left(-4\right) X\left(-5\right) X\left(-6\right) X\left(-7\right) X\left(-8\right) X\left(-9\right) {\prod_{i=1}^{n} {\left(-X\left(i\right)^{a} + 1\right)}^{b}} {\prod_{i=1}^{n} X\left(i\right)^{a}}}{X\left(n - 1\right) X\left(n - 2\right) X\left(n - 3\right) X\left(n - 4\right) X\left(n - 5\right) X\left(n - 6\right) X\left(n - 7\right) X\left(n - 8\right) X\left(n - 9\right) X\left(n\right) {\prod_{i=1}^{n} X\left(i\right)^{a} - 1} {\prod_{i=1}^{n} X\left(i - 10\right)}}$
I don't know how to deal with this expression, and it seems to me like it should be straight forward.
In case it's meaningful, after defining the expression, I will be differentiating it with respect to both $a$ and $b$.galioSat, 05 Jan 2019 08:23:28 -0600https://ask.sagemath.org/question/44906/Working with sums/products of listshttps://ask.sagemath.org/question/44905/working-with-sumsproducts-of-lists/I need to work symbolically with expressions such as this
$L(x; a,b) = \prod_{i=1}^n{abx_i^{a-1}(1-x_i^a)^{b-1}}$
where $x$ would be a random sample of size $n$.
I don't know of any way to express the indexing of the sample $x$ by each element...
The closest I got was defining the variables $n$ and $i$ and representing $x$ as a function
var('a','b','x','n','i')
assume(x>0,a>0,b>0,i>0,n>0)
X = function('X',nargs=1)
L = product(a*b*X(i)^(a-1)*(1-X(i)^a)^(b-1), i, 1, n)
But this seems to inmediately assume that $X(i) = i$ and $L$ is represented as:
$-\frac{\left(-1\right)^{n} a^{n} b^{n} X\left(0\right) X\left(-1\right) X\left(-2\right) X\left(-3\right) X\left(-4\right) X\left(-5\right) X\left(-6\right) X\left(-7\right) X\left(-8\right) X\left(-9\right) {\prod_{i=1}^{n} {\left(-X\left(i\right)^{a} + 1\right)}^{b}} {\prod_{i=1}^{n} X\left(i\right)^{a}}}{X\left(n - 1\right) X\left(n - 2\right) X\left(n - 3\right) X\left(n - 4\right) X\left(n - 5\right) X\left(n - 6\right) X\left(n - 7\right) X\left(n - 8\right) X\left(n - 9\right) X\left(n\right) {\prod_{i=1}^{n} X\left(i\right)^{a} - 1} {\prod_{i=1}^{n} X\left(i - 10\right)}}$
I don't know how to deal with this expression, and it seems to me like it should be straight forward.galioSat, 05 Jan 2019 08:20:32 -0600https://ask.sagemath.org/question/44905/Sage doesn't show limit of ratio of sumshttps://ask.sagemath.org/question/24744/sage-doesnt-show-limit-of-ratio-of-sums/ Hi everyone,
I'm new to Sage and I'm trying to obtain the following limit:
$$\lim_{N\to \infty}\frac{\sum_{i=1}^{N} x_i^{5/2}}{\sum_{i=1}^N x_i^2}$$
with $x_i=(N-i)/(N-1)$. What I tried was:
i = var('i')
assume(i>0,'integer')
N = var('N')
assume(N>0,'integer')
x_i = (N-i)/(N-1)
numerator = sum(x_i^(5./2.),i,1,N)
denominator = sum(x_i^(2.),i,1,N)
limit(numerator/denominator,N=oo)
However, this just gives me:
6*limit((N - 1)*sum(((N - i)/(N - 1))^2.5, i, 1, N)/(2*N^2 - N), N, +Infinity)
From what I can see, Sage has no problems with the denominator, the general formula of which was obtained easily. However, apparently it has problems obtaining the general formula for the numerator due to the fact that the exponent in the sum is not an integer. Is there a way to cope with this? How can I obtain the limit?
Thanks in advance for all the help!
nespinozaSun, 02 Nov 2014 16:23:58 -0600https://ask.sagemath.org/question/24744/Summing with Euler_phi Errorhttps://ask.sagemath.org/question/10340/summing-with-euler_phi-error/New to sage, having some trouble with summation.
z, k both declared as variables.
sum((euler_phi(k)/k)*log(1/(1-2*z^k)),k,2,5)
Error: not an integer argument in an arithmetic function (18)
If I change it to euler_phi(5)/5 it's fine.
david8381Wed, 10 Jul 2013 04:29:53 -0500https://ask.sagemath.org/question/10340/Extract terms from a sumhttps://ask.sagemath.org/question/9295/extract-terms-from-a-sum/Is there some way to programmatically extract the first, second, third, and so on terms from a sum of symbolic terms (or equivalently, turn such a sum into the list of its summands)? For example, after
sage: A,B,C = var('A'), var('B'), var('C')
sage: F = A*B+C; F
A*B + C
Is there some method you can call on F to extract A*B (or C)? This would be useful especially for displaying sage in LaTeX via sageTeX when a formula that is the sum of 4 terms (say) runs over the margin and has to be split up somehow. I would also be interested in a workaround in sageTeX that would allow you to flexibly insert a linebreak in a formula under the circumstances that the formula generated by Sage got too long for a line.
heatkernelTue, 04 Sep 2012 17:05:14 -0500https://ask.sagemath.org/question/9295/