csmyth3025 Posted October 3, 2011 Share Posted October 3, 2011 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 Link to comment Share on other sites More sharing options...

Cap'n Refsmmat Posted October 3, 2011 Share Posted October 3, 2011 Yes, generally one performs the intermediate steps keeping all of the digits (as much precision as possible), and only rounds the final answer. Link to comment Share on other sites More sharing options...

csmyth3025 Posted October 3, 2011 Author Share Posted October 3, 2011 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 Link to comment Share on other sites More sharing options...

Cap'n Refsmmat Posted October 3, 2011 Share Posted October 3, 2011 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: [math]55.7 \times 432.678 = 24100[/math] 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: [math]55.7 - 32.468 = 23.2[/math] 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. Link to comment Share on other sites More sharing options...

csmyth3025 Posted October 4, 2011 Author Share Posted October 4, 2011 Thanks again. I think I'll try to follow the rule as I now understand it - unless I get information to the otherwise. Chris Link to comment Share on other sites More sharing options...

Schrödinger's hat Posted October 4, 2011 Share Posted October 4, 2011 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. Link to comment Share on other sites More sharing options...

csmyth3025 Posted October 4, 2011 Author Share Posted October 4, 2011 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 Link to comment Share on other sites More sharing options...

Schrödinger's hat Posted October 6, 2011 Share Posted October 6, 2011 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. Link to comment Share on other sites More sharing options...

csmyth3025 Posted October 7, 2011 Author Share Posted October 7, 2011 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 Link to comment Share on other sites More sharing options...

Schrödinger's hat Posted October 8, 2011 Share Posted October 8, 2011 (edited) 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. [math]\Delta x[/math] denotes the error, or some small change in x. [math]f(x,y)[/math] 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. [math]\text{product}(x,y) = x\times y[/math] would be saying: The product of x and y is defined as [math]x\times y[/math]. In the same way, something like [math]f(x,y)=2x+y[/math] could be read as: f of x and y is 2x + y. If you have a function [math]f(x,y)[/math] maybe it's [math]x+y[/math] or [math]x\times y[/math] and you want the error ([math]\Delta f[/math] in it due to some error in x or y -- [math]\Delta x[/math] or [math]\Delta y[/math], which is small compared to the value of x or y. Then the maximum error can be calculated with: [math] \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[/math] 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: [math]\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=y_0}\right)[/math] But all they are really sayings is 'how much does f change, if we change [math]x[/math] by a little bit while keeping [math]y[/math] at [math]y_0[/math] You can think of it this way: If I was standing on a hill, how much would my altitude [math]f[/math] increase for each metre I walk east (change [math]x[/math]) providing I don't walk north or south (keep [math]y[/math] at [math]y_0[/math]) If you've learned a bit of calculus before you would have seen [math]\frac{df}{dx}[/math] and similar. Don't worry about this section if you haven't done derivatives before. [math]\frac{\partial f}{\partial x}[/math] 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 [math]|_{y=y_0}[/math] is just telling us what value to keep [math]y[/math] at. So we might have [math]f(x,y) = x^2\times y[/math] then to evaluate the partial derivative at [math]y=3[/math] or [math]\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=3}\right)[/math] we'd do two steps: First hold y constant: giving us [math]f(x,y) = 3x^2[/math] Then take the x derivative [math]\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=3}\right) = \frac{d}{dx} 3x^2 = 3\times 2x = 6x[/math] Right. Let's apply this to some functions. What we were here for in the first place. Let's say we have [math]f(x,y) = x+y[/math] Then our partial derivatives are: [math]\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=y_0}\right) = \frac{d}{dx}\left(x+y_0\right) = 1[/math] and [math]\left(\;\left. \frac{\partial f}{\partial y}\right|_{x=x_0}\right) = \frac{d}{dx}\left(x+y_0\right) = 1[/math] Well, that big scary equation wasn't so hard after all. This means our error is: [math]\Delta f = 1\times\Delta x + 1\times \Delta y[/math] 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 [math]\Delta x = 0.00005[/math] and [math]0.05[/math] respectively. We plug everything into our equations and we get [math]f = 1.8232[/math] with an error of [math]0.05005[/math] 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[math]\left(\;\left. \frac{\partial f}{\partial x}\right|_{y=y_0}\right)[/math] 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: [math]\left(\;\left. \frac{\partial f}{\partial y}\right|_{x=x_0}\right)[/math] 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 [math]\Delta x[/math] and [math]\Delta y[/math] would be the width and length of that column, and [math]\Delta f[/math] 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 [math]f(x,y) = x\times y[/math] More in the sequel. I'll let y'all digest that and take a bit of a break from writing. Edited October 8, 2011 by Schrödinger's hat 1 Link to comment Share on other sites More sharing options...

csmyth3025 Posted October 10, 2011 Author Share Posted October 10, 2011 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 Link to comment Share on other sites More sharing options...

Schrödinger's hat Posted October 10, 2011 Share Posted October 10, 2011 (edited) Continuing from where I left off. With [math]f=xy[/math], our partial derivatives are no longer constant. If we change [math]x[/math] by a little bit, the amount [math]f[/math] changes depends on y. You can see this easily enough, even without calculus. If we take [math]f(x+\Delta x,y)=(x+\Delta x)y = xy + \Delta x y[/math]. So the amount f changes when we change x by a small amount depends on the value of y, or [math] \left.\frac{\partial f}{\partial x}\right|_{y=y_0} = y_0 [/math] Same goes for [math]y[/math] at [math]x_0[/math]. So our error formula for multiplication winds up being: [math]\Delta f = y\Delta x + x\Delta y[/math] Now if we have a certain number of significant digits for [math]x[/math], call it [math]n[/math], and a certain number of significant digistfor [math]y[/math], call it [math]m[/math], then we know that the maximum values for the errors in each term are less than: [math]\Delta x = \frac{x}{10^{n-1}}[/math] and [math] \Delta y = \frac{y}{10^{m-1}}[/math] 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 [math]\frac{10.2}{10^{3-1}}=0.102[/math] 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 [math]\Delta f = x\Delta y + y\Delta x[/math] and plug in our values to get: [math]\Delta f = \frac{xy}{10^{n-1}} + \frac{xy}{10^{m-1}}[/math] 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. [math]345.92 \times 0.164[/math] 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 [math]345.92\times 0.164 \times 0.05 + 345.92\times 0.164 \times 0.005[/math] or [math]0.28 + 0.028[/math] 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 October 10, 2011 by Schrödinger's hat Link to comment Share on other sites More sharing options...

csmyth3025 Posted October 12, 2011 Author Share Posted October 12, 2011 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 Link to comment Share on other sites More sharing options...

Schrödinger's hat Posted October 12, 2011 Share Posted October 12, 2011 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. Link to comment Share on other sites More sharing options...

Adidas Porsche Design Posted October 19, 2011 Share Posted October 19, 2011 Thanks SH. I learn a lot from your post. Link to comment Share on other sites More sharing options...

## Recommended Posts

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account## Sign in

Already have an account? Sign in here.

Sign In Now