# How to Solve Math Problems with Guess-and-Check (Trial-and-Error)

TR Smith is a product designer and former teacher who uses math in her work every day.

Guess-and-check, aka trial-and-error, is a rudimentary though ancient technique for solving a variety of math problems, both simple and complex. When an equation cannot be solved with a formula (or it can but you don't know how) guessing and checking will produce a solution. In some cases, the guess-and-check algorithm can be repeated indefinitely to produce a solution with arbitrary precision. In other cases, the algorithm has a clear termination point. The basic method of trial-and-error is explained below along with several examples to help you solve different kinds of math problems.

## Explanation Guess-and-Check

To solve a problem via trial-and-error, the first thing is to come up with an initial guess for the solution. Then you plug that guess into the equation to see if it provides the correct solution to the problem. If it doesn't, you adjust your guess either up or down and plug that new guess into the equation to see if it works. You repeat the process of adjusting your guesses until you converge on the right answer. Sometimes you may have some intuition of what to guess initially; other times it may be a totally blind guess.

The guess-and-check algorithm stops either when you get the exact right answer, you get close enough to the right answer, or you don't have time to check more cases. Here are examples of each scenario.

## Example 1

The product of five consecutive integers is 360360. What is the smallest of the integers?

For this problem, let's make an initial guess of 7 and check to see if it provides the right answer. If the smallest integer in a set of five consecutive integers is 7, then the full set is {7, 8, 9, 10, 11}. The product of these five numbers is 55440, which is too small. This means we need to adjust our guess upward.

Let's assume that the smallest of the five consecutive integers is 14 so that the set is {14, 15, 16, 17, 18}. The product of these five integers is 1028160, which now too high. Therefore, we know that the correct answer must be larger than 7 but smaller than 14.

It's fairly easy to test all the possibilities because there are only six of them:

{8, 9, 10, 11, 12}, product = 95040
{9, 10, 11, 12, 13}, product = 154440
{10, 11, 12, 13, 14}, product = 240240
{11, 12, 13, 14, 15}, product = 360360
{12, 13, 14, 15, 16}, product = 524160
{13, 14, 15, 16, 17}, product = 742560

Therefore the correct answer is 11.

## Example 2

Solve the equation 2^x + 3x = 40.

An equation like this with a mix of exponents and linear terms cannot be solved algebraically, so we must try to solve it algorithmically.

If we take x = 4 as an initial guess, we get 2^4 + 3*4 = 28, and if we take x = 5, we get 2^5 + 3*5 = 47. Because 40 is between 28 and 47, and because 2^x + 3x is a continuous function of x, the correct value of x must be between 4 and 5. We can also see that increasing the value of x increases the answer on the right-hand side of the equation.

Now let's try x = 4.5, which is halfway between 4 and 5. Using a calculator, we find that 2^4.5 + 3*4.5 = 36.1274, which is closer to 40, but still too small. This tells us that the correct answer is halfway between 4.5 and 5

Let's try x = 4.7. This gives us 2^4.7 + 3*4.7 = 40.0921, which is just a little bit too big. Now we know that the correct answer is between 4.5 and 4.7, and much closer to 4.7

Let's try x = 4.695. This gives us 2^4.695 +3*4.695 = 39.9872, which is a tiny bit too small. As we refine our guesses, we get closer and closer and now we can see that the correct answer is between 4.695 and 4.7.

As one last guess, let's try x = 4.696. This gives us 2^4.696 + 3*4.696 = 40.0081. This is close enough for most practical purposes, so we can conclude that the correct solution is approximately 4.696. If you need more precision than that, you can keep going.

## Example 3

Marya has to build a fence around a piece of her backyard to make a dog kennel. She has only 12 feet of fencing material to build the enclosure, but she can also use two perpendicular lines of existing fence (at the back corner of her yard) to form the walls of the kennel. How should she use her 12 feet of fence and the back corner to maximize the area of the enclosure?

There are many ways Marya can attach the ends of her 12 feet of fence to the existing lines of fence to make an enclosure. If she makes a single right angle bend in the fencing material, she can form a rectangular enclosure. Here are the areas of rectangles obtained from 5-7, 8-4, and 6-6 splits.

The maximum area of a rectangular enclosure is obtained with the 6-6 split that makes a square with an area of 36 square feet. You can prove with calculus that this is the largest rectangle, or you can verify it by trial-and-error.

If Marya keeps the fencing material straight and attaches the ends to the existing corner of fence, she can make a right triangular enclosure. The hypotenuse of these triangles will be 12 feet.

Testing different proportions of triangle Marya finds that the triangle with the largest area is obtained when the width and length are equal, aka an isosceles right triangle. As in the rectangular case, the maximum area is 36 square feet.

Marya decides to test the areas of more complicates shapes. The figure below shows the 12 feet of material curved to form a quarter circular arc, bent in three places to form three sides of a regular octagon, and curved to form a half circular arc.

The quarter-circular arc has the largest area of the three and the largest area of all the shapes she tested. Marya does not feel like testing any more shapes and decides to build the enclosure in the shape of a quarter circle.

This is an example of a problem where trial and error does not have a clearly defined stopping point; the process ends when the tester decides she has examined enough possibilities.

## Tip: Simplify Expressions Whenever Possible

One thing that makes solving any kind of math problem easier is simplification. When the statement of the problem is as short as possible and extraneous variables are eliminated, it makes it easier to work out the problem with trial-and-error.

For example, let's simplify the equation (5x^3 + 13)/(x + 5) = 2x - 3. The trick is to multiply both sides by the term x + 5, which gives us

5x^3 + 13 = (2x - 3)(x + 5)
5x^3 + 13 = 2x^2 + 7x - 15
5x^3 - 2x^2 - 7x + 2 = 0

Now you can use guess-and-check to find the solution or solutions to this equation. If you plug x = 0 into the expression 5x^3 - 2x^2 - 7x + 2 you get a value of 2. If you plug x = 1 into the expression you get a value of -2. This tells you that between 0 and 1 there is some number that will give you a value of 0.

## Guess-and-Check for Multiple Choice Exams

One of the best applications of trial-and-error is on multiple choice math tests. Many times you can get the right answer more quickly by testing the answer choices than by working out the problem by hand. For example, suppose you have to solve the following multiple-choice exam problem:

The average of the set {14, 5, x, 2x, 19} is 13. What is the value of x?

and the five answer choices are

A. 8
B. 9
C. 10
D. 11
E. 12

An easy place to start is with an initial guess of answer choice C, x = 10. This gives you the set {14, 5, 10, 20, 19}, whose average is (14 + 5 + 10 + 20 + 19)/5 = 13.6. This means x = 10 is too large, so you should next test one of the smaller answer choices.

If you choose answer choice A, x = 8, you get the set {14, 5, 8, 16, 20}. The average of this set is (14 + 5 + 8 + 16 + 20)/5 = 12.6. Clearly x = 8 is too small.

The correct answer has to be between 10 and 8, therefore it has to be B, x = 9.

## Limitations of Guess-and-Check

Guess-and-check can be more time-consuming than solving problems algebraically when it is possible to solve them algebraically. In Example 2, there is no algebraic way to find the exact solution to the equation 2^x + 3x = 40, but a calculus technique such as the Newton-Raphson algorithm will give you a very precise approximation very quickly. A graphing calculator can also be used to approximate the solution.

In Example 3, the optimal curve that maximizes the area of the enclosure is in fact a circular arc with an angle of 90 degrees, aka a quarter circle. However, proving that it is the optimal way to bend the fencing material requires more advanced math. Trial-and-error cannot replace more advanced abstract mathematical techniques for proving theorems.

10

2

5

1

26

## Popular

30

9

• ### How to Integrate 1/(x^3 + 1) and 1/(x^3 - 1)

0

0 of 8192 characters used

• Gary 13 months ago

Hi, how do you solve the angle of roof pitch, angle w.r.t. the horizontal. I have a rise of 2.5 feet and a run of 4.75 feet. I drew it on grid paper and measured with a protractor but I would like to know the real way to find the angle with just a pocket calculator. thank you.

• Author

TR Smith 13 months ago from Eastern Europe

Hi Gary, the formula for the angle of roof pitch with respect to the horizontal, as a function of the rise and run, is

arctan(rise/run)

In other words, divide the rise by the run, then take the inverse tangent of that number. On a pocket calculator the inverse tangent button is either labeled arctan or tan -1. You also need to make sure your calculator is set to degrees mode instead of radians mode. (Radians are just another way to measure angles, like how Fahrenheit and Celsius are two different ways to measure temperature.) With your numbers you get

arctan(2.5/4.75) = 27.7585 degrees.