Matlab Problem Given the following integral and its numerica
Matlab Problem.
Given the following integral and its numerical approximation:
Write a function called approximateIntegral that uses a loop to compute a numerical approximation that adaptively changes ?x to smaller and smaller step sizes, until the approximation is accurate and precise within the number of decimal points defined by precision (difference between approxi+1 and approxi must be less than 110-precision). For example, you may test your function by assuming a starting value of ?x = 1 and decrease the step size from there for each refinement step. I.e. the value for refinement may be 1/10th, asking you to decrease ?x by this factor for each iteration step. Show the results of your refinement in tabular form (you may use fprintf), by displaying ?x and the corresponding numerical approximation to the integral in the command window. The function should alsoreturn the content of this table in matrix form. I.e. a matrix containing the current ?x and the numerical approximation to the integral (res =[dxi; approxi]).
function res = approximateIntegral(dx, refinement, precision)
Notes:
1. Assume dx is less than or equal to 1.
2. Assume refinement is less than or equal to dx.
3. Assume precision is an integer.
4. You do not need additional conditional statements testing the validity of the input arguments.
Matlab Problem. Given the following integral and its numerical approximation: Write a function called approximateIntegral that uses a loop to compute a numerical approximation that adaptively changes ?x to smaller and smaller step sizes, until the approximation is accurate and precise within the number of decimal points defined by precision (difference between approxi+1 and approxi must be less than 1½10^-precision). For example, you may test your function by assuming a starting value of ?x = 1 and decrease the step size from there for each ½refinement½ step. I.e. the value for refinement may be 1/10th, asking you to decrease ?x by this factor for each iteration step. Show the results of your refinement in tabular form (you may use fprintf), by displaying ?x and the corresponding numerical approximation to the integral in the command window. The function should alsoreturn the content of this table in matrix form. I.e. a matrix containing the current ?x and the numerical approximation to the integral (res =[dxi; approxi]). function res = approximateIntegral(dx, refinement, precision) Notes: 1. Assume dx is less than or equal to 1. 2. Assume refinement is less than or equal to dx. 3. Assume precision is an integer. 4. You do not need additional conditional statements testing the validity of the input argumentsSolution
% Just Run This Func
function [ mat ] = aprrox()
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
mat=[];
for i=1:100
mat(i,1)=10/(i*10);
mat(i,2)=(sin(1)/1 +sin(2)/2)*mat(i,1)
end
% first column = value of deltax & second is result
