Computational Methods Junior Honours : Checkpoint 1

 

Assessment:  MarkingCP1.htm

 

 

 

The purpose of this checkpoint is to refresh you on the mechanics of editing, compiling and running java code, which you learned in
Physics 2 Scientific Programming

(new for this year!) My Java notes in a  peanutshell intended to be what you need to know, and not much more

 

You should refresh your memory of with the Physics 2 Scientific Programming course and associated documents.

 

A list of the most needed Unix commands is here

Particular attention should be payed to

·       Loops

·       Methods

·       Objects

 

Some useful Java documentation (increasingly advanced).


The checkpoint will also teach you how to write numerical data into text files, and display them as presentation quality graphs
using the popular xmgrace tool.

 

Example: CosinePlotter class

CosinePlotter.java defines a class that outputs the values of cos(x) for one period.

The cosine is evaluated in a method that is accessed by a method  (aka function) call.

javac CosinePlotter.java

java CosinePlotter

 

Your task:

 

 

 

 

 

 

 

for ( int i=0;i<10;i++){

      System.out.println(“i = “+i);

}

 

 

 

 

Save the file as a postscript file (harmonic.ps) using the print menu and print it out. 

o   Play with the zoom (magnifying glass) and autoscale (AS) buttons on the left hand side

o   Try playing with logarithmic scales, and change the plot title.

 

·       Can you tell what is happening?

 

·       Harder: