Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Solution of - 1 1 1 - x 2 2 d x vsing PRV . 1 #question in the lecture note: 2 import numpy as
Solution of vsing PRV
#question in the lecture note:
import numpy as np
success
#we make a for loop to creat a random numbers and count the success points
for in range :
#make random point
random.uni form #the range of is from to one side of the box
random.uniform #the range of is from to The other side of the box
npsqrt function at
#check if is less than
if yi fxi:
success success
rateOfSuccess success #success points over the total number of points
areaOfRectangle # is the area of the box green aren red area
integral rateOfSuccess #formula for estimation area under the curve
print
function has negative valre should break the interval two piece
one with negative value ome with possible value and make a box for each one.
green aren red area
the furetion above xaais
jist need modity
the highlighted part the code. and
integral rateOfSuccess #formula for estimation area under the curve
print
function has negative valre should break the interval two piece
one with negative value ome with possible value and make a box for each one.
green aren red area
the furetion above xaais
jist need modity
the highlighted part the code.Total of marks Use a random number generator in Python eg numpy.random.uniform to ap import numpy as np
n
success
#we make a for loop to creat a random numbers and count the success points
for i in rangen:
#make random point xiyi
xi nprandom.uniform #the range of x is from to one side of the box
yi nprandom.uniform #the range of x is from to The other side of the box
fxi npsqrtxi #fxi function at xi
#check if yi is less than fxi
if yi fxi:
success success
rateOfSuccess successn #success points over the total number of points
areaOfRectangle # is the area of the box
proximate the following integral:
Show your code with the result.
Hint: The function is positive on and negative on You should use the method taught in
class with at least points.
Use method shown in image
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started