inicio mail me! sindicaci;ón

Octave笔记 之 数值积分与解方程

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

喜欢这篇文章?点下面的按钮分享到:Google/豆瓣/鲜果/校内/饭否...
  • Google
  • douban
  • xianguo
  • xiaonei
  • fanfou
  • Facebook
  • del.icio.us
  • Technorati
  • Digg
  • Slashdot
  • TwitThis
  • Live
Tags: , ,

Related posts(相关文章)

沙发: (Using Mozilla Firefox Mozilla Firefox 2.0.0.14 on Linux Linux)

shellex said:

May 9, 2008 @ 1:24 pm

这比赛,真黑啊

[Reply(回复)]


RSS feed for comments on this post · TrackBack URI

Leave a Comment