Hey everyone:

So, I start by making a symbolic function. Gamma(k) is the sum of some 
variables, u_i. Generating the function by hand is difficult, so I was 
hoping I could make it so that Sage generates the function and then I can 
give values for the u_i's, and have it compute the value for me. However, 
even after I give values to the u's, it doesn't substitute them into the 
equation. Sorry if this is basic, but what am I doing wrong? Ideally, I 
could write a function that would calculate the sum of many gammas, and 
then I could just supply values for the u's. Here's my code right now:

reset()
var("G")
var('i')
G = 5
u = [SR("u_%i"%x) for x in [0..6]]
gamma(k) = (1/G)*sum(-(u[i])^(k-1)/(u[i]-1)^k for i in (1..G-1))
show(1/5 - 3*2/5 + 3*gamma(2) - gamma(3))
u[1] = -1
u[2] = -1
u[3] = -1
u[4] = -1
show(1/5 - 3*2/5 + 3*gamma(2) - gamma(3))

 

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to