Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using the numerial intergation code : 1. Simpson’s Composite (Numerical Integrat

ID: 3577172 • Letter: U

Question

using the numerial intergation code :

1. Simpson’s Composite (Numerical Integration)

   To find the approximate area under a curve given by a function f(x). The area
   is computed relative to the x axis and it is negative when the function is
   below 0.

   This is represented by

   I = ? f(xi) ?xi     from x1 = a to x2m-1 = b

   The algorithm uses the Simpson's composite rule, which approximate the area
   between x0 and x2 as
  
   ?x*(f(x0) + 4*f(x1) + f(x2))/3

   INPUT endpoints a,b; positive integer m

   OUTPUT s=approximation xI to I
*/

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

double simpsonRule(double, double, int);

int main()
{

   // Read input parameters
   cout<<"Enter the integration lower and upper boundaries ";
    double a, b;
   cin >> a >> b;
   if(a>b){
       cout<<"Error: lower limit must be smaller than upper one ";
       return 1;
   }
   cout<<"Enter the integration steps (>1) ";
    int n;
   cin >> n;
   if(n < 2)   {
       cout<<"Error: integration steps must be larger than 1 ";
       return 1;
   }

   // Call simpsonRule function
    double xI = simpsonRule(a, b, n/2);   // note: m = half the integration steps

   // Write output
   cout << "The integration between "<<a<< " and "<<b<<" results in "<<endl;
   cout << xI << endl;

   return 0;
}

// Note: The funtion is set to zero if it is undefined
double f(double x)
{
    // original
    double xx = x*x;
   return (xx<1)? sqrt(1.-xx): 0;
}

//
// SIMPSON RULE
//

double simpsonRule(double a, double b, int m)
{
   // Step 1 Set h = (b - a)/(2m)
   double h = (b-a)/(2.*m);

   // Step 2 Set    xI0 = f(a) + f(b)
   //              xI1 = 0   (summation of f(x2i-1) )
   //              xI2 = 0   (summation of f(x2i) )
   double xI0 = f(a) + f(b);
   double xI1 = 0;
   double xI2 = 0;

   //Step 3 For i = 1, …, 2*m-1 do Steps 4 and 5
   for(int i=1; i<2*m; ++i){

        // Step 4   Set x = a + i*h
       double x = a + i*h;

        // Step 5   If i is even then set xI2 = xI2 + f(x)
        //          else set xI1 = xI1 + f(x)
       if (i%2 == 0)
           xI2 += f(x);
       else
           xI1 += f(x);

   }
   // Step 6 Set xI = h*(xI0 + 2*xI2 + 4*xI1)/3.

   double xI = h*(xI0 + 2*xI2 + 4*xI1)/3.;

   // Step 7 OUTPUT (xI)
   return xI;
}

Problem 1 Arc Length An engineering problem involves the determination of the length of a flat sheet of metal required to build a sheet of corrugated roofing. The cross-section of the roofing is shaped into the form of a sine wave by a machine A f(x) (Ar)2 (Af)2 As Aar 1 As sin Af Ax V 1 cos a) Az Supposed a corrugated sheet of length three feet is needed, the height of each wave is one inch from the center line, and each wave has a period of approximately 2T inches. The problem of finding the length of the initial flat sheet is one of finding the arc length L of the curve given in this case by fox) sin x from x 0 inches to 36 inches. The arc length can be approximated as the sum of the length of many small straight segments As. The length of each segment is calculated using the Pythagoras theorem. For fxp sin x, it can be shown that the slope of As is Af/Ax cos x. The total arc length is 36 1 COS a) 2Az which converges to the actual arc length as Ax get smaller and smaller. Problem 1.1 Compute the arc length L by integrating the square root term in the summation between 0 and 36 inches. Use enough integration steps to obtain a result accurate to two decimal places expressed in inches.

Explanation / Answer

Pipelining cannot decrease the interval needed for one task. The advantage of pipelining is that it will increase the outturn of the system once process a stream of tasks.

Applying too several pipelined functions will cause accumulated latency - that's, the time needed for one task to propagate through the total pipe is prolonged. A pipelined system might also need additional resources (buffers, circuits, process units, memory etc.), if the utilize of resources across totally different stages is restricted.

Comparison with parallel approaches[edit]
Another technique to boost the potency through concurrency is data processing. The core distinction is that parallel techniques sometimes duplicate operate units and distribute multiple input tasks right away amongst them. Therefore, it will complete additional tasks per unit time however could suffer dearer resource prices.

For the previous example, the parallel technique duplicates every operate units into another 2. consequently, all the tasks may be operated upon by the duplicated operate units with identical operate at the same time. The time to complete these 3 tasks is reduced to a few slots.

Pipelining in FIR filters[edit]
Consider a 3-tap FIR filter:[1]


which is as shown within the following figure.

Assume the calculation time for multiplication units is metallic element and tantalum for add units. The essential path, representing the minimum time needed for process a brand new sample, is restricted by one multiplication and a pair of add operate units. Therefore, the sample amount is given by

}geq T_+2T_} }geq T_+2T_}
Pipelined FIR filters.png
However, such structure might not be appropriate for the planning with the necessity of high speed. to scale back the sampling amount, we are able to introduce additional pipelining registers on the essential knowledge path. Then the structure is divided into 2 stages and therefore the knowledge made within the initial stage are hold on within the introduced registers, delaying one clock to the second stage. the info in initial 3 clocks is recorded within the following table. below such pipelined structure, the sample amount is reduced to

}geq T_+T_.} }geq T_+T_.}
Pipelined FIR filters2.png


Pipelined FIR filters table.png
Pipelining in 1st-order IIR filters[edit]
By combining look-ahead techniques and pipelining,[2] we have a tendency to area unit ready to enhance the sample rate of target style. Look-ahead pipelining can add canceling poles and zeroes to the transfer operate such the coefficients of the subsequent terms within the divisor of the transfer operate area unit zero.

,ldots ,z^}} ,ldots ,z^}}
Then, the output sample y(n) may be computed in terms of the inputs and therefore the output sample y(n M) such there area unit M delay parts within the essential loop. These parts area unit then wont to pipeline the essential loop by M stages so the sample rate may be accumulated by an element M.

Consider the 1st-order IIR filter transfer operate

}}} }}}
The output y(n) may be computed in terms of the input u(n) and therefore the previous output.


In a easy structure to style such operate, the sample rate of this algorithmic filter is restricted by the calculation time of 1 multiply-add operation.

To pipeline such style, we have a tendency to observe that H incorporates a pole at


Therefore, in an exceedingly 3-stage pipelined equivalent stable filter, the transfer operate may be derived by adding poles and zeros at

})}} })}}
and is given by

+a^z^}{1-a^z^}}} +a^z^}{1-a^z^}}}
Therefore, the corresponding sample rate may be accumulated by an element three.