Question: You are required to write a function file that calculates the definite integral using a second order approximation. It should work similarly to the trapz

You are required to write a function file that calculates the definite integral using a second order approximation. It should work similarly to the trapz command. Note that for two equally sized arrays, X and Y, trapz(X,Y) calculates the integral using a first order 1approximation. i.e. It connects each pair of points using a straight line, calculates the area of each trapezium, then adds them up to get a first order approximation. Also note that X does not have to be evenly spaced for trapz to work. For this assignment, you need to create a function file titled Simpz_studentID, such that Simpz_studentID (X,Y) estimates the integral using a second order approximation. i.e. It connects each set of 3 points using a 1quadratic curve, calculates the area of each segment, then adds them up. Your solution should work even if X is not evenly spaced. Your main file should be similar to below (with your student ID in place of studentID). This main file calls the function file Simpz_studentID and it should display the correct output values without error. % Student name, student IDX1 = [1 2 5 6 8 10 11];Y1 = [1 4 25 36 64 100 121];X2 = [3 5 6 9 10 12 13 15 19];Y2 = [1.8 2.2 2.5 3 3.1 3.2 3.3 3.6 3.8];X3 = [0 0.2 0.4 0.5 0.7 0.9 1.0];Y3 = [2 3 4 5 4 3 2];Trap1 = trapz(X1,Y1);Simp1 = Simpz_studentID(X1,Y1);Trap2 = trapz(X2,Y2);Simp2 = Simpz_studentID(X2,Y2);Trap3 = trapz(X3,Y3);Simp3 = Simpz_studentID(X3,Y3);Matrix_Output = [Trap1 Simp1;Trap2 Simp2;Trap3 Simp3]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!