please please  Here's the python script for the lab. Can you answer only 11.a,b,c,d,e? PLease from scipy import random import numpy as np import matplotlib.pyplot as plt i = 1 # set a value for current in Amperes (A) B = 2 # set a value for magnetic field in Tesla (T) R = 1 # set length of wire in meters (m) a1 = -R # set left end point of straight wire b1 = R # set right end point of straight wire a2 = 0 # set left end point of curved wire b2 = np.pi # set end point of curved wire N = 1000 # set number of intervals N def f(x): return 1    def g(x): return np.sin(x) # generate an array of all zeroes array1 = np.zeros(N) array2 = np.zeros(N)    # change each entry in array to a random number between a and b for i in range(N): array1[i] = random.uniform(a1,b1) array2[i] = random.uniform(a2,b2) # compute summation over all random numbers in array integral_straight = 0.0 integral_semicirc = 0.0 for i in array1: integral_straight += f(i)    for i in array2: integral_semicirc += g(i) # compute the average value for each # contribution of force from each wire straight = ((b1-a1)/float(N)) * integral_straight semicirc = ((b2-a2)/float(N)) * integral_semicirc # calculate the net force by subtraction f_net = - i * B * straight + i * B * R * semicirc    print('The net force is %0.06f' % f_net, 'N') 11. Lastly, for your conclusion, please summarize the context of this experi-ment. Following this, please make sure you can address the questions below: (a) What happens when we run our script several times? (b) Given that we can run our script multiple times, what is the average? (c) By running this experiment multiple times, we achieved our goal? why? (d) If there is another scenario, to compute integrals, how many times do you think we should run this experiment to get the answer? (e) Can we say there is a likelihood that if we ran the experiment one time, we would obtain the answer? and by what chance (in percentage)?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please please 

Here's the python script for the lab. Can you answer only 11.a,b,c,d,e? PLease

from scipy import random
import numpy as np
import matplotlib.pyplot as plt

i = 1 # set a value for current in Amperes (A)
B = 2 # set a value for magnetic field in Tesla (T)
R = 1 # set length of wire in meters (m)
a1 = -R # set left end point of straight wire
b1 = R # set right end point of straight wire
a2 = 0 # set left end point of curved wire
b2 = np.pi # set end point of curved wire
N = 1000 # set number of intervals N


def f(x):
return 1
  
def g(x):
return np.sin(x)

# generate an array of all zeroes
array1 = np.zeros(N)
array2 = np.zeros(N)
  
# change each entry in array to a random number between a and b
for i in range(N):
array1[i] = random.uniform(a1,b1)
array2[i] = random.uniform(a2,b2)

# compute summation over all random numbers in array
integral_straight = 0.0
integral_semicirc = 0.0

for i in array1:
integral_straight += f(i)
  
for i in array2:
integral_semicirc += g(i)

# compute the average value for each
# contribution of force from each wire
straight = ((b1-a1)/float(N)) * integral_straight
semicirc = ((b2-a2)/float(N)) * integral_semicirc

# calculate the net force by subtraction
f_net = - i * B * straight + i * B * R * semicirc
  
print('The net force is %0.06f' % f_net, 'N')

11. Lastly, for your conclusion, please summarize the context of this experi-ment. Following this, please make sure you can address the questions below:
(a) What happens when we run our script several times?
(b) Given that we can run our script multiple times, what is the average?
(c) By running this experiment multiple times, we achieved our goal? why?
(d) If there is another scenario, to compute integrals, how many times do you
think we should run this experiment to get the answer?
(e) Can we say there is a likelihood that if we ran the experiment one time,
we would obtain the answer? and by what chance (in percentage)?

