用Octave计算曲线积分
广告
{{v.name}}
计算\(\int_L(xy^2+2x)dx+(x^2y+2)dy\),其中\(L:y=2x\)从起点(1,2)至终点(2,4).
程序代码如下
function [text_result, numeric_result] = func85()
pkg load symbolic;
x=sym('x');
y=2 * x;
result1 = x * y^2 + 2 * x;
result2 = x^2 * y + 2;
result = result1 + 2 * result2;
result = int(result, x, 1, 2);
text_result = ["\n", disp(result)];
numeric_result = eval(result);
endfunction
结果如下
>> [text_result, numeric_result] = func85()
text_result =
37
numeric_result = 37