Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

N=100 M=5 #that's my work question 1, check if I'm correct and help me with questions 2 and 3 use python code to solve all

image text in transcribed

image text in transcribed

image text in transcribed

N=100 M=5

#that's my work question 1, check if I'm correct and help me with questions 2 and 3 use python code to solve all this problems Web VPython 3.2

#Double integral of x^2

#inputs x_coord =0.0 # x coordinates of stone

maxit =100 # upper limit loop

x_min = -1 x_max = 3

Area_of_shape= 24 # area of a cube analytical_value =14

# Defining variables value_of_Area = 0.0 incount= 0 M=1 MArea = 0 averageArea= 0 i = 0,0 j= 0

#Defining graphical displays

gdisplay() inside = gdots(color=color.red) outside = gdots(color= color.blue)

gdisplay() plotpi= gdots(color= color.black)

# double intergral function def f(x): return x**2 #processing

for j in range(1,M+1): i=0 incount = 0 value_of_Area =0 outside.delete() inside.delete() for i in range(1,maxit): rate(1000) x_coord = random()*(x_max-x_min) if f( x_coord)

print("area estimate= " ,averageArea) aberror =abs(analytical_value- value_of_Area) print(aberror)

Thus far we have used the Throwing stones method to integrate a function of one variable. Now extend this to determine the integral of I=1202x2+y2dxdy Firstly, visualise this then determine the integral in Excel. Once again set up a workbook and determine for the same N and M values as previously this is to help you understand the system. Adapt your VPython code do the following: Integrate x2 between -1 and 3 between using both the stone throwing approach and the mean value approach. 1. For m=1&N=1000, what do you observe if you plot N vs calculated value of the function for both methods? 2. For N=102,103,104,105,106 and m=16 plot the N vs absolute error for both methods. What relationship fits this distribution of points? Comment on what you observe 3. Now plot N against the Standard Deviation (the Variance) for both methods and comment on what you observe. Please include your well commented codes as well as the requested graphs and associated comments in your report. If we wanted to calculate the properties of a magnesium atom (12 electrons) we would integrate some function over the coordinates of each electron - a 36D integral. This could take us a while to do. As an exercise, use the mean value MC approach to evaluate the following 10D integral that has an analytical solution of 156/6. Following the same evaluation route as you did in A,B and C in question 1. I=01dx101dx201dx10(x1+x2++x10)2 Please include your code as well as the graphs and associated comments in your report

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions