// // proj_1.sce // // A program to integrate the area under the curve // of the function, using Simpson's rule // // by: Jamie Beckett // date: 09/04/02 // class: Egr 345 // Prof. Hugh Jack // Set the curve length and step size steps = 100; //number of steps between 1 & 10 curve_end = 10; //Upper limit curve_start = 1; //Lower limit delta_s = (curve_end - curve_start) / steps; //increments of curve to //use with Simpson's // Initial conditions value=0; area=0; // Loop to integrate the motion for i=1:steps, value = [value; curve_start + i * delta_s]; area = [area; (5*value($) + 2 * log (( sin(value($)) / value($) ) + 2 ))]; Area_under = (delta_s)*area; s = sum(Area_under); end //Displays the sum of all the rectangles s // Dump the values to the screen //[value area] // Write values to a file (delete the existing file first) unix("del c:\temp\data_409.txt"); write("c:\temp\data_409.txt", [value area]);