Computational Physics by using Matlab
Computational physics can be regarded as an amalgamation of physics with mathematics and computer science. Computers these days have changed the way physics (and all sciences) is done, and computational physics is now widely accepted as an equally valid approach to Physics after Experimental and Theoretical approach.
Matlab is one of the nicest platform to do these physics and has been gaining a lot of popularity in problem solving these days owing to its visibility and seamless integration feature. You can read more about Matlab here:
Some recommended books for Matlab are:
But Matlab as a platform is really colossal and like and ocean, so we need to be specific about the reason we are using Matlab .
Guide to Good programming:
If it is asked; What are the most important characteristics of a good program,or what do you mean by a good program?
Many people or mostly all will say efficiency and speed. Efficiency can have more synonyms like reliability, accuracy, perfectness etc. Yes indeed that’s true not very true though. Efficiency and speed are really crucial characteristics of a program but they do not define a program to be a good program or a bad program.
A program that is not efficient or accurate is of not much value , yet it still can be used if we understand the limitation of the program or what contain the accuracy of the code. We need to be the gentle and caring teacher who helps its pupils to understand the lessons. And for the speed; what matters is how long it takes to solve the problem and not how long to execute the program. So the speed can sometimes be traded for more accuracy (at least for experimental physics in which you use Matlab to talk to instruments and order them to solve your work)
Q: So, what is then the most important characteristic of a good program ?
Ans: It is the clarity of the code that is the most or very crucial aspect of the code. If its not clear what is the code doing then it is not a good code. If the code does not clearly describe the logic and algorithm of how it is doing our work, then it is not a good code. Unless you are in the receiving end of the code and believe in Data abstraction ideology.
On the other hand, if a code is clear and describes the use of each module, variables, algorithm then we are more likely to understand what is is intended to do. If or when there is an error, we can then very easily cure it as we understand the code, because of its clarity.
A standard problem solving approach for any problem or code is to break the code into smaller chunks called modules. This gives a better understanding of the total problem.This aspect is called as top-down design by physicists.
Another way to enhance the clarity of a code is to use valid variable names. Imagine reading a computer code asking to solve and integration of sin x over some space, and in the code you encounter a variable name as win32. What sense would that make? So employ using valid variable names and also make sure that the code does not have several variables doing the same operation. Try to extract maximum information and utilization from one single variable before it is cloned for some operations which can not be avoided.
This post is all about a basic tutorial of how to code in any programming platform. So start constructing some nice codes.