# midpoint_input.txt # # Discussion: # # Suggest how the midpoint quadrature rule works. # # Consider the function poly(x) = (x+1)*(x-1)*(x-1)*(4-x) over [0,4]. # Approximate it by rectangles whose heights are the midpoints of 10, 20 or 40 intervals. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 14 October 2013 # # Author: # # John Burkardt # set term png set output "midpoint10.png" set grid # # Define a thick cyan line to be used for the plot of poly(x): # set style line 1 lw 4 linecolor rgb "black" # # Setting the fill to solid means the "boxes" will be filled in when # we draw them. # set style fill solid # # Plot poly(x) with linestyle 1 versus 10 rectangles. # set output "midpoint10.png" set title "Midpoint Quadrature Rule with 10 Intervals" set timestamp plot [x=0:4] (x+1)*(x-1)*(x-1)*(4-x) ls 1, "poly10.txt" using 1:2:(0.37) with boxes # # Plot poly(x) with linestyle 1 versus 20 rectangles. # set output "midpoint20.png" set title "Midpoint Quadrature Rule with 20 Intervals" set timestamp plot [x=0:4] (x+1)*(x-1)*(x-1)*(4-x) ls 1, "poly20.txt" using 1:2:(0.18) with boxes # # Plot poly(x) with linestyle 1, versus 40 rectangles. # set output "midpoint40.png" set title "Midpoint Quadrature Rule with 40 Intervals" set timestamp plot [x=0:4] (x+1)*(x-1)*(x-1)*(4-x) ls 1, "poly40.txt" using 1:2:(0.08) with boxes # # Terminate. # quit