Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 27
Image: ubuntu2204
Kernel: SageMath 10.0

Riemann Sums Assignment

Note: There are no graphs on this assignment.

Question 1

[2 points] Approximate the area under the graph of f(x)=3x29x+5f(x)=3x^2-9x+5 on the interval [5,5][-5,5] using left and right Riemann sums with n=25n=25 and n=50n=50 subintervals.

[The actual area is 300300.]

f(x)=3*x^2-9*x+5 a=-5 b=5 n=25 dx=(b-a)/n i=var('i') LS=sum (f(a+i*dx)*dx, i, 0, n-1) print ('The left Riemann sum is',N(LS)) RS=sum(f(a+i*dx) *dx, i, 1, n) #calculates right sum print ('The right Riemann sum is',N(RS))
The left Riemann sum is 318.800000000000 The right Riemann sum is 282.800000000000
f(x)=3*x^2-9*x+5 a=-5 b=5 n=50 dx=(b-a)/n i=var('i') LS=sum (f(a+i*dx)*dx, i, 0, n-1) print ('The left Riemann sum is',N(LS)) RS=sum(f(a+i*dx) *dx, i, 1, n) #calculates right sum print ('The right Riemann sum is',N(RS))
The left Riemann sum is 309.200000000000 The right Riemann sum is 291.200000000000

Question 2

[2 points] The area under the graph of f(x)=ln(sin(x))f(x)=\ln(\sin(x)) from x=1x=1 to x=2x=2 is approximately 0.0455-0.0455.

To get an idea of how big nn must be to get a good approximation (say correct to four decimal places), find both the left and right Riemann sums with n=100n=100, n=500n=500, and n=1000n=1000.

f(x)=ln(sin(x)) a=1 b=2 n=200 dx=(b-a)/n i=var('i') LS=sum (f(a+i*dx)*dx, i, 0, n-1) print ('The left Riemann sum is',N(LS)) RS=sum(f(a+i*dx) *dx, i, 1, n) print ('The right Riemann sum is',N(RS))
The left Riemann sum is -0.0456982758324585 The right Riemann sum is -0.0453106722815888
f(x)=ln(sin(x)) a=1 b=2 n=500 dx=(b-a)/n i=var('i') LS=sum (f(a+i*dx)*dx, i, 0, n-1) print ('The left Riemann sum is',N(LS)) RS=sum(f(a+i*dx) *dx, i, 1, n) print ('The right Riemann sum is',N(RS))
The left Riemann sum is -0.0455800702068700 The right Riemann sum is -0.0454250287865221
f(x)=ln(sin(x)) a=1 b=2 n=1000 dx=(b-a)/n i=var('i') LS=sum (f(a+i*dx)*dx, i, 0, n-1) print ('The left Riemann sum is',N(LS)) RS=sum(f(a+i*dx) *dx, i, 1, n) print ('The right Riemann sum is',N(RS))
The left Riemann sum is -0.0455410349143012 The right Riemann sum is -0.0454635142041273

Question 3

[2 points] The graph of x2+y2=25x^2+y^2=25 is a circle of radius 5 centered at the origin. From geometry, we know its area is π5278.54\pi\cdot5^2\approx78.54. We will approximate this area using Riemann sums.

Let f(x)=25x2\displaystyle f(x)=\sqrt{25-x^2} (the top half of the circle). Approximate the area between ff and the x-axis from x=5x=-5 to x=5x=5 using left and right Riemann sums with n=100n=100 subintervals.

Now multiply this area by 2 to get an approximation for the area of the whole circle. You should be pretty close to the correct area.

f(x)=sqrt (25-x^2) a=-5 b=5 n=100 dx=(b-a)/n i=var('i') LS=sum (f(a+i*dx)*dx, i, 0, n-1) print ('The left Riemann sum is',N(LS)) RS=sum(f(a+i*dx) *dx, i, 1, n) print ('The right Riemann sum is',N(RS))
The left Riemann sum is 39.2283563887312 The right Riemann sum is 39.2283563887312
(39.2283563887312*2)
78.4567127774624

Question 4

[3 points] Use CoCalc's sum command to evaluate the following sums. [Remember to declare variables.]

Part a

i=1501i2\displaystyle\sum_{i=1}^{50}\frac{1}{i^2}

i=var('i') N(sum((1/i^2),i,1,50))
1.62513273362153

Part b

k=10100k33k25\displaystyle\sum_{k=10}^{100}\frac{k^3-3k^2}{5}

k=var('k') sum(((k^3-3*k^2)/5),k,10,100)
4897256

Part c

k=1n((kn)2+kn)1n\displaystyle\sum_{k=1}^{n}\left(\left(\frac{k}{n}\right)^2+\frac{k}{n}\right)\cdot\frac{1}{n}

[Hint: Declare both nn and kk to be variables.]

n=var ('n') k=var ('k') sum(((k/n)^2+k/n)*1/n,k,1,n)
1/6*(5*n^2 + 6*n + 1)/n^2

Question 5

[1 point] Use the limit command to calculate the limit as nn\to\infty of your answer from Question 4, Part c.

[Hint: The answer should be 56\frac{5}{6}]

n=var('n') limit(1/6*(5*n^2+6*n+1)/n^2, n=infinity)
5/6

After you finish Question 5, note: The limit in Question 5 gives the area between the x-axis and the function f(x)=x2+xf(x)=x^2+x over the interval from x=0x=0 to x=1x=1, because the sum in Question 4, Part c, is the right Riemann sum with nn rectangles for this function.

In other words, 01x2+xdx=limnk=1n((kn)2+kn)1n=56\displaystyle\int_0^1 x^2+x\, dx=\lim_{n\to\infty}\sum_{k=1}^{n}\left(\left(\frac{k}{n}\right)^2+\frac{k}{n}\right)\cdot\frac{1}{n}=\frac{5}{6}.