FindMaximum[f,x]
自動的に選ばれた点から始めて f の極大値を求める.
FindMaximum[f,{x,x0}]
x=x0から始めて f の極大値を求める.
FindMaximum[f,{{x,x0},{y,y0},…}]
複数の変数を持つ関数の極大値を求める.
FindMaximum[{f,cons},{{x,x0},{y,y0},…}]
制約条件 cons のもとで極大値を求める.
FindMaximum[{f,cons},{x,y,…}]
制約条件で定義された範囲内の点から始める.
FindMaximum
FindMaximum[f,x]
自動的に選ばれた点から始めて f の極大値を求める.
FindMaximum[f,{x,x0}]
x=x0から始めて f の極大値を求める.
FindMaximum[f,{{x,x0},{y,y0},…}]
複数の変数を持つ関数の極大値を求める.
FindMaximum[{f,cons},{{x,x0},{y,y0},…}]
制約条件 cons のもとで極大値を求める.
FindMaximum[{f,cons},{x,y,…}]
制約条件で定義された範囲内の点から始める.
詳細とオプション
- FindMaximumは{fmax,{x->xmax}}の形式のリストを返す.ここで,fmaxは f の見出された極大値で,xmaxはそのときの x の値である.
- 変数の初期値がリストで与えられている場合,変数の値はこれと同じ次元のリストであると解釈される.
- 制約条件 cons は,等式,不等式,あるいはこれらの論理結合を含むことができる.
- 制約条件 cons は以下の論理結合でよい.
-
lhs==rhs 等式 lhs>rhs または lhs>=rhs 不等式 {x,y,…}∈reg 領域指定 - FindMaximumは,まずすべての変数の値を局所化し,次に記号的となった変数で f を評価し,繰り返して結果を数値的に評価する.
- FindMaximumは属性HoldAllを持ち.Blockを用いて実質的に変数を局所化する.
- FindMaximum[f,{x,x0,x1}]は,x0と x1を x の最初の2つの値として用い,導関数を使用せずに f の極大値を求める.
- FindMaximum[f,{x,x0,xmin,xmax}]は極大値を求める.x が xminから xmaxまでの区間からはみ出したところで探索を中止する.
- f と cons が両方とも線形である場合を除き,FindMaximumによって求まった結果は,極大値のみに対応して最大値には対応しないことがある.
- デフォルトで,変数はすべて実数であると仮定される.
- 線形の f と consについては,x∈Integersを使って変数が整数値のみを取るように指定することができる.
- 次のオプションを使うことができる.
-
AccuracyGoal Automatic 目標確度 EvaluationMonitor None f が評価されるたびに常に評価される式 Gradient Automatic 勾配関数のリスト {D[f,x],D[f,y],…} MaxIterations Automatic 使用する最大反復回数 Method Automatic 使用するアルゴリズム PrecisionGoal Automatic 目標精度 StepMonitor None 段階を取るたびに常に評価される式 WorkingPrecision MachinePrecision 内部計算で使用する精度 - AccuracyGoalとPrecisionGoalの設定値で,極大値の位置の値と極大値に達したときの関数の値の両方で目標とする有効桁精度を指定する.
- FindMaximumは,AccuracyGoalまたはPrecisionGoalで指定された精度(または確度)に達するまで計算を続ける.
- Methodが取り得る設定には,"ConjugateGradient","PrincipalAxis","LevenbergMarquardt","Newton","QuasiNewton"等がある.デフォルト値はAutomaticである.
例題
すべて開く すべて閉じる例 (4)
FindMaximum[x Cos[x], {x, 2}]Plot[x Cos[x], {x, 0, 14}]x /. Last[FindMaximum[x Cos[x], {x, 2}]]FindMaximum[{x Cos[x], 1 ≤ x ≤ 15}, {x, 7}]FindMaximum[{-x - y, x + 2y ≥ 3 && x ≥ 0 && y ≥ 0 && y∈Integers}, {x, y}]FindMaximum[{x + y, {x, y}∈Disk[]}, {x, y}]Show[ContourPlot[x + y, {x, y}∈Disk[]], Graphics[{Red, PointSize[Large], Point[{x, y} /. Last[%]]}]]スコープ (12)
FindMaximum[x Cos[x], {x, 5}]FindMaximum[x Cos[x], {x, 10}]FindMaximum[Sin[x]Sin[2y], {{x, 2}, {y, 2}}]FindMaximum[{Sin[x]Sin[2y], x ^ 2 + y ^ 2 < 3}, {{x, 2}, {y, 2}}]FindMaximum[{Sin[x]Sin[2y], x ^ 2 + y ^ 2 < 3}, {x, y}]FindMaximum[{-x - y, 3x + 2y ≥ 7 && x ≥ 0 && y ≥ 0}, {x, y}]FindMaximum[{-x - y, 3x + 2y ≥ 7 && x ≥ 0 && y ≥ 0 && x∈Integers}, {x, y}]Or制約条件が指定できる:
FindMaximum[{x + y, x ^ 2 + y ^ 2 ≤ 1 || (x + 2) ^ 2 + (y + 2) ^ 2 ≤ 1}, {x, y}]ℛ = Cylinder[{{-1, 0, 1}, {1, 0, -1}}, 1];FindMaximum[{z, {x, y, z}∈ℛ}, {x, y, z}]Graphics3D[{{Opacity[0.5], Green, ℛ}, {Red, PointSize[Large], Point[{x, y, z} /. Last[%]]}}]Subscript[ℛ, 1] = Disk[];
Subscript[ℛ, 2] = Line[{{-(1/2), -(1/2)}, {-(1/2), (1/2)}, {(1/2), (1/2)}, {(1/2), -(1/2)}, {-(1/2), -(1/2)}}];FindMaximum[{(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] = Rectangle[];
Subscript[ℛ, 2] = Circle[{(1/3), (1/3)}, {2 r, r}];FindMaximum[{r, {x, y}∈Subscript[ℛ, 1] && {x, y}∈Subscript[ℛ, 2]}, {r, x, y}]Graphics[{{LightBlue, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}, {Red, Point[{x, y}]}} /. Last[%]]Subscript[ℛ, 3] = Disk[{a, b}, {r, 2 - r}];FindMaximum[{r, ({0, 0} | {1, 0} | {0, 1})∈Subscript[ℛ, 3]}, {a, b, r}]Graphics[{{LightBlue, Subscript[ℛ, 3]} /. Last[%], {Red, Point[{{0, 0}, {1, 0}, {0, 1}}]}}]ℛ = Sphere[];FindMaximum[{x.{1, 2, 3}, x∈ℛ}, x]Subscript[ℛ, 1] = Triangle[{{0, 0}, {1, 0}, {0, 1}}];
Subscript[ℛ, 2] = Disk[{2, 2}, 1];FindMaximum[{EuclideanDistance[x, y], {x∈Subscript[ℛ, 1], y∈Subscript[ℛ, 2]}}, {x, y}]Graphics[{{LightBlue, Subscript[ℛ, 1], Subscript[ℛ, 2]}, {Red, Point[{x, y}]}} /. Last[%]]オプション (7)
AccuracyGoalとPrecisionGoal (2)
FindMaximum[Sin[x / 2], {x, 1}, AccuracyGoal -> 9, PrecisionGoal -> 8]次は,収束基準
と
を強制する.これはデフォルトの機械精度計算では達することができない:
FindMaximum[Sin[x / 2], {x, 1}, AccuracyGoal -> 20, PrecisionGoal -> 18]
WorkingPrecisionの設定値を高くするとこのプロセスは収束する:
FindMaximum[Sin[x / 2], {x, 1}, AccuracyGoal -> 20, PrecisionGoal -> 18, WorkingPrecision -> 40]EvaluationMonitor (1)
Gradient (1)
FindMaximum[Sin[x]Sin[2 y], {x, y}, Gradient -> {Cos[x] Sin[2 y], 2 Cos[2 y] Sin[x]}, Method -> "Newton"]FindMaximum[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)
この場合は,デフォルトの導関数に基づいた方法はうまくいかない:
FindMaximum[-Abs[x + 1] - Abs[x + 1.01] - Abs[y + 1], {x, y}]FindMaximum[-Abs[x + 1] - Abs[x + 1.01] - Abs[y + 1], {x, y}, Method -> "ConjugateGradient"]
FindMaximum[-Abs[x + 1] - Abs[x + 1.01] - Abs[y + 1], {x, y}, Method -> "PrincipalAxis"]NMaximizeもまた,さまざまな直接探索法を使う:
NMaximize[{-Abs[x + 1] - Abs[x + 1.01] - Abs[y + 1]}, {x, y}]StepMonitor (1)
FindMaximumが関数の最大値を求める際に取るステップ:
pts = Reap[FindMaximum[-(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//Minus//Log, {x, -1.3, 1.5}, {y, -1.5, 1.4}, Epilog -> {Red, Line[pts], Point[pts]}]WorkingPrecision (1)
作業精度を
にする.デフォルトでAccuracyGoalとPrecisionGoalは
に設定されている:
FindMaximum[Cos[x ^ 2 - 3 y] + Sin[x ^ 2 + y ^ 2], {x, y}, Method -> "Newton", WorkingPrecision -> 20]特性と関係 (2)
FindMaximumは極大値を求めようとするのに対し,NMaximize は大域的最大値を求めようとする:
FindMaximum[{100 / ((x - 1)^2 + (y - 1)^2 + 1) + 200 / ((x + 1)^2 + (y + 2)^2 + 1), x^2 + y^2 > 3 }, {{x, 2}, y}]NMaximize[{ 100 / ((x - 1)^2 + (y - 1)^2 + 1) + 200 / ((x + 1)^2 + (y + 2)^2 + 1), x^2 + y^2 > 3 }, {x, y}]ContourPlot[100 / (((x - 1)) ^ 2 + ((y - 1)) ^ 2 + 1) + 200 / (((x + 1)) ^ 2 + ((y + 2)) ^ 2 + 1), {x, -3, 2}, {y, -3, 2}, RegionFunction -> (#1 ^ 2 + #2 ^ 2 > 3&), Contours -> 10, Epilog -> ({Red, PointSize[.02], Text["global maximum", {-.995, -2.092}], Point[{-.995, -1.992}], Text["local maximum", {0.5304, 1.2191}], Point[{1.2304, 1.2191}]}), ContourLabels -> True]Maximizeは大域的最大値を求め,無限大の精度で使うことができる:
Maximize[{ 100 / ((x - 1)^2 + (y - 1)^2 + 1) + 200 / ((x + 1)^2 + (y + 2)^2 + 1), x^2 + y^2 > 3 }, {x, y}]N[%]FindMaximumは最大値と最大になる点の両方を与える:
FindMaximum[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]FindArgMaxは最大となる点を与える:
FindArgMax[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]FindMaxValueは最大値を与える:
FindMaxValue[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]考えられる問題 (6)
機械精度の計算では,滑らかな最大値を持つ関数でさえも凸凹に見える:
x /. Last[FindMaximum[x Cos[x], {x, -1}]]
Plot[x Cos[x], {x, % - 1.*^-7, % + 1.*^-7}, PlotRange -> All]機械精度を超えると,このような問題を避けられることがしばしばある:
FindMinimum[x Cos[x], {x, -1}, WorkingPrecision -> 30]FindMaximum[{x + y, x ^ 2 + y ^ 2 ≥ 2 && x ^ 2 + y ^ 2 ≤ 1}, {x, y}]FindMaximum[Tan[x], {x, 2}]FindMaximum[{x ^ 2 + y ^ 2, x ^ 2 + y ^ 2 > 10}, {x, y}]整数線形計画法アルゴリズムは機械数の問題にのみ使うことができる:
FindMaximum[{-x - y, x + 2y ≥ 3 && x > 1 && y > 1 && x∈Integers}, {x, y}, WorkingPrecision -> 20]適切な初期値を与えるとアルゴリズムが収束するようになることがある:
FindMaximum[{-Cos[x] + Exp[(x - 0.5) y], x ^ 2 + y ^ 2 < 1}, {x, y}]FindMaximum[{-Cos[x] + Exp[(x - 0.5) y], x ^ 2 + y ^ 2 < 1}, {{x, -1}, {y, -1}}]f[x_] := Nest[Sin[# + Sin[2#]]&, x, 15]FindMaximum[f[x], {x, 0}]//Timing
g[x_ ? NumericQ] := Nest[Sin[# + Sin[2#]]&, x, 15]FindMaximum[g[x], {x, 0}]//Timing
テクニカルノート
-
▪
- 制約条件付き最適化 ▪
- 制約条件のない最適化 ▪
- 数値最適化 ▪
- 記号的評価
関連するガイド
-
▪
- 最適化 ▪
- 凸最適化 ▪
- 記号的なベクトル,行列,配列
履歴
2003 で導入 (5.0) | 2007 で更新 (6.0) ▪ 2014 (10.0)
テキスト
Wolfram Research (2003), FindMaximum, Wolfram言語関数, https://reference.wolfram.com/language/ref/FindMaximum.html (2014年に更新).
CMS
Wolfram Language. 2003. "FindMaximum." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/FindMaximum.html.
APA
Wolfram Language. (2003). FindMaximum. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FindMaximum.html
BibTeX
@misc{reference.wolfram_2026_findmaximum, author="Wolfram Research", title="{FindMaximum}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/FindMaximum.html}", note=[Accessed: 09-October-2026]}
BibLaTeX
@online{reference.wolfram_2026_findmaximum, organization={Wolfram Research}, title={FindMaximum}, year={2014}, url={https://reference.wolfram.com/language/ref/FindMaximum.html}, note=[Accessed: 09-October-2026]}