INTRODUCTION

What is Computational Physics ?

Why do we need Computational Physics ?

What are the advantages and disadvantages ?

Process of Computational Problem Solving


Introduction :

What is Computational Physics ?

Use of mathematical and experimental knowledge to create computer-based models of aspects of nature Computer modeling of physical systems.

Use these models to simulate the behavior of nature and relate the results that you observe back to the real world. In a sense, Computational Scientists create a simulated version of nature on which they perform experiments.

Why do we need Computational Physics ?

The computational methods in physics is most often needed in cases where:

physical experimentation is difficult

physical experimentation is expensive

physical experimentation is impossible

What are the advantages and disadvantages ?

We will obtain an approximate solution, or we may find the solution faster, but there is an error associated with our calculations which can be reduced but it will cost time and effort

Example :



Process of Computational Problem Solving

We must be sure of what question we are answering, what theoretical and experimental knowledge we can bring to bear, and what kind of answer we wish to obtain. This consideration requires knowledge about underlying science, in our case physics. A computational scientist is a scientist, in our case is a physicist.


I. IDENTIFY THE PROBLEM

We must be sure that the problem is one that can be approached computationally.

Example :

In 1600 Kepler took a problem to characterize the path taken by Mars as it orbits the sun (a computational question).

Other related problems that might exist but were not of his interest;

measure how Mars moves (an experimental question)

why Mars moves the way it does (a theoretical question)

II. MODEL

We need to reduce the problem as originally stated into one expressed in purely

mathematical terms, using mathematical expertise to extract the essentials from

the underlying physical description of the problem.

Once the problem is expressed mathematically, it can be solved computationally.

Example: Kepler's model



III. METHOD

Finding the answer often requires the use of numerical analysis, which

lies at the intersection of applied mathematics and computer science

Example:

Kepler used the trial and error method for the above model


IV. IMPLEMENTATION

To carry the method out we may need to do calculations by;

hand

a packet calculator

writing a computer program

when a computer is required, a variety of programming languages, each with

different properties, ranging from the most basic home computers to the fastest

parallel supercomputers. Then the common steps in developing the program is;

programming style:

modular design, use of subroutines

top-down design, starts with the most general

structured design and programming, combination of the two

what the program do ?

how the code is developed ?

Algorithm Design :

Algorithm is the sequence of logical steps required to perform a specific task such as solving a problem. In a good algorithm :

A ) each step must be deterministic, i.e.; nothing can be left to chance.

Example :


B ) the process must always end after a finite number of steps. An

algorithm can not be open-ended.

Example :

While( a > c) {

b = b + 1;

}

C ) the algorithm must be general enough to deal with any contingency.

Example :


Example : a correct design



Implementation :

      Program Composition
      Flowcharting

A. Flowcharting

A flowchart is a visual or graphical representation of an algorithm. The

flowchart employs a series of blocks and arrows, each of which represents a particular operation or step in the algorithm. The arrows represent the sequence in which the operations are implemented.

Example :

Algorithm and flowchart for the solution of a simple addition program

Step 1: Start the calculation

Step 2: Input a value for A

Step 3: Input a value for B

Step 4: Add A to B and call the answer c

Step 5: Output the value for C

Step 6: End the calculation



Three good reasons for studying flowchart :

1. an effective way for expressing and communicating algorithm

2. very useful in following your own or someone else's program

3. they are ideal for visualizing some of the fundamental control

structures employed in computer programming.

B. Pseudocode:

An alternative way to express an algorithm that bridges the gap between

flowcharts and computer code. This technique uses Englishlike statements place

of the graphical symbols of the flowchart.

Example :

Pseudocode for the solution of a simple addition program

BEGIN add A and B

Sum = 0

INPUT A

INPUT B

Sum = A + B

OUTPUT Sum

END add A and B

Advantage of pseudocode is that it is easier to develop a program with it than with a

flowchart. The pseudocode is also easier to modify. The disadvantage is their graphic form. Flowchart is better suited for visualizing complex algorithms.

C. Program Composition:

After constructing the algorithm, the next step is to express it as code. To write a code we need a programming language. There are many programming languages to perform computing. The question is which language is "best" for scientific computing. This has been the subject of heated debates in recent years. The most common used programming languages used are FORTRAN, C, BASIC, and Pascal. Here we only consider FORTRAN and C. FORTRAN which stands for formula translation was introduced by IBM in 1957. Since then, this programming language has been the dominating language for scientific computation.

C is a general-purpose programming language. C was originally designed for and implemented on the UNIX operating system on the DEC PDP-11, by Dennis Ritchie.

Example :

FORTRAN code for the solution of a simple addition program

c ADDCODE in FORTRAN

A = 2.3

B = 7.7

C = A + B

Write (6,10)

10 FORMAT(5x,' A + B = ' f 12.6) C

STOP

END



C code for the solution of a simple addition program

/* ADDCODE in C */

#include<stdio.h>

main()

{

float a = 2.3, b = 7.7;

c = a + b

printf(" a + b = \n %f " , C);

}

V. ANALYSIS:

As we discussed there is always an error associated with the result obtained by computational methods. Analysis of the errors is to study the effect of this error on our technique.

The error associated with both calculation and measurements can be characterized with regard to their accuracy and precision. Accuracy refers to how closely a computed or measured value agrees with the true value. Precision refers to how closely individual computed or measured values agree with each other. Thus, precision signifies

(1) the number of significant representing a quantity or

(2) the spread in repeated computations or measurements of particular value.

Computational methods should be sufficiently accurate or unbiased to meet the requirements of a particular physics or engineering problems. They also should be precise enough for adequate physics and engineering design.

Following is the list of some of the common errors :

A. Truncation Error:
This the errors caused by the method itself.

Example :

Approximate ex :

P3 (x) = 1 + x / 1! + x2 / 2! + x3 / 3!

However, we know that to obtain the answer with a good accuracy ex really requires an infinitely long series:

Where is m is infinitely large number. The approximation of ex with cubic gives an inexact answer. The error is due to truncating the series and does not have anything to do with computer or calculator.

B. Round-off Error:


All computing devices represent numbers with some precision. Computers, will nearly always use floating-point numbers with a fixed word length. The true values are not exactly expressed by such representations.

Example :

e = 1.7 .....

pi = 3.141592653......

This error is the result of rounded or chopped decimal fraction after the final digit.

C. Error in original data


Real-world problems, in which an existing or proposed physical situation is modeled by a mathematical equation, frequently have coefficients that are imperfectly known.

The model itself may not perfectly reflect the behavior of the situation either. In most cases we can not do anything about this error but we should be aware of it.


D. Blunders:

Human are involved in programming, operation, preparing the input, and interpreting the output, thus blunders or gross errors do occur more frequently that we like to admit.

E. Propagated Error:

This is the error in the succeeding steps of the process due to the occurrence of an earlier error. This in addition to the local error made at that step.

Absolute vs. Relative error, Significant digits

Absolute error = true value - approximate value

Relative error = (true value - approximate value) / true value

= Absolute error / true value

question : Do we know the true value ?

The answer is no. So what do we use for true value. We use the value that we obtain after some iteration as the true value.

Example : Absolute Error

find the absolute error for the following :

a (true) = 100.00, a (app.) = 99.998, Absolute (error) = 0.002

b (true) = 0.001, b (app.) = 0.003, Absolute (error) = 0.002

c (true) = 0.0000001, c (app.) = 0.0000004, Absolute (error) = 0.0000003

d (true) = 50.00, d (app.) = 49.00, Absolute (error) = 1.00

Example : Relative Error

find the absolute error for the following :

a (true) = 100.00, a (app.) = 99.998

Relative (error) = 0.002/100.00 = 0.00002 = 0.002 %

b (true) = 0.001, b (app.) = 0.003, Relative (error) = 0.002/0.001 = 2 = 200 %

c (true) = 0.0000001 c (app.) = 0.0000004

Relative (error) = 0.0000003 / 0.0000001 = 300 %

d (true) = 50.00, d (app.) = 49.00, Relative (error) = 1.00 / 50.00 = 2 %

What is your conclusion ?

Do you get the same error in all the above cases ?

How small is so small that can neglected ?