matlab 非线性,matlab非线性方程的解法

fsolve是MATLAB用于解决非线性方程组的函数,它实现了多种算法,如信任域Dogleg、反射信任区域和Levenberg-Marquardt。fsolve接受函数句柄、初始猜测值和选项,可以返回解、函数值、退出标志和输出结构。该函数允许用户指定算法、设置最大迭代次数、调整精度参数等。此外,fsolve还支持用户自定义雅可比矩阵,并提供详细的输出信息和诊断功能。
摘要由CSDN通过智能技术生成

CODE:

function [x,FVAL,EXITFLAG,OUTPUT,JACOB] = fsolve(FUN,x,options,varargin)

%FSOLVE solves systems of nonlinear equations of several variables.

%

%   FSOLVE attempts to solve equations of the form:

%

%   F(X) = 0    where F and X may be vectors or matrices.

%

%   FSOLVE implements three different algorithms: trust region dogleg,

%   trust region reflective, and Levenberg-Marquardt. Choose one via the

%   option Algorithm: for instance, to choose trust region reflective, set

%   OPTIONS = optimset('Algorithm','trust-region-reflective'), and then

%   pass OPTIONS to FSOLVE.

%

%   X = FSOLVE(FUN,X0) starts at the matrix X0 and tries to solve the

%   equations in FUN.  FUN accepts input X and returns a vector (matrix) of

%   equation values F evaluated at X.

%

%   X = FSOLVE(FUN,X0,OPTIONS) solves the equations with the default

%   optimization parameters replaced by values in the structure OPTIONS, an

%   argument created with the OPTIMSET function.  See OPTIMSET for details.

%   Use the Jacobian option to specify that FUN also returns a second output

%   argument J that is the Jacobian matrix at the point X. If FUN returns a

%   vector F of m components when X has length n, then J is an m-by-n matrix

%   where J(i,j) is the partial derivative of F(i) with respect to x(j).

%   (Note that the Jacobian J is the transpose of the gradient of F.)

%

%   X = FSOLVE(PROBLEM) solves system defined in PROBLEM. PROBLEM is a

%   structure with the function FUN in PROBLEM.objective, the start point

%   in PROBLEM.x0, the options structure in PROBLEM.options, and solver

%   name 'fsolve' in PROBLEM.solver.  Use this syntax to solve at the

%   command line a problem exported from OPTIMTOOL. The structure PROBLEM

%   must have all the fields.

%

%   [X,FVAL] = FSOLVE(FUN,X0,...) returns the value of the equations FUN

%   at X.

%

%   [X,FVAL,EXITFLAG] = FSOLVE(FUN,X0,...) returns an EXITFLAG that

%   describes the exit condition of FSOLVE. Possible values of EXITFLAG and

%   the corresponding exit conditions are listed below. See the

%   documentation for a complete description.

%

%     1  FSOLVE converged to a root.

%     2  Change in X too small.

%     3  Change in residual norm too small.

%     4  Computed search direction too small.

%     0  Too many function evaluations or iterations.

%    -1  Stopped by output/plot function.

%    -2  Converged to a point that is not a root.

%    -3  Trust region radius too small (Trust-region-dogleg) or

%        Regularization parameter too large (Levenberg-Marquardt).

%    -4  Line search failed.

%

%   [X,FVAL,EXITFLAG,OUTPUT] = FSOLVE(FUN,X0,...) returns a structure

%   OUTPUT with the number of iterations taken in OUTPUT.iterations, the

%   number of function evaluations in OUTPUT.funcCount, the algorithm used

%   in OUTPUT.algorithm, the number of CG iterations (if used) in

%   OUTPUT.cgiterations, the first-order optimality (if used) in

%   OUTPUT.firstorderopt, and the exit message in OUTPUT.message.

%

%   [X,FVAL,EXITFLAG,OUTPUT,JACOB] = FSOLVE(FUN,X0,...) returns the

%   Jacobian of FUN at X.

%

%   Examples

%     FUN can be specified using @:

%        x = fsolve(@myfun,[2 3 4],optimset('Display','iter'))

%

%   where myfun is a MATLAB function such as:

%

%       function F = myfun(x)

%       F = sin(x);

%

%   FUN can also be an anonymous function:

%

%       x = fsolve(@(x) sin(3*x),[1 4],optimset('Display','off'))

%

%   If FUN is parameterized, you can use anonymous functions to cap

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值