Answered step by step
Verified Expert Solution
Link Copied!

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 1
In numerical methods, there are often many ways to make a calculation that gives the same answer but at very
different efficiencies (i.e., one method is faster than another). In this problem we will consider one such
calculation. In molecular dynamics we often need to compute the so-called Lenard-Jones 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 =1
6+1
12,=2+2+2
,=12,=12,=12.
Let us assume that two particles are located one at (1,0,3) and another at (2,-2,-1) and that two methods are
available for the calculation of LJ, namely
Method 1
(1) Calculate =2+2+2
(2) Calculate =1
6+1
12
Methods 2
(1) Calculate 2=2+2+2
(2) Calculate 1
2
(3) Calculate 1
6=1
2
1
2
1
2
(4) Calculate 1
12=1
6
1
6
(5) Calculate =1
6+1
12
Write a Matlab code that determines the amount of time it takes for Method 1 and Method
2 to do the calculation 10,102,103,104,105,106,107,108 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=1:1000000
end
elapsedTime=toc
after running these 4 lines of code you should get something like:
>> elapsedTime =
0.0176
which gives you the time it took do perform the loop in seconds. Finally, produce a log-log 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

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_2

Step: 3

blur-text-image_3

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

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

What are the six steps in applying for a patent?

Answered: 1 week ago