`Hey,
Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.
clc
clear all
close all
format long
f=@(x) sin(x)^3;
I1=SimpsonComp(f,1,6,7);
I2=SimpThreeEight(f,1,6,7);
disp('Average is');
disp((I1+I2)/2)
function int=SimpsonComp(f,a,b,n)
%takes in parameter as function handel f, starting interval a and ending
%interval b for integration and number of intervals as n
h=(b-a)/n;%step of integration
fa=f(a);%value of function at a
fb=f(b);%value of function at b
ff=0;%initialize ff to 0
for i=2:2:n%traversing on even numbers i
x=(a+(i-1)*h);%accessing even points in the intervals divided
fx=feval(f,x);%value of function at x
ff=ff+4*fx;%add 4*fx to ff
end
for i=3:2:n%traversing on odd numbers i
x=(a+(i-1)*h);%accessing odd points in the intervals divided
fx=feval(f,x);%value of function at x
ff=ff+2*fx;%add 4*fx to ff
end
int=(h/3)*(fa+fb+ff);%finally add first and last points tto all the sum and divide by 3
end
function I = SimpThreeEight(f, a, b, n)
h = (b-a)/n;
S =feval(f,a);
for i = 1:3:n-2
x(i) = a + h*i;
S = S + 3*feval(f, x(i));
end
for i = 2:3:n-1
x(i) = a + h*i;
S = S + 3*feval(f, x(i));
end
for i = 3 : 3: n-3
x(i) = a + h*i;
S = S + 2*feval(f, x(i));
end
S = S + feval(f, b);
I = 3*h*S/8;
end
Kindly revert for any queries
Thanks.
In Matlab please Given the function: So sin? (x)dx calculate the integral for all possible combinations...
5." 9 sin(x) dx. (Round your answers to six decimal places.) (a) Find the approximations T10, M10, and S10 for T10- M10 = S10= Find the corresponding errors ET, Em, and Es. (Round your answers to six decimal places.) ET= EM= Es= (b) Compare the actual errors in part (a) with the error estimates given by the Theorem about Error Bounds for Trapezoidal and Midpoint Rules and the Theorem about Error Bound for Simpson's Rule. (Round your answers to six...
Use Matlab code Consider the following function sin(x) Using the following parameters in your functions: -func: the function/equation that you are required to integrate -a, b: the integration limits n: the number of points to be used for the integration I:Integral estimate a) Write a function capable of performing numerical integration of h(x) using the composite trapezoidal rule. Use your function to integration the equation with 9 points. Write a function capable of performing numerical integration of h(x) using the...
7 Use Simpson's rule with n=1 (so there are 2n = 2 subintervals) to approximate 8 dx. The approximate value of the integral from Simpson's rule is (Round the final answer to two decimal places as needed. Round all intermediate values to four decimal places as needed.)
3 11 Use Simpson's rule with n=1 (so there are 2n = 2 subintervals) to approximate dx. 1 + x2 The approximate value of the integral from Simpson's rule is (Round the final answer to two decimal places as needed. Round all intermediate values to four decimal places as needed.) 5 Use Simpson's rule with n=4 (so there are 2n = 8 subintervals) to approximate OX dx and use the fundamental theorem of calculus to find the exact value of...
(a) Estimate So sin(x + 1) dx by using either Simpson's Rule or Trapezoidal Rule with n= 6 (Round the answer to 6 decimal places). (b) Estimate the minimum number of subintervals needed to approximate the integrals with an error of magnitude less than 10-4 by the rule you used in part (a).
Use the Trapezoidal Rule, the Midpoint Rule, and Simpson's Rule to approximate the given integral with the specified value of n. (Round your answers to six decimal places.) 5 3 cos(6x) n = 8 dx, X 1 (a) the Trapezoidal Rule (b) the Midpoint Rule (c) Simpson's Rule
please help with number 15 15. Given the following definite integral, lo x + x dx a. Evaluate the integral using limits, showing all steps: b. Confirm your result by using the rules of integration and the Fundamental Theorem of Calculus: TUUKU U uit alta vi tile region bounded by the following equations (Note that this is an "area between functions" question, and not a question of finding the definite integral): y = 5x - 1 y = 0 x...
1. Numerical Integration The integral of a function f(x) for a s x S b can be interpreted as the area between the f(x) curve and the x axis, bounded by the limits x- a and x b. If we denote this area by A, then we can write A as A-f(x)dx A sophisticated method to find the area under a curve is to split the area into trapezoidal elements. Each trapezoid is called a panel. 1.2 0.2 1.2 13...
ise trapeczoidal rale to mumericlly evaluane ths inegra I(sin x +cos 2x) dx Divide the integral of integration into 5 divisions (n-5), Present all the steps and the final answer to three decimal places. Maintain four decimal places in intermediate steps. Check your answer against the exact value of the integral.
Use the Trapezoidal Rule, the Midpoint Rule, and Simpson's Rule to approximate the given integral with the specified value of n. (Round your answers to six decimal places.) 4 In(1 + ex) dx, n = 8 Jo (a) the Trapezoidal Rule X (b) the Midpoint Rule (c) Simpson's Rule 8.804229