Code: Function1.m
clc
clear
a = 0; b = 1;
f = @(x) 4.* 1./(1 + x.^2);
n = 2; % you can also increase n
err = 1;
while err > 0.5*10^-5
h = (b - a) / (n - 1);
x = a:h:b;
wS = h/3 * [1 2*ones(1,n-2) 1] ;
wS(2:2:end) = 4*h/3 ;
IS1 = sum(f(x) .* wS);
I = quad(f, 0, 1);
err = abs(IS1 - I);
n = n + 1;
end
disp("Absolute error of f1 = "+num2str(err));
disp("Integral of f1 = "+num2str(IS1));
Output:
Code: Function2.m
clc
clear
a = 0; b = 1/sqrt(2);
f = @(x) 8 * (sqrt(1 - x.^2) - x);
n = 2; % you can also increase n
err = 1;
while err > 0.5*10^-5
h = (b - a) / (n - 1);
x = a:h:b;
wS = h/3 * [1 2*ones(1,n-2) 1] ;
wS(2:2:end) = 4*h/3 ;
IS2 = sum(f(x) .* wS);
I = quad(f, 0, b);
err = abs(IS2 - I);
n = n + 1;
end
disp("Absolute error of f2 = "+num2str(err));
disp("Integral of f2 = "+num2str(IS2));
Output:
please include matlab code!! [Computer Exercises 5.3.1] Find approximate values for the two integrals 1 dr 0 0 Use composite Simpson's rule with an error-Ί 10-5 [Computer Exercises 5.3.1] Fi...
Numerical Methods Consider the integral 2 (a) [16 marks] Use the composite Simpson's rule with four intervals to calculate (by hand) approximate value of the integral Calculate the maximum value of the error in your approximation, and compare it with the true error. (b) 19 marks] Determine the number of subintervals n and the step size h so that the composite Simpson's rule for n subintervals can be used to compute the given integral with an accuracy of 5 ×...
How would you code this on matlab? Wirite a code to find an approximation for the composite trapezoidal rule. dr witiferent mumber of sabintervals using Use the following number of subintervals namely, n 10,n 20,n-40 andn 100 and calculate the global errors in each case. Wirite a code to find an approximation for the composite trapezoidal rule. dr witiferent mumber of sabintervals using Use the following number of subintervals namely, n 10,n 20,n-40 andn 100 and calculate the global errors...
Numerically apply the composite Simpson’s rule to compute with evenly spaced nodes with n = 10, 20, 40, 80. Note that different coefficients should be placed in front of the function values at nodes with odd and even subscripts. Compute absolute errors. Please attach your MATLAB code and complete the table below: 1 0 We were unable to transcribe this imagen Result by the composite Simpson's rule Absolute error Absolute errorxn4 10 20 40 80 1 0 n Result by...
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...
numerical analysis Find the relation error use the Simpson's 1/3 rule to approximate the definite integral. Use n=4, Só(3 – x2) dx A) = 33.5% E) = 10.0% B) = 2.36% F) = 31.01% C) = 7.36% G)12.5% D) = 12.00% H) = 0.0%
Explain using Matlab code but also why you used the linear system please 1 Quadrature Rule A quadrature rule is a way to approximate integrals numerically i.e. using a computer). Many such quadrature rules can be derived by solving a simple linear system. Set up a linear system and then use Matlab to find the coefficients wo, W1, W2, W3, W4, W5 such that | f(x)dx = wof(0) + wif(0.2) + w2f(0.4) + w3f(0.6) +w4f(0.8) + w5f (1) for each...
13. Let f(x)and consider the integral 1= | f(x) dr. 0 (a) Use the composite trapezoidal rule with h = 0.25 to approximate 1. 13. Let f(x) e and consider the integral -I:f( 1e)dr. (a) Use the composite trapezoidal rule with h 0.25 to approxinate 1. (b) Calculate the bound on the absolute error for the Trapezoidal rule.
help wanted?? thank you explain correctly Problem 1 Use the trapezoidal rule technique to approximate the following integrals: a) 「(x2+1)dr(Note: use 0.5 increments forx) b) sina d INote: use a MATLAB function to subdivide the interval into eight equal parts) c e dx (Note: use 0.25 increments for x Problem 2 Use the Simpson's rule to evaluate the following integrals aDdr Problem 3: Given the polynomial: x3-6x2 + 30-0, Use MATLAB to find all roots of this polynomial. Use MATLAB's...
Approximating With Simpson's Rule 6) Now we want to use Simpson's Rule to find the volume of the machine part. Remember that Simp- son's Rule approximates integrals, not just areas. Since we don't just want the area under the radius function, we can't just apply Simpson's Rule to the radius function. If we let f(x) be the radius of the machine part at the point x, write down the integral that gives the volume of the machine part (with an...
Question: Code your own MATLAB program to find the approximate value of the Integeral 0 to 2 ex dx with Trapezoidal rule for N = 20, i.e., t20. Also give the relative error of t20 with Integeral 0 to 2 ex dx = e2 − 1. (Hint: For-end loops or Elementwise operations)