Главная » Просмотр файлов » Thompson - Computing for Scientists and Engineers

Thompson - Computing for Scientists and Engineers (523188), страница 22

Файл №523188 Thompson - Computing for Scientists and Engineers (Thompson - Computing for Scientists and Engineers) 22 страницаThompson - Computing for Scientists and Engineers (523188) страница 222013-09-15СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 22)

We now discuss briefly these types of numerical noise.Roundoff and truncation errorsWhen a computer uses roundoff of numbers the least-significant digit is rounded tothe nearest least-but-one significant digit. For example, 0.12345676 rounded to 7significant figures is 0.1234568, while 0.12345674 rounded to 7 significant figuresis 0.1234567; the maximum error from such roundoff is therefore about 10-7.

Asanother example, the numbers 1.99999 and 2.00001 are both 2.0000 when roundedto 5 significant figures.In truncation, sometimes referred to as “chopping,” the least-significant digit isdropped. For example, both 0.12345676 and 0.12345674 truncate to 0.1234567.When converting floating-point variable values to integer-variable values, truncationis always used by scientific programming languages.

Thus, both 3.9999999 and3.0000001 truncate to integer 3. For this reason, counting should never be programmed in terms of floating-point variables.A simple program to determine both the number of significant figures carried in acomputer’s floating-point calculations, and also whether roundoff or truncation isused, is given as Program 4.3. The program Significant Digits in Floating Point will estimate the number of significant digits to a given base, and willsignal 'y' or 'n' depending on whether the final value was truncated or not.

Anonzero test number close to unity, value, is input, a given floating-point base(input as base) is chosen, then a while loop is executed until value is unchanged by adding in successively smaller powers. The number of digits is (approximately, for base2) the number of significant digits carried.Exercise 4.4(a) Explain how the algorithm coded in Significant Digits in FloatingPoint works.(b) Code and run the program on your computer.

Does the number of significant binary digits and decimal digits agree with what is stated in your computermanual? Is the floating-point arithmetic done by truncating or by rounding?Note that you should run several nearly equal values through the test. If any ofthem returns truncate = 'n', then your computer does rounding arithmetic.Explain this remark. ■For the double-precision variables declared in Program 4.3, my workstationgave 63 binary bits and did truncating arithmetic. The 63 bits are presumably storedin two 32-bit words, with one bit allowed for the sign.

When using base-10 theprogram declared that 19 decimal digits were carried: indeed 263 is just less than1019, and 264 is just greater than 1019.4.3NUMERICAL NOISE IN COMPUTING113PROGRAM 4.3 A program for estimating, for the computer on which it is run, the number ofsignificant digits to a given base.#include#include<stdio.h><math.h>main(){/* Significant Digits in Floating Point */double value,power,newvalue;int base,digits;char truncate;printf("Significant Digits in Floating Point\n");value = 1;while (value !=.

0)printf("\n\nInput test value near 1 (0 to end):");scanf("%1f",&value);if (value == 0){printf("\nEnd Significant Digits in Floating-Point");exit (0);}printf("\nInput floating-point base:");scanf("%i",&base);power = 1; digits = 0; newvalue = 0; truncate = 'y';tile (value != newvalue)power = power/base;digits = digits+l;newvalue = value+power;if (newvalue > value+power*base) truncate = 'n';printf("Number of digits is %i",digits-1);printf("\nValue of truncate is '%c'",truncate);The same algorithm can be used with a pocket calculator to determine its number ofsignificant digits and whether it uses roundoff or truncation.

The most commonscheme in both computers and calculators is truncation, because this allows simplerhardware to be used.Now that you know the number of significant digits in your computer or calculator, it is interesting to see some consequences of the finite number of digits. Thisexercise is probably easiest done on a pocket calculator rather than on a computer.114NUMERICAL DERIVATIVES AND INTEGRALSExercise 4.5(a) Demonstrate by examples that finite-precision arithmetic does not satisfy theassociative law of addition: (a + b) + c = a + (b + c).

Exhibit cases in whichthe signs of a, b, and c differ.(b) Prove that for addition the ordering that produces the smallest error fromloss of significant figures is to arrange the numbers by increasing order of magnitude, that is, smallest numbers first.(c) Demonstrate that the identity b(a/b) = a for b 0 is not always satisfiedin numerical arithmetic. For what ranges of a, b, and c are the relative errors largest in your arithmetic unit? nPart (b) of this exercise suggests that convergence of power series, as considered inSection 3.5, is not performed in the most accurate way.

The Horner polynomial expansion, considered later in this section, which considers the highest powers of avariable first, may often be preferred for numerical accuracy whenever feasible.Unstable problems and unstable methodsThe effects of the finite accuracy of computer arithmetic that we have just consideredarise partly from the use of unstable methods, which are sensitive to the accuracy ofthe calculation steps.

Examples are subtractive cancellation in calculating variancesor the solutions of quadratic equations, as we investigate in the next subsection.Such unstable methods should be clearly distinguished from unstable problems, inwhich the exact solution is very sensitive to slight variations in the data, independently of the accuracy of the arithmetic.An example of an unstable problem is the solution of the pair of linear equations(4.10)which are shown graphically in Figure 4.3 as the heavy solid and solid lines, respectively. These have an exact and unique solution x = 1, y = 1, which is theintersection point (solid circle) of the two lines in the figure.The solution of a pair of equations that are very similar to (4.10) namely,(4.11)shown dotted in Figure 4.3, is at x = -1, y = 3, the intersection point (dottedcircle) in the figure.

If one attempts to solve such an unstable problem numerically,then the results will be very sensitive to numerical noise. Geometrically, we seefrom Figure 4.3 that all three lines have almost the same slope, so that their intersection points are very sensitive to these slopes.4.3NUMERICAL NOISE IN COMPUTING115FIGURE 4.3 Lines that represent (4.10) (heavy solid and solid lines) and (4.11) (heavy solid anddotted lines).

Determination of their intersections is an unstable problem, since the intersection isat (1, 1) for (4.10) but at (1,3) for (4.11).From the viewpoint of linear algebra and the numerical solution of matrix inverses, the determinant of the two-by-two matrices made from the left-hand sides in(4.10) and (4.11) is very much less than the quantities on the right-hand sides ofthese equations, so that the matrices are ill-conditioned.Exercise 4.6(a) Generalize the above example from the equation pair (4.10) or (4.11) to thePair.(4.12)Eliminate x between this pair of equations to show that(4.13)in which the denominator is the determinant from the left-hand side of the pair ofequations.

Explain why values of b close to 1 produce y values that are verysensitive to the value of b.116NUMERICAL DERIVATIVES AND INTEGRALS(b) Check out (4.13) by first choosing a = 2, b = 1.OOOOO1, c = 2.001, toshow that y = 1000 and therefore x = -998. Second, choose a = 2, butb = 0.999999, c = 2.000001, to show that now y = -1, x = 3, which is athousand-fold change in the y solution for a change of only two parts per million in the b coefficient.(c) Show that the problem cannot be alleviated by first solving for x, then usingthe first equation in (4.12) to calculate y.

First give an algebraic demonstration,then rotate the book through a right angle and look at Figure 4.3 to devise a geometrical explanation nIn many numerical problems differences in coefficients such as those in Exercise 4.6 (b) may arise from roundoff or truncation errors in steps of the computation that generate the coefficients. Because there are so many numbers flying aroundin the computer, we seldom inspect the intermediate results to check on this numerical malfunction, unlike the situation when most of the calculations are done using apocket calculator with manual input and output for many of the steps.Therefore, numerical methods developed in the olden days of hand-cranked calculators, when numerical errors could easily be monitored and sometimes controlled, are often quite unsuitable for computer applications.

Nowadays, the user ofa numerical recipe might not even know how the algorithm that is being used wascoded, and whether the method used has been tested for numerical stability. Thisdistinction between the suitability of numerical methods for hand calculation versuscomputer calculation is discussed further in Section 3.6 in the diversion on computers and spline methods.The difficulties with unstable problems and with unstable methods are related toinstability of equilibrium and to chaos in mechanical systems, as well as to noise amplification and feedback in electrical systems.

These topics are lucidly discussed inChapter 9 of Pippard’s book on the physics of vibration, and are developed in moredetail in his book on response and stability. Unstable problems and unstable methods also occur when solving differential equations numerically, often because of extreme sensitivity to boundary conditions. This is discussed in Sections 8.4 and 8.6for the second-order Euler method and for stiff differential equations, respectively.Such mechanical, electrical, and numerical instabilities are intimately related.Errors from subtractive cancellationAmong other problems facing those who would compute numerically are errors arising from subtractive cancellation, which is the reduction in the number of significantfigures that may occur when two numbers (assuming they have the same signs) aresubtracted.

Характеристики

Тип файла
PDF-файл
Размер
4,66 Mb
Тип материала
Учебное заведение
Неизвестно

Список файлов книги

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6353
Авторов
на СтудИзбе
311
Средний доход
с одного платного файла
Обучение Подробнее