Question

PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU.

Use Simpsons 3/8 rule with n segments to approximate the integral of the following function on interval [3, 10] 2.(x-3) f(x)

A correct answer is 6.8837, which can be typed in as follows: 6.8837 A correct answer is 0.2756, which can be typed in as fol

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Script:

close all
clear
clc

syms x
a = 3; b = 10; % Integration interval
f = 1.385 * sin(2*(x - 3)/7); % Function to be integrated
I_Exact = 6.8648;

N = [3, 6]; % Number of sub-intervals
Rel_Err_Simps = zeros(1, length(N));
fprintf('%-10s%-20s%-30s\n', 'N', 'I (Simps.)', 'Rel. Err. (Simps.) %')
for i = 1:length(N)
n = N(i);
I_Simps = CompositeSimpson38Rule(f, a, b, n);
Rel_Err_Simps(i) = abs((I_Simps - I_Exact)/I_Exact) * 100;
fprintf('%-10d%-20.4f%-30.4f\n', n, I_Simps, Rel_Err_Simps(i))
end

function I = CompositeSimpson38Rule(f, a, b, n)
h = (b - a)/n;
x_vals = a:h:b; % Nodes
I = (3*h/8) * ( subs(f, x_vals(1)) + ...
3*sum(subs(f, x_vals(2:3:end-1))) + ...
3*sum(subs(f, x_vals(3:3:end-1))) + ...
2*sum(subs(f, x_vals(4:3:end-1))) + ...
subs(f, x_vals(end)) ); % Composite Simpson's 3/8 Rule
end

Output:

Command Window N I (Simps.) 3 6.8837 6 6.8659 fx >> | Rel. Err. (Simps.) % 0.2756 0.0154

Add a comment
Know the answer?
Add Answer to:
PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. Use Simpson's...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. Consider the...

    PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. Consider the following Ordinary Differential Equation (ODE): dy = 3.0*** + 1.08 * 210 – 3* y2 dat with initial condition at point xo = 0.375: Yo = 0.0044 Apply Runge-Kutta method of the second order with h = 0.25 and the set of parameters given below to approximate the solution of the ODE at the three points given in the table below. Fill in the...

  • Question 2 Not yet answered Marked out of 1.0000 Use Simpson's 1/3 rule with n segments...

    Question 2 Not yet answered Marked out of 1.0000 Use Simpson's 1/3 rule with n segments to approximate the integral of the following function on interval [5, 11] f(x) = 4.96.sin(x - 5) The exact value of the integral is Texact = 0.1976 Fill in the blank spaces in the following table. Round up your answers to 4 decimals. Relative error , is defined as * 100% P Flag question exact E, exac n, segments I, integral €,1%) 2 4

  • Use Simpson's 3/8 rule with n segments to approximate the integral of the following function on...

    Use Simpson's 3/8 rule with n segments to approximate the integral of the following function on interval [3, 15) f(3) = 2.208 - cos(5,0.9 The exact value of the integral is Ieract=19.5662 Fill in the blank spaces in the following table. Round up your answers to 4 decimals. Relative error et is defined as I - Ievac 100% Ieract n, segments I integral +(%) 3 12

  • Use Simpson's 1/3 rule with n segments to approximate the integral of the following function on...

    Use Simpson's 1/3 rule with n segments to approximate the integral of the following function on interval [1, 13] f(t) = 1.945 · sin (27) The exact value of the integral is Teract = 15.4821 Fill in the blank spaces in the following table. Round up your answers to 4 decimals. Relative error et is defined as I - Ieract * 100% Et = Texact n, segments I, integral Et(%) 2 8

  • PLEASE ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. THIS IS...

    PLEASE ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. THIS IS THE FULL QUESTION GIVEN. dyi Consider the following Ordinary Differential Equation (ODE) for function yı (2) on interval [0, 1] dayi dyi +(-9.7) * + 28.64 * dr3 d. 2 dar + (-23.828) * yı (x) = -5.18 0.9-2 with the following initial conditions at point x 0: dyi dy yi = -4.98 = 1.168 26.8052 dar Introducting notations dyi dy2 dayı Y2 =...

  • PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. Solve the...

    PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. Solve the following ODE from x = 4 to x = 4.5 using a step size of h = 0.5 with non-self-starting Heun Method, where y(3.5) = 0.244898 and y(4) = 0.1875. List the values for the Predictor and the Corrector with three iterations only. Make sure you include 4 decimals in your answer. dy dx 3y + = 0 Example answer: 0.2500 X DO) pl...

  • PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. dyi y...

    PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. dyi y = 2.5. dy Consider the following Ordinary Differential Equation (ODE) for function yı(a) on interval [0, 1] dyi dayı dyi d3 + (-3.3) * + 2.9 * + (-0.6) * yı(20) = 0.0 dar2 da with the following initial conditions at point x = 0: dayı = 8.86 = 18.248 dar dra Introducting notations dyi dy2 y2 = da da d2 convert the ODE...

  • Can you solve all the parts please? Use the Trapezoidal Rule, the Midpoint Rule, and Simpson's...

    Can you solve all the parts please? 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.) 1/2 dt, n = 10 (a) the Trapezoidal Rule (b) the Midpoint Rule (c) Simpson's Rule

  • MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demo...

    MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...

  • 4. This question is about using the composite Simpson's Rule to estimate the integral 1 =...

    4. This question is about using the composite Simpson's Rule to estimate the integral 1 = (exp() dr to ten decimal places. (a) Enter and save the following Matlab function function y = f(x) y =exp(x/2); end [O marks) (b) Now complete the following Matlab function function y = compSR (a,b,N) end The function is to return the estimate of I found by applying Simpson's Rule N times. The Matlab function from the previous part of the question should be...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT