Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1 In numerical methods, there are often many ways to make a calculation that gives the same answer but at very different efficiencies (
Problem
In numerical methods, there are often many ways to make a calculation that gives the same answer but at very
different efficiencies ie one method is faster than another In this problem we will consider one such
calculation. In molecular dynamics we often need to compute the socalled LenardJones Potential: a
mathematically simply model approximating the interactions strength between two neutral uncharged
particles. If the Euclidean distance between the two particles is r then
Let us assume that two particles are located one at and another at and that two methods are
available for the calculation of LJ namely
Method
Calculate
Calculate
Methods
Calculate
Calculate
Calculate
Calculate
Calculate
Write a Matlab code that determines the amount of time it takes for Method and Method
to do the calculation times. Look at how the calculation times increase with
the number of times you do the calculation. For estimating the time, you should use the Matlab commands tic and
toc. For example, if you write the following in Matlab
tic;
for i:
end
elapsedTimetoc
after running these lines of code you should get something like:
elapsedTime
which gives you the time it took do perform the loop in seconds. Finally, produce a loglog plot showing the
time that is required to perform the calculations for the two methods versus the number of calculations.
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