Question

The weights for a two-point open Newton-Cotes rule are the same as in a two-point closed...

The weights for a two-point open Newton-Cotes rule are the same as in a two-point closed Newton-Cotes rule (trapezoid rule). The quadrature points are x1 = a+1/3(b-a) and x2 =a+2/3(b-a). write a matlab function to implement a two point, open newton cotes rule, and use the function to evaluate a couple of integrals.

Homework Answers

Answer #1

Required Matlab code with explanatory comments is given below:

function [integral] = my2ptNC(f,a,b)
%finds the integral using 2-point open
%Newton-Cotes formulae
weights=[(b-a)/2,(b-a)/2]; %weights for 2 point open NC
xvalues=[a+1*(b-a)/3,a+2*(b-a)/3]; %the x values used in NC
fvalues=f(xvalues); %evaluate function at these points
integral=sum(weights.*fvalues); %find their weighted sum
fprintf('The integral is approximately %f12 \n',integral) %show integral
end

Sample usage:

Please do rate this answer positively if you found it helpful. Thanks and have a good day!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The weights for a two-point open Newton-Cotes rule are the same as in a two-point closed...
The weights for a two-point open Newton-Cotes rule are the same as in a two-point closed Newton-Cotes rule (trapezoid rule). The quadrature points are x1 = a+1/3(b-a) and x2 =a+2/3(b-a). write a matlab function to implement a two point, open newton cotes rule, and use the function to evaluate a couple of integrals.
Use C++ to design a program: Your program will use three different 5-point numerical quadrature methods...
Use C++ to design a program: Your program will use three different 5-point numerical quadrature methods (Closed Newton Cotes, Gaussian Quadrature, and Lobatto Quadrature) You will employ each of these methods to solve each of the following three problems to find the area under the respective curves over the interval (-1, 1). The following is a plot of the first function f(x) = 1 - sin(1 - x)    The true area under the curve is (to 20 digits) 0.58385316345285761300.              ...
(a) Generate the following discrete functions using MATLAB. Plot the two functions on the same page...
(a) Generate the following discrete functions using MATLAB. Plot the two functions on the same page using MATLAB stem function. For x2[k] plot the real and imaginary parts separately. Therefore, a total of three plots will be plotted on one page. (i) x1[k]= -5.1sin((0.1*pi*k)-3*pi/4)+1.1cos(0.4*pi*k) such that k belongs in[-10,40] (ii)x2[k]= ((-0.9)^k)*exp(i*pi*k/10) such that k belongs in[0,100] (b) Are x1[k] and x2[k] periodic sequences. If so, what are their periods? Mark them on the plots. (c) Calculate the total energy of...
Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2...
Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2 ) = ?1 2 + ?2 2 − 26 ?(?1?2 ) = 3?1 2 + 25?2 2 − 100 (1 Mark) b) Use MATLAB’s FSOLVE operator to solve these equations with x1 = 2 and x2 = 2 as your starting point. How many iterations did MATLAB use to solve them? (1 Mark)
Consider a function x2 − 3 = 0 . Then with the starting point x0 =...
Consider a function x2 − 3 = 0 . Then with the starting point x0 = 1 , if we perform three iterations of Newton-Rhapson Method, we have the following: (Note that your answer format should be x.xxxx. For example, 2 ->, 2.0000 or 1.34 -> 1.3400, or 1.23474 - > 1.2374, or 1.23746->1.2375) x1 = x2 = x3 =
Use MATLAB to determine the intersection point for the sets of equations shown below. Use the...
Use MATLAB to determine the intersection point for the sets of equations shown below. Use the backslash when possible. Graph the equations with different colors, and plot the intersection point with a red star marker. If the equations do not intersect, graph them anyway. Include a legend. cannot use 'ezplot' or 'solve' b) -4(x1)+(2(x2))^3=10 x1+x2=-8
This problem explores two analytical methods to approximate 4√(16.5) = (16.5)1/4 (a) Calculate the linear approximation...
This problem explores two analytical methods to approximate 4√(16.5) = (16.5)1/4 (a) Calculate the linear approximation to the function f(x) = x1/4 at the point a = 16 and use it to approximate 4√(16.5). (b) Calculate the iteration scheme that arises from applying Newton’s Method to the function g(x) = x4-16.5 and use it to evaluate 2 iterates, x1, x2 with a starting guess of x0 = 2.
A product is produced using two inputs x1 and x2 costing P1=$10 and P2 = $5...
A product is produced using two inputs x1 and x2 costing P1=$10 and P2 = $5 per unit respectively. The production function is y = 2(x1)1.5 (x2)0.2 where y is the quantity of output, and x1, x2 are the quantities of the two inputs. A)What input quantities (x1, x2) minimize the cost of producing 10,000 units of output? (3 points) B)What is the optimal mix of x1 and x2 if the company has a total budget of $1000 and what...
Two types of survey questions are open questions and closed questions. An open question allows for...
Two types of survey questions are open questions and closed questions. An open question allows for any kind of​ response; a closed question allows for only a fixed response. An open question and a closed question with its possible choices are given below. List the advantages and disadvantages of each question. Open​ question: What can be done to get students to eat healthier​ foods? Closed​ question: How would you get students to eat healthier​ foods? 1. Mandatory nutrition course 2....
Suppose that X1 and X2 are independent continuous random variables with the same probability density function...
Suppose that X1 and X2 are independent continuous random variables with the same probability density function as: f(x) = ( x 2 0 < x < 2, 0 otherwise. Let a new random variable be Y = min(X1, X2,). a) Use distribution function method to find the probability density function of Y, fY (y). b) Compute P(Y > 1).
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT