主題
Search

最接近整數函式


最接近整數函式,也稱為 nint 或 round 函式,定義為 nint(x) 是最接近 x整數。 雖然符號 |_x] 有時用於表示最接近整數函式(Hastad等人,1988),但這種符號相當笨拙,不建議使用。 另請注意,雖然 [x] 有時用於表示最接近整數函式,但 [x] 也常用於表示向下取整函式 |_x_|(包括高斯在他 1808 年對二次互易律的第三次證明中),因此也不鼓勵使用這種符號。

NearestIntegerFunction

由於對於半整數,定義是模稜兩可的,因此通常會新增額外的規則,即半整數總是四捨五入到偶數,以避免統計偏差。 例如,nint(1.5)=2nint(2.5)=2nint(3.5)=4nint(4.5)=4,等等。 C 中遵循此約定math.h庫函式rint,以及 Wolfram 語言,其中最接近整數函式實現為Round[x]。

由於關於小數部分/值和整數部分/值的用法可能令人困惑,下表總結了使用的名稱和符號。 此處,S&O 表示 Spanier 和 Oldham (1987)。

符號名稱S&OGraham 等人Wolfram 語言
[x]向上取整函式--向上取整,最小整數Ceiling[x]
mod(m,n)同餘----Mod[m, n]
|_x_|向下取整函式Int(x)向下取整,最大整數,整數部分Floor[x]
x-|_x_|小數數值frac(x)小數部分 或 {x}SawtoothWave[x]
sgn(x)(|x|-|_|x|_|)小數部分Fp(x)無名稱FractionalPart[x]
sgn(x)|_|x|_|整數部分Ip(x)無名稱IntegerPart[x]
nint(x)最接近整數函式----Round[x]
m\n----Quotient[m, n]
NearestIntegerDiff

上面的圖說明了對於小的 nx^(1/n)-[x^(1/n)]

NearestIntegerFunctionReImAbs
Min Max
Re
Im Powered by webMathematica

最接近整數函式也可以擴充套件到複平面,如上圖所示。


另請參閱

向上取整函式, 向下取整函式, 小數部分, 整數部分, Mod, Nint Zeta 函式, Quotient, 階梯函式

相關的 Wolfram 網站

http://functions.wolfram.com/IntegerFunctions/Round/

使用 探索

參考文獻

Graham, R. L.; Knuth, D. E.; 和 Patashnik, O. "Integer Functions." Ch. 3 in Concrete Mathematics: A Foundation for Computer Science, 2nd ed. Reading, MA: Addison-Wesley, pp. 67-101, 1994.Hastad, J.; Just, B.; Lagarias, J. C.; 和 Schnorr, C. P. "Polynomial Time Algorithms for Finding Integer Relations among Real Numbers." SIAM J. Comput. 18, 859-881, 1988.Spanier, J.; Myland, J.; 和 Oldham, K. B. An Atlas of Functions, 2nd ed. Washington, DC: Hemisphere, 1987.

在 中被引用

最接近整數函式

引用為

Weisstein, Eric W. "Nearest Integer Function." 來自 —— 資源。 https://mathworld.tw/NearestIntegerFunction.html

主題分類