# 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

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

3

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.

Asked: **
2015-08-31 16:15:03 -0500
**

Seen: **121 times**

Last updated: **Aug 31 '15**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.