Ask Your Question
1

Summation in a range

asked 2015-08-31 23:15:03 +0100

MikeMikeMike gravatar image

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).

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2015-08-31 23:43:44 +0100

eric_g gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-08-31 23:15:03 +0100

Seen: 1,894 times

Last updated: Aug 31 '15