Write a program that computes an approximation of a definite integral for the fu
ID: 3633705 • Letter: W
Question
Write a program that computes an approximation of a definite integral for the functions f(x) = e^(-x^2) and f(x) = e^(-x) with a = 0 and b = 1. The program should use the trapezoidal integration rule:
h = (b-a) / N
The program should include a function "trapeze" that computes and returns the value of the integral of a function passed as a parameter. Other parameters of "trapeze" are the bounds a and b and the number of intervals N. The program should read the value of N from input as in the example below.
Your program should reproduce the following format [THIS IS AN EXAMPLE OUTPUT]
Enter the number of intervals: 20
integral of exp(-x*x): 0.746671
integral of exp(-x): 0.632252
Explanation / Answer
http://introcs.cs.princeton.edu/java/93integration/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.