Page <
1
> of 5
+
ZOOM
Lab #7: Magnetic Force of a Current Carrying Wire
Recall that the magnetic force on a current carrying wire can be charac-
terized by the notion of moving charges (current) along a wire subject to a
magnetic field produces a force on the wire. The expression for magnetic force
on a current carrying wire is
F = iL x B,
assuming that the wire is straight. For a curved wire, small segments of wire
can be portioned into small elements ds such that the force is then expressed
dF = i · ds x B.
Integrating yields the form for magnetic force with an arc length
F = iB sin 0
ds.
a
Notice that for a straight wire, we can simply write as F = iLB sin 0 given some
wire of length L.
Magnetic Force due to Straight and Semi-circular Wire
х В
R
As an example, a wire consisting of a straight and semi-circular portions are
subject to a uniform magnetic field. This problem shows in two ways, that
magnetic force exerted on the wire reaches to a net zero, and that we can
exemplify the method of solving this problem analytically two ways. Lets write
this out based on our understanding and application of the Right-Hand Rule,
R
Fnet
Fstraight + Fsemicircle = –iB
dx + iB
Rsin Od0.
-R
0. Our
Ultimately, the above expression results in Fnet
goal for this lab then, is to confirm our solution through means of a numerical
experiment through solving integrals as shown on the right hand side. Fur-
thermore, rather than solving our integrals through difficult and cumbersome
numerical integration techniques, we will make use of a numerical method called
the monte carlo method of integraion.
2¿RB – 2iRB
--------
Transcribed Image Text:Page < 1 > of 5 + ZOOM Lab #7: Magnetic Force of a Current Carrying Wire Recall that the magnetic force on a current carrying wire can be charac- terized by the notion of moving charges (current) along a wire subject to a magnetic field produces a force on the wire. The expression for magnetic force on a current carrying wire is F = iL x B, assuming that the wire is straight. For a curved wire, small segments of wire can be portioned into small elements ds such that the force is then expressed dF = i · ds x B. Integrating yields the form for magnetic force with an arc length F = iB sin 0 ds. a Notice that for a straight wire, we can simply write as F = iLB sin 0 given some wire of length L. Magnetic Force due to Straight and Semi-circular Wire х В R As an example, a wire consisting of a straight and semi-circular portions are subject to a uniform magnetic field. This problem shows in two ways, that magnetic force exerted on the wire reaches to a net zero, and that we can exemplify the method of solving this problem analytically two ways. Lets write this out based on our understanding and application of the Right-Hand Rule, R Fnet Fstraight + Fsemicircle = –iB dx + iB Rsin Od0. -R 0. Our Ultimately, the above expression results in Fnet goal for this lab then, is to confirm our solution through means of a numerical experiment through solving integrals as shown on the right hand side. Fur- thermore, rather than solving our integrals through difficult and cumbersome numerical integration techniques, we will make use of a numerical method called the monte carlo method of integraion. 2¿RB – 2iRB --------
Page <
2
> of 5
ZOOM
+
Integrating through the Monte Carlo Method
In short, the monte carlo method is a statistical technique used often
to solve problems numerically where it may be deemed too difficult to employ.
While we can solve integration problems analytically by hand, a computer may
not be able to do the same. One such example is the famous Guass integral
-x²
dx = VT.
But without the knowledge in solving this integral by hand, is a challenging
piece of effort. This is where computers help us with numerical approximations
that are used to solve complex integral problems.
The monte carlo method makes use of random sampling. That is, by
selecting random numbers x;, i = 1, 2, .. on a given interval [a, b] of some function
f (x). We then methodically compute the output values while taking the average
of a sum of outputs to estimate our total area. More specifically, we want the
average value of an integral over an interval [a, b], or as such, by defining the
average value of a function as u, we find that
9.
1
| F(x)dx.
а
a
Noting as well, the mean can be represented through a summation of values,
N
E
f (x;)
N
i=1
By equating the expressions above, we arrive at an approximation between the
discrete and continuous representations,
N
1
1
| F(x)dr,
N
i=1
- a
and because the left hand side being discrete, we find ourselves using an algo-
rithm that computes this. Solving the integral on the right hand side yields the
result of our interest,
а
| f(2)dar =
Σf (:)
N
i=1
Recall that we will be choosing points x; at random on the interval [a, b] to help
approximate our integral. Our goal then is to build an algorithm that provides
a summation over N many intervals over the a, b. The output values when
given an input with random numbers will then be added together achieve our
average. The average then, in turn will give us an approximation for the area
under the curve, or the value of integration.
---------
Transcribed Image Text:Page < 2 > of 5 ZOOM + Integrating through the Monte Carlo Method In short, the monte carlo method is a statistical technique used often to solve problems numerically where it may be deemed too difficult to employ. While we can solve integration problems analytically by hand, a computer may not be able to do the same. One such example is the famous Guass integral -x² dx = VT. But without the knowledge in solving this integral by hand, is a challenging piece of effort. This is where computers help us with numerical approximations that are used to solve complex integral problems. The monte carlo method makes use of random sampling. That is, by selecting random numbers x;, i = 1, 2, .. on a given interval [a, b] of some function f (x). We then methodically compute the output values while taking the average of a sum of outputs to estimate our total area. More specifically, we want the average value of an integral over an interval [a, b], or as such, by defining the average value of a function as u, we find that 9. 1 | F(x)dx. а a Noting as well, the mean can be represented through a summation of values, N E f (x;) N i=1 By equating the expressions above, we arrive at an approximation between the discrete and continuous representations, N 1 1 | F(x)dr, N i=1 - a and because the left hand side being discrete, we find ourselves using an algo- rithm that computes this. Solving the integral on the right hand side yields the result of our interest, а | f(2)dar = Σf (:) N i=1 Recall that we will be choosing points x; at random on the interval [a, b] to help approximate our integral. Our goal then is to build an algorithm that provides a summation over N many intervals over the a, b. The output values when given an input with random numbers will then be added together achieve our average. The average then, in turn will give us an approximation for the area under the curve, or the value of integration. ---------
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY