用Octave计算若干项之和的极限
广告
{{v.name}}
计算\(\displaystyle\lim_{n \to \infty} \left [\frac{1}{1 \times 3} + \frac{1}{3 \times 5} + \cdots + \frac{1}{(2n-1) \times (2n+1)} \right ]\)
程序代码如下
function [text_result, numeric_result] = func5(x_value)
pkg load symbolic;
m = sym('m');
n = sym('n');
unit = 1 / ((2*n - 1) * (2*n + 1));
question = symsum(unit, n, 1, m);
lim = limit(question, m, x_value);
text_result = ["\n", disp(lim)];
numeric_result = eval(lim);
endfunction
令\(n \to \infty\),计算结果如下
>>> [text_result, numeric_result] = func5(inf)
text_result =
1/2
numeric_result = 0.5000
令\(n \to 100\),计算结果如下
>> [text_result, numeric_result] = func5(100)
text_result =
100
───
201
numeric_result = 0.4975