さまざまな数値的演算に与えるオプションで,内部計算で維持する精度の桁数を指定する.
WorkingPrecision
さまざまな数値的演算に与えるオプションで,内部計算で維持する精度の桁数を指定する.
詳細
- WorkingPrecisionは,NIntegrateやFindRootのような関数に与えるオプションである.
- WorkingPrecision->n と設定することで,内部計算が最大 n 桁の精度で行われるようになる.
- WorkingPrecision->MachinePrecisionと設定することで,すべての内部計算が機械数で行われるようになる.
- 内部計算が n 桁の精度で行われる場合でも,最終的な結果の精度はこれより劣ることがある.
例題
すべて開く すべて閉じる例 (2)
スコープ (4)
f[x_ ? NumberQ] := x ^ 2 / 2 + Cos[x] - 1Plot[f[x], {x, -0.0001, 0.0001}, WorkingPrecision -> 24]Plot[f[x], {x, -0.0001, 0.0001}]NIntegrate[1 / Sqrt[Sin[x]], {x, 0, 1}, WorkingPrecision -> 24]作業精度より10小さくなるようにPrecisionGoalが自動的に高められる:
NIntegrate[1 / Sqrt[Sin[x]], {x, 0, 1}, WorkingPrecision -> 24, PrecisionGoal -> 14]FindMinimum[Cos[x ^ 2 + y ^ 2] + Sin[x ^ 2 y], {{x, 1.}, {y, 1.}}, WorkingPrecision -> 50]PrecisionGoalとAccuracyGoalは最終精度の半分になるように自動的に設定される:
FindMinimum[Cos[x ^ 2 + y ^ 2] + Sin[x ^ 2 y], {{x, 1.}, {y, 1.}}, WorkingPrecision -> 50, PrecisionGoal -> 25, AccuracyGoal -> 25]sol = NDSolve[{x''[t] + x[t] == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 10}, WorkingPrecision -> 32];PrecisionGoalとAccuracyGoalは作業精度の半分になるように設定される:
sap = NDSolve[{x''[t] + x[t] == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 10}, WorkingPrecision -> 32, PrecisionGoal -> 16, AccuracyGoal -> 16];Plot[Evaluate[{First[x[t] /. sol], First[x[t] /. sap]} - Cos[t]], {t, 0, 10}, WorkingPrecision -> 24]InterpolationOrder->Allを使うとステップ間の誤差が減少する:
sall = NDSolve[{x''[t] + x[t] == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 10}, WorkingPrecision -> 32, InterpolationOrder -> All];
Plot[Evaluate[First[x[t] /. sall] - Cos[t]], {t, 0, 10}, WorkingPrecision -> 24]アプリケーション (1)
一連の解の精度を使ってDuffingの方程式の解の質をチェックする:
deqn = Block[{γ = 15 / 100, ϵ = 3 / 10, ω = 1}, {x''[t] + γ x'[t] - x[t] + x[t] ^ 3 == ϵ Cos[ω t], x[0] == 1, x'[0] == 0}];smp = First[x /. NDSolve[deqn, x, {t, 0, 100}, Method -> {"Extrapolation", "StiffnessTest" -> False}]]Plot[smp[t], {t, 0, 100}]sols = Table[First[x /. NDSolve[deqn, x, {t, 0, 100}, Method -> {"Extrapolation", "StiffnessTest" -> False}, WorkingPrecision -> wp]], {wp, 18, 36, 3}];次のプロットは,終りに近付くに従って解の中に許容範囲を逸脱するものがあるのを示している:
Plot[Evaluate[Map[#[t]&, sols]], {t, 80, 100}]s100 = Map[#[100]&, sols];
ListPlot[s100, DataRange -> {18, 36}]最高精度での解への収束はおよそ6桁が信頼できることを示している:
best = s100[[-1]];ListPlot[Log[10, Abs[Drop[s100, -1] - best]], DataRange -> {18, 33}]考えられる問題 (2)
関数の低精度のパラメータは高精度の演算の使用を無効にすることがある:
two = Total[ConstantArray[.00001, 200000]]sqrt2 = FindRoot[x ^ 2 - two, {x, 1}, WorkingPrecision -> 100]Sqrt[2] - x /. %etwo = SetPrecision[two, Infinity]Table[{wp, Sqrt[etwo] - x /. FindRoot[x ^ 2 - etwo, {x, 1}, WorkingPrecision -> wp]}, {wp, 20, 100, 10}]求解にかかる時間が作業精度の関数として指数的に増大することが予想される:
deqn = Block[{γ = 15 / 100, ϵ = 3 / 10, ω = 1}, {x''[t] + γ x'[t] - x[t] + x[t] ^ 3 == ϵ Cos[ω t], x[0] == 1, x'[0] == 0}];times = Table[{wp, First[Timing[First[x /. NDSolve[deqn, x, {t, 0, 100}, WorkingPrecision -> wp, Method -> "StiffnessSwitching"]]]]}, {wp, Join[{MachinePrecision}, Range[20, 160, 10]]}];
TableForm[times, TableHeadings -> {{}, {"Precision", "Timing"}}]ListLogPlot[times]テクニカルノート
-
▪
- 積分の数値解析
関連するガイド
-
▪
- 精度と確度の制御 ▪
- 微分方程式 ▪
- 時間の測定と最適化 ▪
- ニューラルネットワークの構築と特性 ▪
- ウェーブレット
履歴
1988 で導入 (1.0) | 2003 で更新 (5.0)
テキスト
Wolfram Research (1988), WorkingPrecision, Wolfram言語関数, https://reference.wolfram.com/language/ref/WorkingPrecision.html (2003年に更新).
CMS
Wolfram Language. 1988. "WorkingPrecision." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2003. https://reference.wolfram.com/language/ref/WorkingPrecision.html.
APA
Wolfram Language. (1988). WorkingPrecision. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WorkingPrecision.html
BibTeX
@misc{reference.wolfram_2026_workingprecision, author="Wolfram Research", title="{WorkingPrecision}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/WorkingPrecision.html}", note=[Accessed: 07-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_workingprecision, organization={Wolfram Research}, title={WorkingPrecision}, year={2003}, url={https://reference.wolfram.com/language/ref/WorkingPrecision.html}, note=[Accessed: 07-November-2026]}