MAS116/MAS117 PRESENTATION LAB 1

In this lab we will use LaTeX within a software bundle called MiKTeX (pronounced ‘mik-tek’) to create basic mathematical documents.

1. Getting started with MikTeX

Log on to a university Windows machine, then check to see if MiKTeX is installed on the computer by typing texworks into the search box at the bottom of the screen. If it’s not there, you need to install it from the Software Center on the desktop.

The Software Center may take a minute or two to work properly. If it’s not responding, wait, then press F5.

Once MiKTeX is installed, start TeXWorks.

Delete any text that appears in the left-hand source pane and carefully type the text below.

    \documentclass[11pt, a4paper]{amsart}
    \begin{document}

    Hello!  Here is $f(x) = \frac{e^x}{1 - x}$ inline.
    Here it is bigger on a new line:
    \[
        f(x) = \frac{e^x}{1 - x}.
    \]

    Here is an integral:
    \[
        \int \cos(x) dx = \sin(x) + c.
    \]

    \end{document}

Click on the big green triangle, but make sure it says pdfLaTeX and not pdfTeX by the side. If you’re asked to save your file, make a folder in Documents on your U: drive called mas116_latex (or mas117_latex) and use the filename lab_1.tex.

A PDF document should appear; note that the first run might take several seconds.

If the green triangle has turned into a red cross and no PDF has appeared after a little wait, click on the red cross, check your typing carefully and try again. If you still have problems, ask for help.

You can use ctrl-T as a keyboard shortcut for clicking the green triangle.

By comparing the source code (the text you typed) with the output, do some experimenting to answer the following questions, pressing the green traingle each time to see the result. Note down your answers.

(1)
What is the point of the $-signs in the source code? Does it work without them? What happens if you type f(x) without $-signs?
(2)
What about is the purpose of “backslash square brackets”, \[ and \]? (Try turning them into $-signs or vice-versa.)
(3)
What happens if you type the following without the newlines and spaces that we had before?
  Here is an integral: \[\int\cos(x)dx=\sin(x)+c.\]
Just as you will find with programming, it will make your life much easier when editing (which you will do a lot of) if you make your source .tex file nice and readable from the beginning.
(4)
What has the \frac command done?

2. Looking at the document

Here, you’ve created your first LaTeX file (pronounced ‘lay-tek’). LaTeX is a mark-up language used for creating good quality mathematical documents. Every LaTeX file starts with a \documentclass command. We are using the American Mathematical Society (AMS) ‘article’ class, hence amsart.

The main content is put between \begin{document} and \end{document} commands. Maths must go inside $-signs if it’s inline, or inside \[\] if it needs to be displayed large on its own line (called displayed mathematics or display math). You will sometimes see $$...$$ for displayed mathematics but \[\] is preferred.

Let’s do some more experimenting.

(5)
Usually you should leave LaTeX to put in the correct spacing in mathematics, however, one exception is in an integral where there is usually a small space before the dx. You can do this by typing \cos(x) \, dx.
(6)
What happens if you change the \int command into \int_0^\pi? Finish off the calculation of the definite integral in your document (including something like “ = [sin (x)]0π = ”).
(7)
Change the first paragraph so it reads

“Let f(x) = ex 1x. Then

f(x) = ,

completing the line by calculating the derivative of f by hand and typing it in. Show the steps in your workings by including them as part of the line beginning “f(x) = ”.

(8)
Change the second paragraph so it reads

“Because the derivative of sin (x) is cos (x), it follows that

0π cos (x)dx =

where the last line is finished as in question 6.

(9)
Did you remember to use $-signs and backslashes with the sin (x) and cos (x) in the previous question, as in $\cos(x)$?

Something that might improve things further is align equals signs, as in

0π cos xdx = [sin x] 0π = sin π sin 0 = 0.

One way to do this is to use the \begin{align*} and \end{align*} commands, as in the following.

    \begin{align*}
        \int_{0}^{\pi}\cos(x) \, dx
        &= [\sin x]_{0}^{\pi} \\
        &= \sin \pi - \sin 0 \\
        &= 0.
    \end{align*}

Here, the ampersand, &, is placed before the symbol you want aligned, and a double-backslash, \\, is placed at the end of a line. Experiment with this on the workings you had completed earlier on.

3. Adding structure to the document

We will now give the document some structure. Between \begin{document} and the first paragraph, put the line \section{Differentiation}. Before the second paragraph, put the line \section{Integration}. Your PDF output should now have sections.

Let’s make things look even better with a title.

(10)
Above the \begin{document} command, put the command
\title{Calculus examples}, then process the file. Any change? See below if not.
(11)
The \title{} command works differently to the \section one. Type \maketitle after \begin{document}. Now process the file. This time it should work.
(12)
Add \author{(your name)} under \title{Calculus examples}, and process the file again.
(13)
See what happens if you put \date{September 1684} just after the \author{...} command. What about using \date{\today} instead?

This document is pretty much finished. Add a new section called ‘Formulas’ and try to typeset the main three differentiation rules (product, quotient and chain) along with the formula for integration by parts. Look them up if you’ve forgotten them! _______________________________________________________________

Homework

In response to a homework question, a student handed in the following.

ex cos x ex sin x + ex cos x (chain rule)
ex(cos x sin x)
= 0
cos x = sin x = tan x = 1
π4

Your job is to try and work out what question was asked, then write a much better solution using LaTeX, correcting errors and improving the solution above as much as possible. Be sure to read through the first lecture again before doing this.

Your document should have two sections, ‘Question’ (where you state your guess at the question) and ‘Solution’. Your solution doesn’t need to be long, but should include significantly more words than the badly written one above.

This homework counts towards the homework component of your module mark, as do all the weekly presentation homeworks. As such this must be all your own work: you must not plagiarise or collaborate with other students, and you must not use AI tools.

If you have problems then feel free to use the Discussion Board on Blackboard or Simon Willerton’s office hour.