The C++ compiler on our system is called g++. In most cases all you will need to do is
g++ program.cc -o programto create an executable version of your program. Finally,
./program
python program.pyto run it.
Simply put, if you want to graph two functions, f(x) and g(x), say, then write the functions in your program and include (in C++) a loop of the form
for (x = xmin; x <= xmax; x += dx) cout << x << " " << f(x) << " " << g(x) << endl;An equivalent Python code fragment might be
x = xmin while x <= xmax: print x, f(x), g(x) x += dxTo plot the graphs on the screen, type
./program | gpl -c 1 2 3or
python program.py | gpl -c 1 2 3To save the graphs in a file, type
./program | gpl -c 1 2 3 -P > graph.ps(and similarly for the Python code).
Don't worry about the details of getting multiple plots on a single graph -- we'll cover that later.
The gpl program was developed to simplify the plotting process, especially in C++, but note that Python has several very capable packages that can handle graphics internally. For more information on two of them, try googling "python gnuplot" or "python matplotlib." Feel free to use these packages (or another) if you like.
The current course syllabus calls for homeworks to be submitted as hard-copy. However, as an experiment, you can if you wish submit Homework 1 by e-mail. To do so, please do the following.
zip -r HW1.zip HW1or into a tar archive with
tar cf HW1.tar HW1and e-mail the archive to me.