(Numerical Integration) Suppose we are given a function f(x) whose integral is not known explicitly. We may, however, wish to still approximate the value of the definite integral of f over the interval [a, b]. In order to do this, we could use the so-called composite trapezoid rule with n+1 nodes given by T-1 h Ls(2) dz = (s(a) + 2 fla + kh) + f(b)). k=1 where h = b-a comp_trap_rule Function: Input variables: • an anonymous function representing f • a scalar representing the lower bound of integration a • a scalar representing the upper bound of integration b • a scalar representing the value of n; you may assume this is an integer greater than 0 Output variables: • a scalar represcnting the approximate integral computed by the formula above A possible sample case is: » int = comp_trap_rule(@(x) x^2, 0, 1, 100) int 0.33335 %3!
(Numerical Integration) Suppose we are given a function f(x) whose integral is not known explicitly. We may, however, wish to still approximate the value of the definite integral of f over the interval [a, b]. In order to do this, we could use the so-called composite trapezoid rule with n+1 nodes given by T-1 h Ls(2) dz = (s(a) + 2 fla + kh) + f(b)). k=1 where h = b-a comp_trap_rule Function: Input variables: • an anonymous function representing f • a scalar representing the lower bound of integration a • a scalar representing the upper bound of integration b • a scalar representing the value of n; you may assume this is an integer greater than 0 Output variables: • a scalar represcnting the approximate integral computed by the formula above A possible sample case is: » int = comp_trap_rule(@(x) x^2, 0, 1, 100) int 0.33335 %3!
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.7: Do While Loops
Problem 6E: (Numerical analysis) Here’s a challenging problem for those who know a little calculus. The...
Related questions
Question
make mathlab code
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr