FindMinimum[f,x]
搜索 f 的局部极小值,从一个自动选定的点开始.
FindMinimum[f,{x,x0}]
搜索 f 的局部最小值,从 x=x0 开始.
FindMinimum[f,{{x,x0},{y,y0},…}]
搜索多元函数的局部最小值.
FindMinimum[{f,cons},{{x,x0},{y,y0},…}]
搜索约束条件 cons 下局部最小值.
FindMinimum[{f,cons},{x,y,…}]
从约束条件定义区域内的点开始.
FindMinimum
FindMinimum[f,x]
搜索 f 的局部极小值,从一个自动选定的点开始.
FindMinimum[f,{x,x0}]
搜索 f 的局部最小值,从 x=x0 开始.
FindMinimum[f,{{x,x0},{y,y0},…}]
搜索多元函数的局部最小值.
FindMinimum[{f,cons},{{x,x0},{y,y0},…}]
搜索约束条件 cons 下局部最小值.
FindMinimum[{f,cons},{x,y,…}]
从约束条件定义区域内的点开始.
更多信息和选项
- FindMinimum 返回 {fmin,{x->xmin}} 形式的列表,其中 fmin 是找到的 f 最小值,且 xmin 是找到的 x 的值.
- 如果变量的初始值是以列表形式给出,变量值采用相同维数的列表.
- 约束条件 cons 可以包含方程、不等式或这些表达式的逻辑组合.
- 约束条件 cons 可以是下列任意的逻辑组合:
-
lhs==rhs 方程 lhs>rhs 或 lhs>=rhs 不等式 {x,y,…}∈reg 区域规范 - FindMinimum 首先局部化所有变量值,然后计算符号变量下的 f,然后重复计算数值结果.
- FindMinimum 具有属性 HoldAll,且实际上用 Block 局部化变量.
- FindMinimum[f,{x,x0,x1}] 用 x0 和 x1 作为 x 的前 2 个值搜索 f 的局部最小值,避免使用导数.
- FindMinimum[f,{x,x0,xmin,xmax}] 搜索局部最小值,如果 x 超出了 xmin 到 xmax 的范围,停止搜索.
- 除了当 f 和 cons 都是线性的,由 FindMinimum 找到的结果可能是局部的,但不是全局的最小数.
- 在默认情况下,所有变量都假定为实数.
- 对于线性的 f 和 cons,x∈Integers 可以用来指定变量仅采用整数值.
- 可以给出下列选项:
-
AccuracyGoal Automatic 搜索的准确度 EvaluationMonitor None 当 f 计算时,计算的表达式 Gradient Automatic f 梯度分量的列表 MaxIterations Automatic 使用最大迭代数 Method Automatic 使用的方法 PrecisionGoal Automatic 搜索的精度 StepMonitor None 每个步骤计算的表达式 WorkingPrecision MachinePrecision 内部计算的精度 - AccuracyGoal 和 PrecisionGoal 的设置指定搜索最小值的坐标值和函数值的数字位数.
- FindMinimum 持续计算直到由 AccuracyGoal 或 PrecisionGoal 指定的目标中的任何一个被达到.
- Method 的可能设置包括 "ConjugateGradient"、"PrincipalAxis"、"LevenbergMarquardt"、"Newton"、"QuasiNewton"、"InteriorPoint" 和 "LinearProgramming",默认是 Automatic.
范例
打开所有单元 关闭所有单元基本范例 (4)
FindMinimum[x Cos[x], {x, 2}]Plot[x Cos[x], {x, 0, 20}]x /. Last[FindMinimum[x Cos[x], {x, 2}]]FindMinimum[{x Cos[x], 1 ≤ x ≤ 15}, {x, 7}]FindMinimum[{x + y, x + 2y ≥ 3 && x ≥ 0 && y ≥ 0 && y∈Integers}, {x, y}]FindMinimum[{x + y, {x, y}∈Disk[]}, {x, y}]Show[ContourPlot[x + y, {x, y}∈Disk[]], Graphics[{Red, PointSize[Large], Point[{x, y} /. Last[%]]}]]范围 (12)
FindMinimum[x Cos[x], {x, 5}]FindMinimum[x Cos[x], {x, 10}]FindMinimum[Sin[x]Sin[2y], {{x, 2}, {y, 2}}]FindMinimum[{Sin[x]Sin[2y], x ^ 2 + y ^ 2 < 3}, {{x, 2}, {y, 2}}]FindMinimum[{Sin[x ]Sin[2y], x ^ 2 + y ^ 2 < 3}, {x, y}]FindMinimum[{x + y, 3x + 2y ≥ 7 && x ≥ 0 && y ≥ 0}, {x, y}]FindMinimum[{x + y, 3x + 2y ≥ 7 && x ≥ 0 && y ≥ 0 && x∈Integers}, {x, y}]可以指定 Or 约束条件:
FindMinimum[{x + y, x ^ 2 + y ^ 2 ≤ 1 || (x + 2) ^ 2 + (y + 2) ^ 2 ≤ 1}, {x, y}]t = RotationTransform[{{0, 0, 1}, {1, 1, 1}}];
ℛ = TransformedRegion[Ellipsoid[{0, 0, 0}, {1, 2, 3}], t];FindMinimum[{z, {x, y, z}∈ℛ}, {x, y, z}]Graphics3D[{{Opacity[0.5], Green, GeometricTransformation[Ellipsoid[{0, 0, 0}, {1, 2, 3}], t]}, {Red, PointSize[Large], Point[{x, y, z} /. Last[%]]}}]Subscript[ℛ, 1] = Disk[];
Subscript[ℛ, 2] = InfiniteLine[{{-2, 0}, {0, 2}}];FindMinimum[{(x - u)^2 + (y - v)^2, {{x, y}∈Subscript[ℛ, 1], {u, v}∈Subscript[ℛ, 2]}}, {x, y, u, v}]Graphics[{{LightBlue, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}, {Red, Point[{{x, y}, {u, v}} /. Last[%]]}}]Subscript[ℛ, 1] = Triangle[{{0, 0}, {1, 0}, {0, 1}}];
Subscript[ℛ, 2] = Disk[{1, 1}, {2r, r}];FindMinimum[{r, {x, y}∈Subscript[ℛ, 1] && {x, y}∈Subscript[ℛ, 2]}, {r, x, y}]Graphics[{{LightBlue, Subscript[ℛ, 1], Subscript[ℛ, 2]}, {Red, Point[{x, y}]}} /. Last[%]]Subscript[ℛ, 3] = Disk[{a, b}, r];FindMinimum[{r, ({0, 0} | {1, 0} | {0, 1})∈Subscript[ℛ, 3]}, {a, b, r}]Graphics[{{LightBlue, Subscript[ℛ, 3]} /. %[[2]], {Red, Point[{{0, 0}, {1, 0}, {0, 1}}]}}]使用 Circumsphere 直接给出相同结果:
Circumsphere[{{0, 0}, {1, 0}, {0, 1}}]//Nℛ = Sphere[];FindMinimum[{x.{1, 2, 3}, x∈ℛ}, x]Subscript[ℛ, 1] = Triangle[{{0, 0}, {1, 0}, {0, 1}}];
Subscript[ℛ, 2] = Disk[{2, 2}, 1];FindMinimum[{EuclideanDistance[x, y], {x∈Subscript[ℛ, 1], y∈Subscript[ℛ, 2]}}, {x, y}]Graphics[{{LightBlue, Subscript[ℛ, 1], Subscript[ℛ, 2]}, {Red, Point[{x, y}]}} /. %[[2]]]选项 (7)
AccuracyGoal 和 PrecisionGoal (2)
FindMinimum[Sin[x / 2], {x, 1}, AccuracyGoal -> 9, PrecisionGoal -> 8]FindMinimum[Sin[x / 2], {x, 1}, AccuracyGoal -> 20, PrecisionGoal -> 18]设置一个高 WorkingPrecision 使过程收敛:
FindMinimum[Sin[x / 2], {x, 1}, AccuracyGoal -> 20, PrecisionGoal -> 18, WorkingPrecision -> 40]EvaluationMonitor (1)
Gradient (1)
FindMinimum[Sin[x]Sin[2 y], {x, y}, Gradient -> {Cos[x] Sin[2 y], 2 Cos[2 y] Sin[x]}, Method -> "Newton"]FindMinimum[Sin[x]Sin[2y], {x, y}, Gradient -> {Cos[x] Sin[2 y], 2 Cos[2 y] Sin[x]}, Method -> {"Newton", Hessian -> {{-Sin[x] Sin[2 y], 2 Cos[x] Cos[2 y]}, {2 Cos[x] Cos[2 y], -4 Sin[x] Sin[2 y]}}}]Method (1)
FindMinimum[Abs[x + 1] + Abs[x + 1.01] + Abs[y + 1], {x, y}]FindMinimum[Abs[x + 1] + Abs[x + 1.01] + Abs[y + 1], {x, y}, Method -> "ConjugateGradient"]FindMinimum[Abs[x + 1] + Abs[x + 1.01] + Abs[y + 1], {x, y}, Method -> "PrincipalAxis"]NMinimize 也使用了一系列的直接搜索方法:
NMinimize[{Abs[x + 1] + Abs[x + 1.01] + Abs[y + 1], 0 > x > -2}, {x, y}]StepMonitor (1)
在求一个函数最小值的过程中 FindMinimum 采用的步骤:
pts = Reap[FindMinimum[(1 - x) ^ 2 + 100(-x ^ 2 - y) ^ 2 + 1, {{x, -1.2}, {y, 1}}, StepMonitor :> Sow[{x, y}]]][[2, 1]];
pts = Join[{{-1.2, 1}}, pts];ContourPlot[(1 - x) ^ 2 + 100(-x ^ 2 - y) ^ 2 + 1//Log, {x, -1.3, 1.5}, {y, -1.5, 1.4}, Epilog -> {Red, Line[pts], Point[pts]}]WorkingPrecision (1)
设置工作精度为
;默认情况下 AccuracyGoal 和 PrecisionGoal 设置为
:
FindMinimum[Cos[x ^ 2 - 3 y] + Sin[x ^ 2 + y ^ 2], {x, y}, Method -> "Newton", WorkingPrecision -> 20]应用 (3)
从1973年到1994年,S&P 500 指数的长期债券的年回报(R):
R = {{0.942, 1.02, 1.056, 1.175, 1.002, 0.982, 0.978, 0.947, 1.003, 1.465, 0.985, 1.159, 1.366, 1.309, 0.925, 1.086, 1.212, 1.054, 1.193, 1.079, 1.217, 0.889}, {0.852, 0.735, 1.371, 1.236, 0.926, 1.064, 1.184, 1.323, 0.949, 1.215, 1.224, 1.061, 1.316, 1.186, 1.052, 1.165, 1.316, 0.968, 1.304, 1.076, 1.1, 1.012}};μ = Mean[Transpose@R]Σ = Covariance[Transpose[R]]X = Map[Subscript[x, #]&, {"long T-bond", "SP500"}]FindMinimum[{X.Σ.X, Total[X] == 1 && μ.X ≥ 1.10 && Apply[And, Thread[X ≥ {0, 0}]]}, X]找出能包含
个给定半径
的不重叠圆的最小正方形,其中
. 指定圆的数量和每个圆的半径:
n = 20;
r = BlockRandom[RandomReal[{0.5, 1.5}, n], RandomSeeding -> 123];若
为圆
的中心,则目标是最小化
. 目标可以转换为最小化
和
:
objectiveConstraint = Table[-s <= Norm[c[i], Infinity] + r[[i]] <= s, {i, n}];nonOverlapConstraint = Table[Norm[c[i] - c[j]] >= r[[i]] + r[[j]],
{i, 1, n}, {j, i + 1, n}];vars = Append[Table[Element[c[i], Vectors[2, Reals]], {i, n}], Element[s, Reals]];Short[res = FindMinimum[{s, objectiveConstraint, nonOverlapConstraint}, vars], 5]Graphics[{Table[Circle[c[i], r[[i]]], {i, n}], {FaceForm[None], EdgeForm[Black], Rectangle[{-s, -s}, {s, s}]}}] /. res[[2]]Sum[Area[Disk[c[i], r[[i]]]], {i, n}] / Area[Rectangle[{-s, -s}, {s, s}]] /. res[[2]]p = {{2, 2}, {7, 6}, {3, 5}, {4, 8}, {8, 9}, {6, 2.5}};
r = {1, 1.3, 1.5, 1, 0.7, 1.5};
{start, end} = {{0, 0}, {10, 10}};
domain = Graphics[{MapThread[Circle[#1, #2]&, {p, r}],
{PointSize[0.02], Point[{start, end}]}}, Frame -> True]路径被离散成
个不同的点,点与点之间的距离为
,其中
是最小化的轨迹长度:
n = 30;
distanceConstraints = Table[Inactive[Norm][x[i] - x[i - 1]] <= l / n, {i, n}];objectConstraints = Table[Inactive[Norm][-p[[j]] + x[i]] >= r[[j]], {i, 1, n}, {j, 1, 6}];positionConstraints = {x[0] == start, x[n] == end};vars = Append[Table[x[i]∈Vectors[2, Reals], {i, 0, n}], l∈Reals];Short[res = FindMinimum[{l, distanceConstraints,
objectConstraints, positionConstraints}, vars], 2]pts = vars[[1 ;; -2, 1]] /. res[[2]];
Show[domain, Graphics[{Red, Point[pts]}]]属性和关系 (2)
FindMinimum 尽可能返回一个局部最小值,NMinimize 试图求一个全局最小值:
objective = -100 / ((x - 1)^2 + (y - 1)^2 + 1) - 200 / ((x + 1)^2 + (y + 2)^2 + 1);
FindMinimum[{objective, x^2 + y^2 > 3 }, {{x, 2}, y}]NMinimize[{objective, x^2 + y^2 > 3 }, {x, y}]ContourPlot[objective, {x, -3, 2}, {y, -3, 2}, ...]Minimize 求全局最小值,并可以在无穷精度下计算:
Minimize[{-100 / ((x - 1)^2 + (y - 1)^2 + 1) - 200 / ((x + 1)^2 + (y + 2)^2 + 1), x^2 + y^2 > 3 }, {x, y}]N[%]FindMinimum 同时给出最小值和产生最小值的点:
FindMinimum[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]FindArgMin 给出最小值的位置:
FindArgMin[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]FindMinValue 给出最小值:
FindMinValue[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]可能存在的问题 (6)
用机器精度算术,即使具有平滑最小值的函数看起来也会崎岖不平的:
opt = FindMinimum[x Cos[x], {x, 1}]yopt = First[opt];
xopt = x /. Last[opt];Plot[x Cos[x] - yopt, Evaluate[{x, xopt - 1.*^-7, xopt + 1.*^-7}], PlotRange -> All]FindMinimum[x Cos[x], {x, 1}, WorkingPrecision -> 30]FindMinimum[{x + y, x ^ 2 + y ^ 2 ≥ 2 && x ^ 2 + y ^ 2 ≤ 1}, {x, y}]FindMinimum[Tan[x], {x, 2}]FindMinimum[{-x ^ 2 - y ^ 2, x ^ 2 + y ^ 2 > 10}, {x, y}]FindMinimum[{x + y, x + 2y ≥ 3 && x > 1 && y > 1 && x∈Integers}, {x, y}, WorkingPrecision -> 20]FindMinimum[{Cos[x] - Exp[(x - 0.5) y], x ^ 2 + y ^ 2 < 1}, {x, y}]FindMinimum[{Cos[x] - Exp[(x - 0.5) y], x ^ 2 + y ^ 2 < 1}, {{x, -1}, {y, -1}}]f[x_] := Nest[Sin[# + Sin[2#]]&, x, 15]FindMinimum[f[x], {x, 0}]//Timingg[x_ ? NumericQ] := Nest[Sin[# + Sin[2#]]&, x, 15]FindMinimum[g[x], {x, 0}]//Timing历史
1988年引入 (1.0) | 在以下年份被更新:2000 (4.1) ▪ 2003 (5.0) ▪ 2007 (6.0) ▪ 2014 (10.0)
文本
Wolfram Research (1988),FindMinimum,Wolfram 语言函数,https://reference.wolfram.com/language/ref/FindMinimum.html (更新于 2014 年).
CMS
Wolfram 语言. 1988. "FindMinimum." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2014. https://reference.wolfram.com/language/ref/FindMinimum.html.
APA
Wolfram 语言. (1988). FindMinimum. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/FindMinimum.html 年
BibTeX
@misc{reference.wolfram_2026_findminimum, author="Wolfram Research", title="{FindMinimum}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/FindMinimum.html}", note=[Accessed: 28-October-2026]}
BibLaTeX
@online{reference.wolfram_2026_findminimum, organization={Wolfram Research}, title={FindMinimum}, year={2014}, url={https://reference.wolfram.com/language/ref/FindMinimum.html}, note=[Accessed: 28-October-2026]}