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

Using Visual Studio 2015, C++, This program will perform the Trapezoidal Method

ID: 3573860 • Letter: U

Question

Using Visual Studio 2015, C++,

This program will perform the Trapezoidal Method to compute the definite integral of a given function f(x) over the given interval of a to b. This technique is explained in the course textbook in section 14.5 (Numerical Integration) T_0=1/2 (f(a) + f(b))(b-a) T_k=1/2 T_k-1 + delta x_k sigma_i=1^n-1 f(a + I middot delta x k): for i = all odd numbers from 1 to n-1 where: delta x_k=b-a/2^k n=2^k f(x)=1/x^2 Is the function to be evaluated This Program should perform at least the following functions: The program should display a title banner which has the title of Trapezoidal Method of Integration and some brief text that explains the functionality of the program. The program should accept the number of iterations (k) to be ran. For this problem one test case is sufficient if it is greater than 6. Write a function that computes the value of f(x)=1/x^2. Look at Chapter 14 of the course textbook for examples. Use the Trapezoidal Method to compute the integral over the range 1 to 2 (a=1, b=2) Output to the screen the formatted result of the integration Method for each step k in Equation 1. Remembering that there will be at least 6 iterations based on other program requirements given.

Explanation / Answer

//this program compute definite integral using trapezoidal method
//x0=1 and x1=2 and function is 1/(x*x)
//output is 0.501
//10 itearation is used to compute integral
// i am providing c program..
#include<stdio.h>
#include<math.h>
void main()
{
   float x0=1,x1,h=0.1,y0,y1,tr=0,i; //x0=1(lower limit) and x1=2(upper limit)
   for( i=1;i<=2;i=i+0.1)
   { x1=x0+h;
   if(x1>2)
   x1=2;
   //   y0=exp(x0);
   y0=1/(x0*x0);  
       printf("%2.5f ",y0);
   //   y1=exp(x1);
   y1=1/(x1*x1);
       tr=tr+((y0+y1)*0.5*h); //formula for trapezoidal
       x0=x1;
   }
  
   printf("%2.5f is the final answer",tr);
}     

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote