# Simple math - rounding off results

## Recommended Posts

In my dotage I've decided to revisit a textbook I still have from a class I took about 10 years ago. The book is Basic Technical Mathematics with Calculus (Seventh Edition) by Allyn J. Washington (Addison Wesley Longman, publisher).

The specific problem is meant to illustrate the correct rounding techniques as they apply to practical math problems. These techniques concern accuracy (significant digits in multiplication and division) and precision (the decimal position of the last significant digit in addition and subtraction).

The problem is presented as follows:

(3872/503.1) - (2.056*309.6/395.2)

I first evaluated each of the groupings using the principle that the individual results should be accurate to four significant digits. My interim result was thus: 7.696 - 1.611

I then performed the subtraction based on the premise that the precision of the result should match the least precise number in my interim result (thousandths): Answer = 6.085

The book provides an answer to this problem (without explanation) of 6.086

If I don't round off any of my results, the final answer I get (to seven significant digits) is 6.085611 Rounding this off to four significant digits will, of course, produce the 6.086 given answer.

This leads me to believe that only the final result of this calculation should be rounded off. The complication in my mind is that the final answer is the result of the subtraction of one number from another (both numbers being, themselves, the product of a prior multiplication operation).

I notice that all of the original values are given to four significant digits. Is this the criteria by which only the final answer should be rounded off?

I realize that this produces a very minor difference in the final answer, but I'd like to be sure that I understand how these rules for rounding off should be applied.

Chris

##### Share on other sites

Yes, generally one performs the intermediate steps keeping all of the digits (as much precision as possible), and only rounds the final answer.

##### Share on other sites

Yes, generally one performs the intermediate steps keeping all of the digits (as much precision as possible), and only rounds the final answer.

Thanks.

Let's see if I "get it", though. If the original grouped numbers had been different, for instance:

(3872/64) - (2.056*309.6/395.2) , my interim result would be 60.5 (exactly) - 1.610672 and my unrounded result would be 58.889328. If I apply the rule that the least precise interim result should dictate the precision of the final result, I would have a rounded answer of 58.9. If, on the other hand, I apply the rule that the final result shouldn't be more accurate than the least accurate initial figure - the result should be rounded to two significant digits: 59

In the original problem, the initial values were all accurate to four significant figures - and the final answer was also taken to four significant digits. As I now understand it, the accuracy of the initial values (when powers, multiplication, division, addition and subtraction are all part of the calculation) dictate the accuracy of the final result. If a calculation involves only addition and subtraction of terms, the least precise initial term dictates the precision of the final result.

Is this a fair description of how these rules are applied?

Chris

##### Share on other sites

So the rules depend on whether you're doing addition and subtraction or multiplication and division.

If I take two numbers and multiply them, the final result must have the same number of significant digits as the least precise initial term:

$55.7 \times 432.678 = 24100$

If I take two numbers and subtract or add them, the final result must have the same number of decimal places as the initial term with the fewest decimal places:

$55.7 - 32.468 = 23.2$

Interim results should be kept to full precision, and you should only round your final results.

I'm actually not sure how this applies to compound expressions like the example you gave. I think you've done the right thing, but I'm not entirely sure.

##### Share on other sites

Thanks again. I think I'll try to follow the rule as I now understand it - unless I get information to the otherwise.

Chris

##### Share on other sites

Yes, generally one performs the intermediate steps keeping all of the digits (as much precision as possible), and only rounds the final answer.

Well the error doesn't accumulate all that quickly.

For all but the most convoluted calculations, two or three guard digits¹ should be enough. Even one is sufficient for most cases.

So if you were calculating 2.056*309.6 with one guard digit, you would store 636.54 as the interim value.

Then

646.54/395.2 = 1.6107

3872/503.1 = 7.6963

7.6963 - 1.6107 = 6.0856

Then round to get: 6.086

I've bolded all of the significant digits for clarity.

