Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

myimproperintegral(f,a,tol) which takes three inputs: a: A real number. f: A fun

ID: 3372661 • Letter: M

Question

myimproperintegral(f,a,tol) which takes three inputs:

a: A real number.

f: A function handle for a function for which the improper integral R %u221E

a

f(x) dx converges.

tol: A real number assumed to be positive and quite small.

Approximates R %u221E

a

f(x) dx. The way this should work is as follows: Use a while loop to approximate

R b

a

f(x) dx using quad for b = a, a + 1, a + 2, ... until successive values di%uFB00er by less than tol.

Returns: The %uFB01nal value.


better view



matlab help

myimproperintegral(f,a,tol) which takes three inputs: A real number. A function handle for a function for which the improper integral f(x) dx converges, tol: A real number assumed to be positive and quite small. Approximates f(x) dx. The way this should work is as follows: Use a while loop to approximate f(x) dx using quad for b = a,a + 1, a + 2,... until successive values differ by less than tol. Returns: The final value.

Explanation / Answer


function [ result ] = myimproperintegral(f,a,tol)
t_i1 = 0;
t_i2 = 0;
value = 100000;
t_i1 = quad(f,a,a);
i = a;
while value > tol
    t_i2 = quad(f,a,i + 1);
    value = abs(t_i2 - t_i1);
    t_i1 = t_i2;
    i = i + 1;
   
end
result = quad(f, a, i);