Evaluate:
5
∫ [|y-3| + [y]] dy
-1
Bonus Question:
Work out the following definite integral:
5
∫ (|y-3| + [y]) dy
-1
Notes:
(i) [x] is defined as the greatest integer ≤ x
(ii) |x| is the
absolute value of x.
The first function being integrated has an integral value at each point, and changes that value only at integral values of y, so if we graph the function, we only need to count squares under the "curve". In the four columns of squares bounded by the independent variable (y) values -1 to 3, the height is 2, thus counting 8 squares. From 3 to 4, the height is 3, adding that many squares, and from 4 to 5, the height is 5, adding that many squares. The total is 8+3+5 = 16.
The second function being integrated has a triangle with area 1/2 surmounting each column, which would otherwise have the same area as the columns for function 1. This adds 6/2 = 3 to the total area, making 19.
The following program evaluates the functions piecewise from "infinitessimally" above each integer to "infinitessimally" below the next, for the 6 columns of the graph. The average is the average height of that column, as the functions are linear between integer values of the independent variable. The epsilon value is that pseudo-infinitessimal, but needn't be that small, as the linear nature of the function between the integer values also causes any decrease at one end to be offset by an increase at the other.
DEFDBL A-Z
CLS
epsilon = .00000000000001#
FOR ytop = 0 TO 5
y0 = ytop - 1 + epsilon
y1 = ytop - epsilon
val0 = INT(ABS(y0 - 3) + INT(y0))
val1 = INT(ABS(y1 - 3) + INT(y1))
incr = (val0 + val1) / 2
PRINT USING "(##_, ##) - (##_, ##) ##.##"; y0; val0; y1; val1; incr
area = area + incr
NEXT
PRINT
PRINT TAB(20); area
area = 0
PRINT : PRINT
FOR ytop = 0 TO 5
y0 = ytop - 1 + epsilon
y1 = ytop - epsilon
val0 = ABS(y0 - 3) + INT(y0)
val1 = ABS(y1 - 3) + INT(y1)
incr = (val0 + val1) / 2
PRINT USING "(##_, ##) - (##_, ##) ##.##"; y0; val0; y1; val1; incr
area = area + incr
NEXT
PRINT
PRINT TAB(20); area
The end points of the linear segments are given, followed by the area of the column below that section. The total is given below each set (each function).
(-1, 2) - (-0, 2) 2.00
( 0, 2) - ( 1, 2) 2.00
( 1, 2) - ( 2, 2) 2.00
( 2, 2) - ( 3, 2) 2.00
( 3, 3) - ( 4, 3) 3.00
( 4, 5) - ( 5, 5) 5.00
16
(-1, 3) - (-0, 2) 2.50
( 0, 3) - ( 1, 2) 2.50
( 1, 3) - ( 2, 2) 2.50
( 2, 3) - ( 3, 2) 2.50
( 3, 3) - ( 4, 4) 3.50
( 4, 5) - ( 5, 6) 5.50
19
|
Posted by Charlie
on 2008-04-27 18:58:18 |