PLEASE use MATLAB only to write the code
clear
clc
f = @(x) (100./x).*sin(10./x);
a = 1; b=3;
n3 = 3; n5 = 5; n7 = 7;
f_exact = -18.79829683678703;
step3 = (b-a)/n3;
step5 = (b-a)/n5;
step7 = (b-a)/n7;
% dx = step
% I = ((b-a)/2n)*(f(a)+ f(a+dx) + ... + f(b-dx)+ f(b) )
I3 = 0;
for j=a:step3:b % a:dx:b
I3 = I3 + ((b-a)/(2*n3))*f(j);
end
I5 = 0;
for j=a:step5:b
I5 = I5 + ((b-a)/(2*n5))*f(j);
end
I7 = 0;
for j=a:step7:b
I7 = I7 + ((b-a)/(2*n7))*f(j);
end
integration_n3 = I3
percent_err_n3 = 100*abs((f_exact - I3)/f_exact)
integration_n5 = I5
percent_err_n5 = 100*abs((f_exact - I5)/f_exact)
integration_n7 = I7
percent_err_n7 = 100*abs((f_exact - I7)/f_exact)
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
PLEASE PLEASE GIVE A THUMBS UP
PLEASE use MATLAB only to write the code 100 10 Assume -18.79829683678703 is the "exact" value...
Can you please do this in matlab Consider the following function: 4 0 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 : Integral estimate A. Write a function capable of performing numerical integration of h(x) using the composite B. write a function capable of performing numerical integration of h(x) using the composite C. Calculate the absolute...
Show work by hand and also using MATLAB code. Model 1 Given a polynomial f(x) Write a first-order approximation of f(x), given the value of f(x) at two points Plot the polynomial and the first-order approximation on a graph Write a second-order approximation of f(x), given the value at three points. Plot the polynomial, the first-order and second-order approximations on a graph Find the integral Exactly Using trapezoidal rule Using composite trapezoidal rule Using Simpson's 1/3 rule . Calculate the...
10 points (done by MATLAB:code submission required) It is known that -1 (a) Write a MATLAB code using composite Simpson 1/3 rule to compute this integral; (b) If a relative error of 1% is required, what should be the maximum step size h (or minimum number of subintervals to be used)? Run your code to find the answer for the maximum step size, and the numerical value of the integral.
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...
2 Problem 3 (25 points) Let I = ïrdz. a) [by hand] Use a composite trapezoidal rule to evaluate 1 using N = 3 subintervals. b) MATLAB] Use a composite trapezoidal rule to evaluate I using N - 6 subinterval:s c) by hand] Use Romberg extrapolation to combine your results from a) and b) and obtain an improved approximation (you may want to compare with a numerical approximation of the exact value of the integral 2 Problem 3 (25 points)...
MATLAB Write an m-file capable of performing numerical integration for the equation using the simpsons and trapezoidal functions: function [value, error] = simpsons(func, a, b, n, I) %retuns the value and error ret = 0; h = (b-a)/(n+1); %step size pts = a:h:b; % array of points for i=2:(n+3)/2 a = 2*i-3; b = 2*i-2; c = 2*i-1; ret = ret + (func(pts(a)) + 4*func(pts(b)) + func(pts(c))); end value = h*ret/3; error = abs(I - value)*100/I; %error between value and...
USE MATLAB Problem 3. Consider the running integral 'dx 0s xs3 Determine: (a) the exact value over the domain, (b) the zero-order approximation, and c) the zero-order approximation. Apply 100 points on the interval 0x<3. (d) Plot the approximation as a continuous curve and the exact value as a sequence of o's Q8. What is exact value of z for 0s x<3? Q9. What is approximate value of z for 0<x3 when using zero-order approximation with 100 points over domain?...
Please attempt only if you know the solution. I have received wrong solutions many times. 3. Use the Composite Trapezoidal rule to estimate the integral 67e**dx by taking the 11 nodes. 4. Evaluate the integral foodx by using composite Simpson's įrd rule with spacing h = 0.25. Compare the error with the exact value. 5. Compute the value of 1.2 (sin r – log I +e")dx by using the composite Simp- son's th rule with spacing h = 0.2.
4. Find the exact value of the integral. Then use composite trapezoidal rule and the composite Simpson's rule to approximate the integral below using n 4 and n 8. Round your results to four decimal places. .3 2a +3a2 dx
need help finishing this problem. matlab erf(x) = 2-1 e_pdt Vr Joe Composte trapezoid rule (MATLAB trapz andlor cuntrapr tunctions) Three point Gauss-Legendre quadrature MATLAB's builb-in integral function (Adaptive Gauss-Kronrod Quadrature) Write a function that receives the following single input 1. A column vector of one or more values at which el) is to be computed Your function should reburn the following outputs (in order, column vectors when input is a vector) 1. The estimate(s) for ert) caculated using composite...