You can see that the extra guard digit absorbs the rounding error (which is smaller because there's an extra digit) to 'guard' your significant digits.

The rounding error will sometimes build up and flow into the next digit, but it takes a lot of calculations for it to do so.

¹a digit that you keep in your calculations beyond the precision you're working to.

##### Share on other sites

Well the error doesn't accumulate all that quickly.

For all but the most convoluted calculations, two or three guard digits¹ should be enough. Even one is sufficient for most cases.

So if you were calculating 2.056*309.6 with one guard digit, you would store 636.54 as the interim value.

Then

646.54/395.2 = 1.6107

3872/503.1 = 7.6963

7.6963 - 1.6107 = 6.0856

Then round to get: 6.086

I've bolded all of the significant digits for clarity.

You can see that the extra guard digit absorbs the rounding error (which is smaller because there's an extra digit) to 'guard' your significant digits.

The rounding error will sometimes build up and flow into the next digit, but it takes a lot of calculations for it to do so.

¹a digit that you keep in your calculations beyond the precision you're working to.

Thanks for that additional input SH. It makes sense.

My initial confusion originated because I was uncertain about the roles that accuracy (significant digits) and precision (the placement of the last significant digit relative to the decimal point) played in complex operations. I clearly understood that calculations involving only multiplication and division (or powers and roots), the number of significant digits initially presented determine the significant digits contained in the result (regardless of the placement of the decimal point).

Conversely, I understood that in operations involving only addition and subtraction the precision of the initial value dictates the precision of the result.

The textbook I cited doesn't explicitly state the precedence of accuracy over precision in complex operations involving multiplication, division, addition and subtraction. Naturally, the text clearly states that addition and subtraction of terms are the last operations to be performed. The exercises illustrate this precedence, though. The small difference between my result and the textbook's correct answer in one of these exercises led to my original question. Your suggestion that two or three guard digits should be retained in the interim results of complex operations (entered sequentially) is one that I'll remember. As your illustration shows, following that principle eliminates the discrepancy I originally encountered.

Upon reflection, it seems only logical that the accuracy of the initial values (as approximate numbers) in complex calculations must dictate the accuracy of the final result. As you know, if such calculations are entered in a calculator as a continuous formula, the result will very probably be shown to 8 (or 10) significant digits.

Chris

##### Share on other sites

Thanks for that additional input SH. It makes sense.

My initial confusion originated because I was uncertain about the roles that accuracy (significant digits) and precision (the placement of the last significant digit relative to the decimal point) played in complex operations. I clearly understood that calculations involving only multiplication and division (or powers and roots), the number of significant digits initially presented determine the significant digits contained in the result (regardless of the placement of the decimal point).

Conversely, I understood that in operations involving only addition and subtraction the precision of the initial value dictates the precision of the result.

There is a precise mathematical relation which relates all these.

Unfortunately understanding it requires a reasonable helping of calculus, vectors and statistics.

If you're interested, I've been meaning to draw up some diagrams which explain the idea behind the formula for a while now, but I'm a bit busy right now.

Remind me/make this thread active in a few days and I may get around to it.

##### Share on other sites

There is a precise mathematical relation which relates all these.

Unfortunately understanding it requires a reasonable helping of calculus, vectors and statistics.

If you're interested, I've been meaning to draw up some diagrams which explain the idea behind the formula for a while now, but I'm a bit busy right now.

Remind me/make this thread active in a few days and I may get around to it.

As it turns out, the book I'm using for self-study (Basic Technical Mathematics with Calculus (Seventh Edition) by Allyn J. Washington (Addison Wesley Longman, publisher) introduced this subject of accuracy and precision in Chapter 1 on page 12. It covers it in a very cursory way as introductory material for the more advanced math that is the main focus of the textbook.

The subject of statistics is introduced in Chapter 22 (pg 592), differential calculus is introduced in Chapter 23 (pg 628) and integral calculus is introduced in Chapter 25 (pg 715). Since I'm determined to thoroughly study this textbook from cover to cover you can appreciate the fact that I'm now taking the first steps on what (for me) will be a rather long journey.

I look forward to futher explanantions of these fundamental concepts (accuracy and precision) and I'll revisit this thread from time to time to take advantage of any insight that you and the other members can provide. This isn't time-critical, though. I expect to be immersed in this self-study project for quite a while.

Thanks,

Chris

##### Share on other sites

Re. my promise. The general formula for maximum error in a calculation involving two variables is as follows:

First of all, some notation:

Some of this might be a bit new and scary, but try to bear with me. Feel free to ask any questions.

$\Delta x$ denotes the error, or some small change in x.

$f(x,y)$ is a function involving x and y, some process involving two numbers which produces a third. Using a name that isn't a single letter can help provide a bit of intuition for this.

$\text{product}(x,y) = x\times y$ would be saying: The product of x and y is defined as $x\times y$.

In the same way, something like $f(x,y)=2x+y$ could be read as: f of x and y is 2x + y.

If you have a function $f(x,y)$ maybe it's $x+y$ or $x\times y$ and you want the error ($\Delta f$ in it due to some error in x or y -- $\Delta x$ or $\Delta y$, which is small compared to the value of x or y.

Then the maximum error can be calculated with:

$\Delta(f(x,y)) = \left(\;\left. \frac{\partial f}{\partial x}\right|_{y=y_0}\right)\Delta x + \left(\;\left. \frac{\partial f}{\partial x}\right|_{x=x_0}\right)\Delta y$

This is a big scary function, especially to those who are new to calculus, but its meaning is not too hard to comprehend.

The worst things are the partial derivatives: $\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=y_0}\right)$

