# Integrating WeBWorK into Textbooks: Sample Exercises

## Section1.1Arithmetic

A simple, but functional example to begin with. If you are just learning how to add, you can test yourself here.
Compute the sum of $$6$$ and $$1\text{:}$$
$$6 + 1 =$$
$$7$$
Solution.
$$6 + 1 = {7}\text{.}$$
That was a simple problem. Let’s move on.
If you are familiar with WeBWorK, then it may be a surprise to you to be interacting with a WeBWorK problem this way, without having logged in to WeBWorK.

### Checkpoint1.1.2.Declaring a Problem Seed.

You can also declare a seed to specify a version of any problem that has randomization. Here is the same problem (“copied” in the PreTeXt source), but with a seed specified.
Compute the sum of $$5$$ and $$8\text{:}$$
$$5 + 8 =$$
$$13$$
Solution.
$$5 + 8 = {13}\text{.}$$

You can code your problem with randomization, but then use a specific seed and WeBWorK’s envir{problemSeed} to override that randomization for the purposes of the version that will appear in HTML and print output. Compute the sum of $$1$$ and $$2\text{:}$$ $$1 + 2 =$$ Answer. $$3$$ Solution. $$1 + 2 = {3}\text{.}$$ ### Checkpoint1.1.4.Special Answer Checking. One of the strengths of WeBWorK is its ability to give intelligent feedback for incorrect answers. • There is general feedback for when the student’s answer is in an entirely different ballpark from the correct answer. Try entering something like “y”. • There is general feedback for when the student’s answer is not in the right form. Try entering “x^2*x^3”, which, right or wrong, is unsimplified. • And problems can be written to detect and respond to common mistakes. Try entering an answer where you multiply the two exponents (instead of adding them, which would be correct.) Use the properties of exponents to simplify $${x^{5}x^{3}}\text{.}$$ $${x^{5}x^{3}}=$$ Answer. $$x^{8}$$ Solution. We add the exponents as follows, while including a gratuitous reference to the quadratic formula: \begin{equation*} \begin{aligned} {x^{5}x^{3}}\amp =x^{5+3}\amp \text{Theorem 1.2.1}\\ \amp =x^{8} \end{aligned} \end{equation*} ### Checkpoint1.1.5.Using Hints. Hints can be inserted into exercises. Whether a hint is visible in the HTML depends on the value of showHint in PGcourse.pl in the WeBWorK course that is hosting these exercises. How the hint is displayed in the pdf output is controlled in the usual way that an PTX hint is controlled.
Simplify the expression $${\sqrt{48}}\text{.}$$
$${\sqrt{48}}=$$
Hint.
Factor the number inside the radical.
$$4\sqrt{3}$$
Solution.
\begin{equation*} {\sqrt{48}}=\sqrt{4^2\cdot 3}=4\sqrt{3} \end{equation*}

### Checkpoint1.1.6.No Randomization.

This problem has no randomization at all, not even if it were exported to be part of a problem set on a WeBWorK server. As such, it really doesn’t need any lines of Perl code in its setup, so you have the option of skipping that part of the authoring process.
$$1+2=$$
$$3$$
### Project1.1.1.Inside a <project>.
If you like, you can have a WeBWorK inside a PROJECT-LIKE block. Just like with an <exercise>, it can be preceded with an optional <introduction> and followed by an optional <conclusion>.
Compute the sum of $$6$$ and $$5\text{:}$$
$$6 + 5 =$$
$$11$$
$$6 + 5 = {11}\text{.}$$