Question
Exercise 1: Implement a C++ program that calculates the left-endpoint, right-endpoint, trapezoidal, midpoint, and simpsons rule approximations for a particular definite integral. The program needs
Exercise 1:
Implement a C++ program that calculates the left-endpoint, right-endpoint, trapezoidal, midpoint, and simpsons rule approximations for a particular definite integral. The program needs to have input n from user using cin and needs to display output on screen using cout. As a test case for our numerical integration, we will approximate the definite integral of f (x) = 1/(1+x^2) on the interval [0, 1].
#include
int main() { /* a = lower limit; b = upper limit; n = number of intervals */ int n; cin >> n; cout << << endl; return 0; }
Exercise 2:
Implement a C++ program that automatically finds n for trapezoidal rule to achieve given accuracies? What is the smallest value of n that makes the absolute value of the error in trapezoidal rule less than 106? Less than 108? n needs to be started from 1 with step-size of 1 using loop. Branch needs to be used to find the n which gives error less than 10-6 or 10-8 by stopping there when it meets the condition. The program must use variables, branch, loop in a proper way. The program needs to display detailed procedure and output on screen using cout.
#include
int main() { string userName; string totalString; cin >> userName; cout << userName <<"'s code" << endl; // Start your programming here! }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started