Answered step by step
Verified Expert Solution
Question
1 Approved Answer
We now have all the pieces necessary to build a walk - on - spheres estimate of temperature on a square domain. Using functions from
We now have all the pieces necessary to build a walkonspheres estimate of temperature on a square domain. Using functions from Tasks and write a function, wostemperatureestimatex y length, cnrtemps, epsilon, numberwalks which returns a tuple with two items: the average temperature estimate as a float, and a numpy.array with the edge temperatures from each individual walk. The parameter epsilon is a float that indicates when
the distance of the walk is close enough to the edge that we can stop. The parameter numberwalks is an integer indicating how many walks to take. Remember that each walk starts afresh from point x y The other parameters are as described in the earlier tasks. Refer to the algorithm descriptiont
in the figure for what to implement.
Sample
x ; y
length ; epsilon
cnrtemps sw:se:ne:nw:
numberwalks
random.seed
Tavg, Ts wostemperatureestimatex y length, cnrtemps, epsilon,
numberwalks
Tavg
Ts
array
numberwalks
random.seed
Tavg, Ts wostemperatureestimatex y length, cnrtemps, epsilon,
numberwalks
Tavg
It is possible to compute the temperature value analytically for this square domain with linearly varying boundary conditions. In this case, the value at is the areaweighted average of the corner
temperature values, as follows:
T TSWtimes times TSEtimes times TNEtimes times TNWtimes times
This results in T K What do we notice from the sample usage above? The result from one walk is a terrible estimate: K This is not surprising. Remember the value gets more accurate as we take more walks. When using walks, the result is K which only differs from the analytical value of K
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