This document is an assignment submission for a computational methods course. It contains code to calculate the Romberg integration of a function from 0 to 1. The function is defined as f(x) = 7 + 14x^6. The code initializes the maximum acceptable error to 10^-6 and creates a zero matrix to store the Romberg integration values. It then calculates the first entry of the matrix and uses Richardson extrapolation in a nested loop to compute the remaining entries. The loops terminate when the error between the current and previous integration values falls below the acceptable error threshold. The final values of i, h, and the Romberg integration matrix R are displayed.
This document is an assignment submission for a computational methods course. It contains code to calculate the Romberg integration of a function from 0 to 1. The function is defined as f(x) = 7 + 14x^6. The code initializes the maximum acceptable error to 10^-6 and creates a zero matrix to store the Romberg integration values. It then calculates the first entry of the matrix and uses Richardson extrapolation in a nested loop to compute the remaining entries. The loops terminate when the error between the current and previous integration values falls below the acceptable error threshold. The final values of i, h, and the Romberg integration matrix R are displayed.
This document is an assignment submission for a computational methods course. It contains code to calculate the Romberg integration of a function from 0 to 1. The function is defined as f(x) = 7 + 14x^6. The code initializes the maximum acceptable error to 10^-6 and creates a zero matrix to store the Romberg integration values. It then calculates the first entry of the matrix and uses Richardson extrapolation in a nested loop to compute the remaining entries. The loops terminate when the error between the current and previous integration values falls below the acceptable error threshold. The final values of i, h, and the Romberg integration matrix R are displayed.
Q1. Q2. Code for Romberg integration: Function: function f = funy(x) f = 7+14*(x.^6); end M-file: clear;clc;close all; %*****Question 2*********************************************************** e=10e-6; % Maximum acceptable error. n=4; % Sets dimension of R a=0; b=1; % a and b are the definite integration limits. h=b-a; R=zeros(n+1,n+1); % Creates R(5,5) as a zero matrix (faster). R(1,1)= (1/2)*h*(funy(a)+funy(b)); % Computes R(1,1)=I1. for i=1:n h=h/2; % Reduces h by half with every iteration to compute the next R element in column 1. for j=1:i R(i+1,1)= (1/2)*h*(funy(a)+2*sum(funy((a + h):h:(b - h)))+funy(b)); R(i+1,j+1)= (4^j*R(i+1,j)-R(i,j))/(4^j-1); % Richardson extrapolation (slide 22) end error=abs(R(i+1, i+1) - R(i, i)); if error<e break end end %Display i, h, and R i h R ______________________________________________________________________________________ i = 4 h = 0.0625