Computing an integral numerically

I am trying to calculate the integral
I_k = Integral(x^k/(10+x)) from 0 to 1
I have ascertained that we can use a recursion relation to do this and found that if we assume that I_N = I_(N-1) for some N then we can do a backward iteration. Which I think I've done in the following M-File function f = numint2(n) % Computes backwards iterations of I_k using the recursion % relation given % below from the value of n given by the user, to 1, in our case % we will choose n = 25
% Solving the given recursive equation for f(n) = f(n-1) gives our final
% condition.
f(n) = 1/(11*(n));
% Set i and print header and first line of table
i=n-1;
fprintf(1, '%d\t%f\n', n, f(n));
% Recursion Formula
for k = 1:n-1;
f(i) = 1/(10*(i+1))-1/10*f(i+1);
% Print Table
fprintf(1, '%d\t%f\n', i, f(i))
%Reduce i by 1
i=i-1;
end
Which gives the output: k I_k
25 0.003636
24 0.003636
23 0.003803
22 0.003968
21 0.004149
20 0.004347
19 0.004565
18 0.004807
17 0.005075
16 0.005375
15 0.005713
14 0.006095
13 0.006533
12 0.007039
11 0.007629
10 0.008328
9 0.009167
8 0.010194
7 0.011481
6 0.013138
5 0.015353
4 0.018465
3 0.023154
2 0.031018
1 0.046898
What I now need to do,is for given N, let us denote the approximation I_25 by a_N. Determine computationally, N such that the relative difference
abs(a_(N+1) - a_N)/1/2*(a_(N+1)+a_N)
And i don't have a clue where to begin, any advice would be greatly appreciated.
Thanks

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

提问:

2012-1-20

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by