Octave是GNU的一个项目,作为最好的Matlab免费替代品之一(另一个是Scilab),我们可以用它做很多事情…
函数积分:
Octave supports three different algorithms for computing the integral of a function f over the interval from a to b. These are
quad
Numerical integration based on Gaussian quadrature.
quadl
Numerical integration using an adaptive Lobatto rule.
trapz
Numerical integration using the trapezodial method.
Sample:
对函数
f(x) = x * sin (1/x) * sqrt (abs (1 - x))
有
function y = f (x)
y = x .* sin (1 ./ x) .* sqrt (abs (1 - x));
endfunction
[v, ier, nfun, err] = quad (”f”, 0, 3)
=> 1.9819
=> 1
=> 5061
=> 1.1522e-07
使用fplot(”f”, [0, 3])可以看到图形
解非线性方程:
-2x^2 + 3xy + 4 sin(y) = 6
3x^2 - 2xy^2 + 3 cos(x) = -4
function y = f (x)
y(1) = -2*x(1)^2 + 3*x(1)*x(2) + 4*sin(x(2)) - 6;
y(2) = 3*x(1)^2 - 2*x(1)*x(2)^2 + 3*cos(x(1)) + 4;
endfunction
[x, info] = fsolve (”f”, [1; 2])
x =
0.57983
2.54621
info = 1