是各种数值运算的一个选项,指定在内部计算时保持多少位的数值精度.
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]PrecisionGoal 自动增加到低于工作精度的 10:
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}]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 语言. 1988. "WorkingPrecision." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2003. https://reference.wolfram.com/language/ref/WorkingPrecision.html.
APA
Wolfram 语言. (1988). WorkingPrecision. Wolfram 语言与系统参考资料中心. 追溯自 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: 20-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: 20-November-2026]}