But all they are really sayings is 'how much does f change, if we change $x$ by a little bit while keeping $y$ at $y_0$

You can think of it this way:

If I was standing on a hill, how much would my altitude $f$ increase for each metre I walk east (change $x$) providing I don't walk north or south (keep $y$ at $y_0$)

If you've learned a bit of calculus before you would have seen $\frac{df}{dx}$ and similar.

$\frac{\partial f}{\partial x}$ is very nearly the same constant, but it's for functions of more than one variable. Basically it's saying 'pretend this function is only a function of x, then differentiate it normally.

The bit beside the line $|_{y=y_0}$ is just telling us what value to keep $y$ at.

So we might have $f(x,y) = x^2\times y$ then to evaluate the partial derivative at $y=3$

or $\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=3}\right)$ we'd do two steps:

First hold y constant: giving us $f(x,y) = 3x^2$

Then take the x derivative $\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=3}\right) = \frac{d}{dx} 3x^2 = 3\times 2x = 6x$

Right. Let's apply this to some functions. What we were here for in the first place.

Let's say we have $f(x,y) = x+y$

Then our partial derivatives are: $\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=y_0}\right) = \frac{d}{dx}\left(x+y_0\right) = 1$ and

$\left(\;\left. \frac{\partial f}{\partial y}\right|_{x=x_0}\right) = \frac{d}{dx}\left(x+y_0\right) = 1$

Well, that big scary equation wasn't so hard after all.

This means our error is: $\Delta f = 1\times\Delta x + 1\times \Delta y$

Let's look at some real numbers, we might have 1.2232 + 1.6

But if these were rounded they could have been anywhere from 1.22315 to 1.2232499999... and 1.55 to 1.64999....

So we have a maximum error of $\Delta x = 0.00005$ and $0.05$ respectively.

We plug everything into our equations and we get $f = 1.8232$ with an error of $0.05005$

The error means the true number could be anywhere between 1.7727 and 1.8737.

Writing down anything past the 8 as our answer is meaningless, because it could change by so much.

So we write 1.8

But if we use that in our calculations, we effectively introduce another maximum error of 0.05, because our 1.223 could have been 1.249 or 1.15 or anything in between and we would have got the same answer.

We can record the fact that it was 1.22 by writing 1.82 as our intermediate value.

This introduces an extra error of up to 0.005.

This is a lot better than 0.05, because 0.05 can change our meaningful digit (the 8 in 1.8) in two steps. Whereas 0.05 takes 20 steps.

Below is a similar concept in graphic form:

The colorful mesh represents the function x+y by being set at the height of its x coordinate plus its y coordinate.

If we'd recorded and previously rounded two numbers to 4 and 12, they could have been anywhere between 3.5 and 4.499... and 11.5 and 12.4999... respectively.

So our position on the grid could be anywhere at the base of the rectangular prism.

The function x+y takes on a value for every point on the grid so we could be at any point in the tilted square.

The partial derivative$\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=y_0}\right)$

Would be asking: How fast do I go up, by going right along one of the grid lines and staying on the colored surface?

and the other derivative: $\left(\;\left. \frac{\partial f}{\partial y}\right|_{x=x_0}\right)$

Would be asking : How fast do I go up, by going into the page along one of the grid lines and staying on the colored surface?

The $\Delta x$ and $\Delta y$ would be the width and length of that column, and $\Delta f$ is the change in height from the highest point on top of the column to the lowest point on top of the column.

We aren't limited to just addition for this concept. Here's a similar diagram for $f(x,y) = x\times y$

More in the sequel.

I'll let y'all digest that and take a bit of a break from writing.

Edited by Schrödinger's hat
##### Share on other sites

Thanks SH for your reply. The math is still beyond my level of complete understanding, but I understand the general idea and the logic of your presentation.

The graphic representations are very helpful. They illustrate that old adage that "...a picture is worth a thousand words..."

I'm encouraged by your response. It's my goal to be able to understand calculus and its associated requisite mathematical concepts so that I have a clear understanding of exactly the type of explanation you've provided. Presenting examples in graphical form is brilliant.

Chris

##### Share on other sites

Continuing from where I left off.

With $f=xy$, our partial derivatives are no longer constant.

If we change $x$ by a little bit, the amount $f$ changes depends on y.

You can see this easily enough, even without calculus.

If we take $f(x+\Delta x,y)=(x+\Delta x)y = xy + \Delta x y$.

So the amount f changes when we change x by a small amount depends on the value of y, or

$\left.\frac{\partial f}{\partial x}\right|_{y=y_0} = y_0$

Same goes for $y$ at $x_0$.

So our error formula for multiplication winds up being:

$\Delta f = y\Delta x + x\Delta y$

Now if we have a certain number of significant digits for $x$, call it $n$, and a certain number of significant digistfor $y$, call it $m$, then we know that the maximum values for the errors in each term are less than:

$\Delta x = \frac{x}{10^{n-1}}$ and $\Delta y = \frac{y}{10^{m-1}}$

Looks complicated, but this is just a way of saying 'the last significant digit might vary'.

An example might help:

Say we have: 10.2

Then $\frac{10.2}{10^{3-1}}=0.102$

In truth this is an overestimate, because we might have 9.3, divide by 10 to get 0.9

No matter how bad our rounding error, we know the original number was in the range of 9.25 to 9.3499... so 0.9 is an overestimate, but an upper bound is all we need to illustrate why it's the number of digits that matters.

Using this information, we go back to the equation $\Delta f = x\Delta y + y\Delta x$ and plug in our values to get:

$\Delta f = \frac{xy}{10^{n-1}} + \frac{xy}{10^{m-1}}$

Or a number n digits smaller than xy plus a number m digits smaller than xy

If m and n are different, one of these will be ten, a hundred, or thousands of times as big as the other, so we only need to calculate our error from the number with the least significant digits.

So our answer will have meaningful digits up to the mth or nth digit from the left, whichever is smaller.

Using some real numbers with more exact rounding error.

$345.92 \times 0.164$

The maximum errors that we might have accumulated if we'd produced these by rounding another number are 0.005 and 0.0005.

Our non-rounded result is 56.731

Our error will be $345.92\times 0.164 \times 0.05 + 345.92\times 0.164 \times 0.005$ or

$0.28 + 0.028$

We can throw away the 0.028 because really only the 0.28 matters.

This will change everything up to the third digit, so we round to

56.7

Although our error is big enough to change the 7, we still write it down because it carries some information. On top of this rounding would change the 6.

Hopefully this makes it clear why we use number of digits for multiplication.

Edited by Schrödinger's hat
##### Share on other sites

Thanks SH. It will take a while for me to fully appreciate the calculus aspect of your explanation. Even without a solid grounding in the math, though, I can still get the gist of the logic involved.

I hope to revisit your posts again later when I'll be able to appreciate the step-by-step advanced calculations that explain this rather fundamental concept. In between times, I'll rely on keeping 2 or 3 "guard digits" in my intermediate calculations. For my immediate purposes this should suffice for the textbook questions I'll be working.

Chris

##### Share on other sites

Thanks SH. It will take a while for me to fully appreciate the calculus aspect of your explanation. Even without a solid grounding in the math, though, I can still get the gist of the logic involved.

I hope to revisit your posts again later when I'll be able to appreciate the step-by-step advanced calculations that explain this rather fundamental concept. In between times, I'll rely on keeping 2 or 3 "guard digits" in my intermediate calculations. For my immediate purposes this should suffice for the textbook questions I'll be working.

Chris

And that's without getting into the statistics aspect of things. I don't think I'll worry you too much with that. The basic idea is: we don't have to worry as much as we thought about error building up, because the errors in different directions cancel out most of the time. Using statistics we can figure out when we have a 99% chance or 60% or whatever of the errors not building up to a point that it matters.

I'm always surprised by how complex/involved the answers to simple concepts can get. You can usually simplify it significantly with hand-waving, but there's usually at least a few 'why's left over.

Reminds me of this.

Also, I was going to make a few more diagrams to make it more digestable, but I got a bit impatient/lazy.

##### Share on other sites

Thanks SH. I learn a lot from your post.

## Create an account

Register a new account