9. i) Consider the integral $\int_1^6 \frac{1}{x+2x^2}dx$. Write a Python code to approximate this integral using a Riemann sum with midpoint rule. Write a Python code 5 to approximate this integral using Monte Carlo (MC) simulations. You may import numpy as np 9. ii) Consider the function $g(k) = \int_1^6 \frac{1}{x+kx^2}dx$. For a fixed positive k, approximate g(k) with a Riemann sum. Use this approximation to plot the function g on interval [0, 5]. You may import matplotlib.pyplot as plt [3%]
Added by Trinidad G.
Close
Step 1
First, we need to define the function g(k) that we want to integrate. Let's say we want to integrate g(k) = k^2. Show more…
Show all steps
Your feedback will help us improve your experience
Jennifer Stoner and 69 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Exercise Riemann Sum Section 5.2 Consider the function x + 1 on 1 < x < 3 Partition the interval [1, 3] in n equal subintervals. Find f(xi). Setup the Riemann sum Evaluate the Riemann sum Evaluate the area under the curve by taking limit as n -> infinity
Adi S.
Give a 4-term left Riemann sum approximation for the integral below. ∫ 4√(x + 8) dx Answer: (fill in corresponding numbers) ∫ 4√(x + 8) dx ≈
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD