Summation in a range
Very new to Sage, and need command to compute an expression like:
SUM from k=1 to 100, sin(k)/k
or
Integrate from x=1 to 10, log(x)
(numerically).
add a comment
Very new to Sage, and need command to compute an expression like:
SUM from k=1 to 100, sin(k)/k
or
Integrate from x=1 to 10, log(x)
(numerically).
Hi,
For the first one:
sage: s = sum(sin(k)/k for k in [1..100])
sage: s
1/100*sin(100) + 1/99*sin(99) + ... + 1
sage: n(s) # to get a numerical value
1.06042893840106
sage: n(s, digits=100)
1.060428938401062128124909620302077101279763978311569855925441799757471979305661574312928477002754702
For the second one:
sage: s = integrate(log(x), (x,1,10))
sage: s
10*log(10) - 9
sage: n(s)
14.0258509299405
Eric.
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2015-08-31 23:15:03 +0100
Seen: 1,839 times
Last updated: Aug 31 '15