COMPUTATIONAL TOOLS

Graphing Tools

We need to plot data. We'll use a package called gnuplot (pronounced "new-plot").


Exercise #1

Plot the following data by first copying to a file, and then using gnuplot to read and plot from that file.


 1   -13.600 
 2   -3.400 
 3   -1.511 
 4   -0.850 
 5   -0.544 
 6   -0.378 
 7   -0.278 
 8   -0.213 
 9   -0.168 
10   -0.136 

NEXT


High Level Languages Answer? COMPRIMISE The set of instructions in the high level language is called the source code.

The interpreter that translates the source code into machine code is called the compiler.

High Level Languages

NEXT


Simple Programming

Skeleton Code
NEXT


Example 1


    program picalc
c    This is a program that calculates the value of pi
c    using the intrinsic funtion asin. The value of pi
c    written to the screen after it is calculated.
    real pi

    pi = 2.0 * asin(1.0)
    print *, 'pi = ',pi

    end program picalc


In C++ this program looks like this...
(See the online notes from CSC 114)

//This is a program that calculates the value of pi
//using the intrinsic funtion asin. The value of pi
//is written to the screen after it is calculated.

#include < iostream>    // this is needed for output to screen
#include < math.h>         // this is needed for the asin function

int main(){

double pi;

pi = 2.0 * asin(1.0);
cout << "pi = " << pi << endl;

}
NEXT


Example 2


    program deg2rad
c    This program calculates the radian equivalent of
c    angles in degrees, for every 10 degrees from 0 to 180.
c    This data is written to a file called 'data.dat' on unit 10.
    real pi, degs, rads

    pi = 2.0 * asin(1.0)

    open(unit=10,file='data.dat')

    do degs = 0.0, 180.0, 10.0
        rads = degs * pi / 180.0
        write(10,*) degs, rads
    enddo

    close(10)

    end program deg2rad



// This program calculates the radian equivalent of
// angles in degrees, for every 10 degrees from 0 to 180.

#include < iostream>
#include < math.h>

int main(){

double pi, rads;
pi = 2.0 * asin(1.0);

for(double degs = 0.; degs <= 180.; degs += 10.;){
  rads = degs * pi / 180.;
  cout << degs << "   " << rads << endl;
  }

}
NEXT


Intrinsic Functions
NEXT


Compiling & Executing Code
NEXT


Exercise #2
NEXT


LaTeX
NEXT


HTML