QuestionQuestion

Transcribed TextTranscribed Text

Numerical Integration Problems: 1. Write a user defined function named trapezoid that receives as input the interval endpoints a, b, the value n, and the function f to be integrated. Your funciton should use the Composite Trapezoidal Rule to return the approximate value of the definite integral of the function. 2. Write a user defined function named simpson that receives as input the interval endpoints a, b, the value n(even), and the function f to be integrated. Your function should use the Composite Simpson’s Rule to return the approximate value of the definite integral of the function. 3. Use your functions (trapezoid, simpson) to approximate the integral ∫ 1 0 e x 2 dx. Compare the values obtained for n = 2, 4, 6, 10. Use the error terms to determine the smallest value of n needed to approximate the integral to within 10 −2 and evaluate your functions with that value of n. 4. Determine the value of n required to approximate the integral ∫ 3 0 x √ x 2 + 1 dx to within 10 −5 accuracy with the Composite Simpson’s Rule. Compare your actual error for this n to the theoretical error bound. 1 5. Use Romberg integration to compute R3,3 for ∫ 4 1 ( sin 2 (x) − 2x sin(x) + 1 ) dx 2 Powered by TCPDF (www.tcpdf.org) Powered by TCPDF (www.tcpdf.org) Powered by TCPDF (www.tcpdf.org) Powered by TCPDF (www.tcpdf.org)

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

function Solution()
clear all
clc
close all
disp('----------Question 3-------------')
%syms x
%Iexact=double(int(exp(x^2),x,0,1));

n=[2 4 6 10];
f=@(t)exp(t.^2);
for i=1:3
    ErrorSimpson(i)=Simpson(f,0,1,n(i+1))-Simpson(f,0,1,n(i));
    ErrorTrapezoid(i)=Trapezoid(f,0,1,n(i+1))-Trapezoid(f,0,1,n(i));
end
ErrorSimpson=ErrorSimpson
ErrorTrapezoid=ErrorTrapezoid

%determine the smallest i such that abs(ErrorTrapezoid(i))>10^(-2)
it=3; err=1;%initialize
while abs(err)>10^(-2)
    err=Trapezoid(f,0,1,it)-Trapezoid(f,0,1,it-1);
    it=it+1;
end...
$88.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Numerical Analysis Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats