the error is but without the bug the error is it is of course completely impossible to tell if is the right value of the error fortunatelyincreasing shows that the error stays about in the program with the bugso the test procedure with increasing and checking that the error decreases points to problem in the code let us look at another bugthis time in the mathematical algorithminstead of computing ac /as we shouldwe forget the second and write : * (af(bthe error for when computing : dt goes like respectivelywhich looks promising the problem is that the right errors should be and that isthe error should be reduced faster in the correct than in the buggy code the problemhoweveris that it is reduced in both codesand we may stop further testing and believe everything is correctly implemented unit testing good habit is to test small pieces of larger code individuallyone at time this is known as unit testing one identifies (smallunit of the codeand then one makes separate test for this unit the unit test should be stand-alone in the sense that it can be run without the outcome of other tests typicallyone algorithm in scientific programs is considered as unit the challenge with unit tests in numerical computing is to deal with numerical approximation errors fortunate side effect of unit testing is that the programmer is forced to use functions to modularize the code into smallerlogical pieces proper test procedures there are three serious ways to test the implementation of numerical methods via unit tests comparing with hand-computed results in problem with few arithmetic operationsi small solving problem without numerical errors we know that the trapezoidal rule must be exact for linear functions the error produced by the program must then be zero (to machine precision demonstrating correct convergence rates strong test when we can compute exact errorsis to see how fast the error goes to zero as grows in the trapezoidal and midpoint rules it is known that the error depends on as as hand-computed results let us use two trapezoids and compute the integral / td : / : / : when : is the width of the two trapezoids running the program gives exactly the same result