Math 578 - Alexiades
                                      Lab 1
                            Warmup programming and plotting

For each assignment, you should create a directory (folder) and work in it, so all files pertaining to the assignment will be in one place.
A good name for this assignment may be: Lab1 . Always read the entire assignment before you start doing it...

1. Write a code that evaluates  f(x) = a − bx3  at N equidistant points in [0,1],
  and outputs the pairs x , f(x) in a file named "values". Ask the user to enter a,b,N, or read them from a data file.
  Try a = −1. , 0. , 1 ,   b = 0.1 , 1. , 5. ,   N=20

(Start aquiring good programming habits: In your code enter your name, date, title, a brief description of what it does, document the main steps, etc )

For plotting, I strongly recommend gnuplot , see links on course page. Very simple to use and powerful.

2. Use gnuplot to display the graph in each case
      gnuplot>   plot "values" with points
  Check it with (for example,   a=1 , b=0.5) :
      gnuplot>   plot   [0:1]   1−0.5*x**3   with lines
  You can plot both your "values" and this curve on the same plot:
      gnuplot>   plot   "values"   with points,   1−0.5*x**3   with lines
  Here is a fancier version, specifying line type (lt) and line width (lw):
      gnuplot>   plot   "values"   with points lt 3 lw 3,   1−0.5*x**3   with lines lt 1 lw 2
  ( useful line types:   red: 1 , green: 2 , blue: 3 , magenta: 4 , black: 7 or 0 or −1 )
  In fact, you can enter formulas in gnuplot, like:
      gnuplot>   f(x)=a−b*x**3 ; a=1 ; b=0.5 ;  plot  [0:1]  f(x)  w  lines  lt 2  lw 3
  then only need to modify a, b and replot, like:  gnuplot> a=0 ; b=−5 ; replot
  [Better yet, can put these in a script file, see examples at bottom, ... gnuplot is very convenient and versatile... ]

  Play with N, to see how many points you would need to "trace out the curve"
  (minimum number needed to capture the shape of the curve with just the points),
  it is vague on purpose... interpret appropriately...

Most everything you need to know is in the How-To and On-line Resources links on the M578 web page. Check them out!
Once you get a good fit on screen, if you want you may save the plot into a .ps file (see gnuplot - How to print ).

4. Now run your code with: a=3,  b=2,  N=10.
  Email me (alexiades@utk.edu and Cc: to yourself),
  with Subject: "M578 lab1" the following:
in a single plain text mail message, NO attachments:
    - your code
    ============================================== (separator line)
    - the input and output from it (ONLY for N=10 !!!).
    ============================================== (separator line)
    - What value of N worked well in Part 2 ?

5. Get into good habits: clean up any junk files and the executable
  (since it can easily be generated by compiling), keeping only
  the useful files (code, input, output, lab1.txt).

                    All done !
Impressive examples of gnuplot scripts: trochoids spiro2.gp , spiro3.gp   Try them!
Also see my gplot scripts.