向量值函数的零点

zeros of a vector-valued function

MATLAB 中有没有函数可以找到向量值函数的零点?常用的函数fzero只是针对标量函数,也无法找到任何标量函数的零点,例如f(x)=x^2.

也许我误解了你的问题,但你可以试试这个解决方案:

y = @(x) x^2;

fminbnd(y, -100, 100)

ans =   -3.5527e-15

也许你可以试试 solve:

syms x y
y = @(x) x^2;
solve( y==0, x);

现在无法检查,稍后我将编辑此解决方案。

Matlab 的优化工具箱 fsolve method 表明它能够:

Solves a problem specified by F(x) = 0 for x, where F(x) is a function that returns a vector value. x is a vector or a matrix.

否则,可以通过尝试最小化向量输出的范数来找到通用向量值函数的零点。假设您的函数 F(x) 输出一个 Nx1 向量。您可以尝试通过执行以下操作找到零:

 y = fminunc(@(x) sum(F(x).^2));

 y = fminsearch(@(x) sum(F(x).^2));

然后您必须检查返回的 y 是否“足够接近”零。

最后一条评论,fzero 函数的算法通过检查符号变化来确定根的存在。 [文档]明确表示

x = fzero(fun,x0) tries to find a point x where fun(x) = 0. This solution is where fun(x) changes sign. fzero cannot find a root of a function such as x^2.

事实上,在旧版本的 matlab (R2012b) 中,fzero 的文档有一个限制部分说

The fzero command finds a point where the function changes sign. If the function is continuous, this is also a point where the function has a value near zero. If the function is not continuous, fzero may return values that are discontinuous points instead of zeros. For example, fzero(@tan,1) returns 1.5708, a discontinuous point in tan.

Furthermore, the fzero command defines a zero as a point where the function crosses the x-axis. Points where the function touches, but does not cross, the x-axis are not valid zeros. For example, y = x.^2 is a parabola that touches the x-axis at 0. Because the function never crosses the x-axis, however, no zero is found. For functions with no valid zeros, fzero executes until Inf, NaN, or a complex value is detected.