## Instructions

This homework is due on Thursday, September 7th at 12:30pm (the start of class). Please turn in all your work. The purpose of this homework is to set up computational and organizational facilities, and to tinker with R. This description may change at any time, however notices about substantial changes (requiring more/less work) will be additionally noted on the class web page. Note that there are two prongs to submission, via Canvas and Bitbucket. Details below.

### Problem 1: Linux setup (33 pts)

To satisfy this homework problem you must set up a working Linux distribution either via a virtual machine (e.g., VirtualBox) or on a partition of your drive.

• You must do this even if you have an Apple machine, although in this case a virtual machine is strongly preferred.
• Ubuntu and Linux Mint are recommended.
• Install (via apt) and learn a full-featured terminal-based emulator. Vim, via the vim package in apt; Emacs is also acceptable, e.g., emacs24-nox in apt. Both include GUI-based versions, which you may also use but for full credit on you must install and learn the non-GUI version. In particular, you must learn the keyboard commands to edit, save, exit, have multiple files open in a single session and how to toggle between them. No mice.
• Install R via the instructions from CRAN, not some other way.
• You may optionally install Rstudio via apt using the dpkg command.

How will you be graded on this problem? I will speculatively give you full credit, but reserve the right to spot check you and dock points if it turns out that you don’t have these skills/facilities set up properly. Use the “grace period” of this first homework to get help.

• While Apple users must also do these things to satisfy this homework, later in the semester I will allow you to neglect the virtual machine so long as you are able to replicate functionality in the OSX environment.

### Problem 2: Bitbucket repository setup (33pts)

To satisfy this homework problem you must set up a repository on Bitbucket, which will be used for all of your class work. I will follow a similar set of steps in class.

• Set up an account at Bitbucket using your VT email address.
• Set up a Git or Mercurial repository called asc-abc where abc are your initials and invite me (rbg@vt.edu) with read and write access.
• Use the web editing tool to create a short “README” that explains what this repository is for, including your name and email address (mostly for my benefit).
• Set up an ssh key following these instructions. You do not need to enter a passphrase, and you don’t need to enable compression (for Mercurial), unless you want to. Otherwise, follow all steps and install all packages (via apt) as needed.
• Use apt to install git or mercurial.
• Clone the repository via ssh to your new home directory in your Linux installation (Problem 1 above) and rename it (via mv) to either asc-hg or asg-git depending on what you chose. If you have set up your ssh key correctly, you will not need to type your Bitbucket password. I will generically use asc-repo below.
• Configure Git or Mercurial to use your editor (from Problem 1).
• Google “git set editor” or “mercurial set editor” for help.
• Use your command-line editor (from Problem 1) to edit the README.md file (which is the same one you edited above via the web) to explain that the directory called hwk will contain your homework solutions and the directory called notes will contain important things you don’t want to forget. Commit your changes (with a sensible message) and push them to the cloud.
• Create a new directory called hwk. Within hwk, create a README.md file explaining that hw1 will contain your solutions to the first homework. Then create a new directory called notes and within that create a README.md file explaining that this directory will be used for saving your important notes. To start that out, create a text file called unix.txt which lists the unix commands you have seen/used so far, one on each line, followed by a short explanation of what it does. Add all of the new files and commit them (with a sensible message), then push them to the cloud.
• Continue to update unix.txt with commands as you encounter them, add/commit and push.

Some words of caution: Version control repositories are for source files, not their output or other temporary files. An exception may be pdf figures generated from those files which you intend to include in other (e.g. LaTeX) documents.

### Problem 3: Optimization (34 pts)

Write an R function returning $f(x) = 1 - x + 3x^2 - x^3, \quad x \in [-0.5, 2.5].$

1. Plot the function over that range and note the critical points. Check them against the truth (via calculus).

2. Use an R library function to find those critical points numerically, and check them against the plot/truth.

3. How many iterations (as counted by the number of evaluations of your R function) did it take to find each critical point?

To “turn in” this homework solution you must do two things.

1. Push the relevant source files to asc-repo/hwk/hw1. Use hw1/README.md to explain what I will find in this directory when I pull it. You must have a single master R file (either a .R or .Rmd) which, when sourced (or compiled) fully reproduces your analysis, i.e., the one in the pdf mentioned in part 2. below. You may source other .R files with your master R file. Choose the names of your files to be concise (ideally less than ten characters) yet descriptive. I should not have to edit your code to make it work. However, if you use packages I don’t have installed, I will gladly install them.
2. You must submit a PDF to Canvas providing the writeup for this solution, which is generated by the source file in part 1.

For full credit on Problem 2 you must have multiple substantial commits to your to the files in asc-repo/hwk/hw1 with understandable commit messages. The rule of thumb is that if you have been working for more than an hour it is probably time for a commit; definitely commit and push before you stop working for the day.