跳轉到內容

分形/數學/數字

來自華夏公益教科書
        "Many questions concerning (discrete) dynamical systems are of a number theoretic or combinatorial nature." Christian Krattenthaler
實數集

數字型別

[編輯 | 編輯原始碼]

數字可以用作 

  • 數值計算中使用的數值
  • 符號計算中使用的符號

數字(例如 角度以圈數表示)可以是:[1]

  • 十進位制數(基數 = 10)[2]
    • 整數
    • 實數
      • 比率 = 分數(有限 連分數) = 有理數(任何有理數的無理度為 1)[3]
        • 最簡形式(不可約形式) :
        • 可約形式
          • 顯式規範化形式(僅當分母為奇數時):[4]
      • 無理數 = 無限連分數(如果數字不能表示為比率,則它就是無理數)
        • 代數數(無理度 = 2)
        • 超越數(無理度 > 2)
    • 十進位制浮點數 [5][6]
      • 有限展開
      • 無限(無窮)展開
        • 無限地繼續下去而不重複(在這種情況下,該數字稱為無理數 = 非重複非終止小數[7]
        • 迴圈或重複
          • (嚴格)週期性(字首 = 0,週期 > 0)
          • 混合 = 終結週期性(字首 > 0,週期 > 0)
  • 二進位制數(基數 = 2)[8]
    • 二進位制有理數(比率)
    • 二進位制實數
      • 二進位制浮點數(科學記數法)
      • 原始二進位制(原始 IEEE 格式)
      • 二進位制定點數(記號)
        • 具有重複序列 :
        • 具有無窮展開



使用有限數量的位表示實數的方法

[編輯 | 編輯原始碼]

展開/表示

[編輯 | 編輯原始碼]
  • 有限 = 終止
  • 無限 = 非終止
    • 週期性 = 無限迴圈
    • 前週期性 = 最終週期性
    • 非週期性: 既不終止也不迴圈的二進位制數字表示無理數

位值記數制中的基數或底數[14]

形式/記號

[編輯 | 編輯原始碼]

記號[15]

  • 數字和基數的序列
    • 無限序列
      • 一般形式用省略號 ( = 3 個點) 表示:
      • 無限迴圈部分用
        • 圓括號表示: .
        • 上劃線:
    • 有限序列
      • 1.23
        • 帶尾隨零: 1.2300,用於指示有效數字的位數,例如在測量中。
      • 帶絕對測量誤差: 均值 ± 範圍 [16],例如: 72.20 ± 0.02
  • 整數的比率
    • 最簡形式(不可約形式) :
    • 可約形式
      • 顯式規範形式 (僅當分母為奇數時):[17],例如:
      • 角度分母公式的顯式規範形式:
  • 連分數:
  • 科學 (指數) 形式或記號: [18]

計算機數字格式(儲存形式)

  • 浮點形式(擴充套件):數字的小數點可以“浮動”到數字的有效數字的左側、右側或之間。
  • 定點格式

圓括號

[edit | edit source]

帶指數的括號(上標)表示該序列重複的次數[19]


尾隨零

[edit | edit source]

小數點右側的尾隨零,如 12.3400,不會影響數字的值,如果只關心數字的值,可以省略。即使零無限重複,也是如此。例如,在藥學中,劑量值會省略尾隨零,以防止誤讀。但是,尾隨零可能有助於指示有效數字的數量,例如在測量中。在這種情況下,透過刪除尾隨零來“簡化”數字將是不正確的。

非零 b 進位制整數 n 中尾隨零的數量等於 b 的最高次冪的指數,該次冪能整除 n。例如,14000 有三個尾隨零,因此可被 1000 = 103 整除,但不能被 104 整除。此屬性在尋找整數分解中的小因子時非常有用。一些計算機架構在它們的指令集中具有計數尾隨零操作,可以高效地確定機器字中的尾隨零位的數量。

二進位制展開示例

[edit | edit source]

首先檢查比率是否是最簡分數(可約)

二進位制展開可以是

轉換

[edit | edit source]

轉換之間

  • 進位制(從二進位制到十進位制,...)
  • 形式(有理數到展開式,...)[20]
    • 從十進位制展開式識別有理數:[21] “計算近似的簡單連分數,並在較大的部分商 a_n 之前截斷它,然後計算截斷的連分數的值。”
    • 轉換迴圈小數為分數 [22]
    • 分數轉換為迴圈小數[23]
      • 使用弗洛伊德迴圈檢測演算法查詢第一個重複餘數
      • 遞迴除法和餘數的收集(與十進位制分數的片段相關聯)
    • 轉換迴圈分數為不同進位制[24]

使用

演算法

[edit | edit source]
  • 尋找
    • 二進位制字串/序列中嚴格重複的模式(事先不知道)[30] “如果有模式=>它的長度必須能整除字串長度”AnotherGeek[31]
    • 二進位制字串/序列中非重複和嚴格重複的模式(事先不知道)
  • 轉換具有迴圈小數部分的數字


將分數約化為最簡分數

[edit | edit source]

可約分數可以透過將分子和分母除以公因子來約分。如果分子和分母都除以它們的最大公約數,則可以將其完全約化為最簡分數

尋找最大公約數的演算法

  • 歐幾里得演算法
  • 質因數分解

歐幾里得演算法通常是首選,因為它允許約分分子和分母過大而難以因式分解的分數

示例

將十進位制分數轉換為二進位制

[edit | edit source]

“...我們反覆將十進位制分數乘以 2。如果結果大於或等於 1,我們將 1 新增到答案中。如果結果小於 1,我們將 0 新增到答案中。”(來自弗吉尼亞理工大學線上 CS 模組[35]

演算法:[36]

  • 將輸入的十進位制分數乘以二
  • 從以上結果
    • 取整數部分作為二進位制數字
    • 取小數部分作為下一步的起點
  • 重複,直到得到 0 或週期性數字
  • 從上往下讀取數字——第一個二進位制數字是小數點後的第一個數字

將 0.1 十進位制分數轉換為二進位制分數的示例

   0.1 * 2 = 0.2 -> 0
   0.2 * 2 = 0.4 -> 0
   0.4 * 2 = 0.8 -> 0
   0.8 * 2 = 1.6 -> 1
   0.6 * 2 = 1.2 -> 1
   0.2 * 2 = 0.4 -> 0
   0.4 * 2 = 0.8 -> 0
   0.8 * 2 = 1.6 -> 1
   0.6 * 2 = 1.2 -> 1
   0.2 * 2 = 0.4 -> 0
   0.4 * 2 = 0.8 -> 0
   0.8 * 2 = 1.6 -> 1
   0.6 * 2 = 1.2 -> 1
   0.2 * 2 = 0.4 -> 0

結果


迴圈分數:[37]

0.(567) = 567/999 = 189/333 = 63/111
0.(0011) = 0011 / 1111 =(in decimal) 3/15 = 1/5

圖形轉換

程式碼

將二進位制分數轉換為十進位制比率

[edit | edit source]

幾何級數

[編輯 | 編輯原始碼]

(前)週期性二進位制小數可以拆分為兩個小數

  • 有限的
  • 無限:週期性,前週期部分為空或全部為零


當 |r|<1 時,等比數列的公式:[38]

對於前週期部分為空或全部為零的無限週期二進位制小數,該公式為[39]

其中 

  • b 是二進位制數字 : 0 或 1
  • t 是前週期塊的長度
  • p 是週期塊的長度
  • a 的值只是重複塊第一次出現的數值
  • 因此



完整公式 現在為

          


示例 

程式碼示例

[edit | edit source]

使用 bc – arbitrary–precision arithmetic language 將十進位制比率轉換為二進位制[40]

bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
obase=2
3/14
.0011011011011011011011011011011011011011011011011011011011011011010
1/5
.0011001100110011001100110011001100110011001100110011001100110011001

itoa 函式[42]

/* 
 itoa example 
 http://www.cplusplus.com/reference/cstdlib/itoa/
*/
#include <stdio.h>
#include <stdlib.h>

int main ()
{
  int i;
  char buffer [33];
  printf ("Enter a number: ");

  scanf ("%d",&i);
  itoa (i,buffer,10);
  printf ("decimal: %s\n",buffer);

  itoa (i,buffer,16);
  printf ("hexadecimal: %s\n",buffer);

  itoa (i,buffer,2);
  printf ("binary: %s\n",buffer);

  return 0;
}

二進位制整數常量

[edit | edit source]

二進位制整數常量[43]

"整數常量可以寫成二進位制常量,由 '0' 和 '1' 數字序列組成,以 '0b' 或 '0B' 為字首。這在對位級操作(如微控制器)進行大量操作的環境中特別有用。

以下語句是相同的

     i =       42;
     i =     0x2a;
     i =      052;
     i = 0b101010;

這些常量的型別遵循與八進位制或十六進位制整數常量相同的規則,因此可以應用像 'L' 或 'UL' 這樣的字尾。"

GMP 庫[44]

/*

C programme using gmp

gcc r.c -lgmp -Wall

http://gmplib.org/manual/Rational-Number-Functions.html#Rational-Number-Functions

*/

#include <stdio.h>
#include <gmp.h>

int main ()
{
        
        // input = binary fraction as a string 
        char  *sbr = "01001010010010100101001001010010010100101001001010010100100101001001010010100100101001010/11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
        
        mpq_t q;   // rational number; 
        int b =2 ; // base of numeral system
        mpz_t  n ;
        mpz_t  d ;
        mpf_t f;

        // init and set variables 
        mpq_init (q); // Initialize r and set it to 0/1.
        mpq_set_str (q, sbr ,  b);
        mpq_canonicalize (q); // It is the responsibility of the user to canonicalize the assigned variable before any arithmetic operations are performed on that variable. 
        mpq_canonicalize (q); // It is the responsibility of the user to canonicalize the assigned variable before any arithmetic operations are performed on that variable.

        // n , d
        mpz_inits(n,d,NULL); 
        mpq_get_num(n,q);
        mpq_get_den(d, q);

        //
        mpf_init2(f, 100); // http://stackoverflow.com/questions/12804362/gmp-division-precision-or-printing-issue
        mpf_set_q(f,q); // There is no rounding, this conversion is exact.

        // print 
        gmp_printf ("decimal fraction =  %Zd / %Zd \ndecimal canonical form =  %Qd\n",n,d, q); // 
        gmp_printf ("binary fraction  = %s \n", sbr); // 
        gmp_printf ("decimal floating point number : %.30Ff \n", f); // 
        
        
        
        // clear memory
        mpq_clear (q);
        mpz_clear (n);
        mpz_clear (d);
        mpf_clear (f);
        
        return 0;
}

輸出

decimal fraction =  179622968672387565806504266 / 618970019642690137449562111 
decimal canonical form =  179622968672387565806504266/618970019642690137449562111
binary fraction  = 01001010010010100101001001010010010100101001001010010100100101001001010010100100101001010/11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 
decimal floating point number : 0.290196557138708685358212602171 

Haskell

[edit | edit source]

Claude Heiland-Allen 的程式碼:[45]

--  http://mathr.co.uk/blog/2014-10-13_converting_fractions_to_strings_of_digits.html

 import Data.Fixed (mod')
 import Data.List (nub)
 import Data.Ratio ((%), denominator)
 import Data.Numbers.Primes (primeFactors)
 import System.Environment (getArgs)

 data Digits = Digits
  { dNegative :: Bool
  , dInteger
  , dPreperiodic
  , dPeriodic :: [Int]
  } deriving Show

preperiod :: Digits -> Int
preperiod = length . dPreperiodic

period :: Digits -> Int
period = length . dPeriodic

digitsAtBase :: Int -> Rational -> Digits
digitsAtBase base rational
  = Digits
  { dNegative = rational < 0
  , dInteger = int
  , dPreperiodic = pre
  , dPeriodic = per
  }
  where
    integer :: Integer
    fraction :: Rational
    (integer, fraction) = properFraction (abs rational)
    int | integer == 0 = [0]
        | otherwise = goInt integer []
    goInt i ds
      | i == 0 = ds
      | otherwise = goInt i' (fromInteger d : ds)
      where
        (i', d) = i `divMod` baseZ
    factors :: [Integer]
    factors = map fromIntegral . nub . primeFactors $ base
    isPreperiodic :: Rational -> Bool
    isPreperiodic x = any (`divides` denominator x) factors
    baseZ :: Integer
    baseZ = fromIntegral base
    baseQ :: Rational
    baseQ = fromIntegral base
    (pre, per) = goPre fraction
      where
        goPre :: Rational -> ([Int], [Int])
        goPre x
          | isPreperiodic x = first (d:) (goPre x')
          | otherwise = ([], d : goPer x x')
          where (d, x') = properFraction (baseQ * x)
        goPer :: Rational -> Rational -> [Int]
        goPer x0 x
          | x0 == x = []
          | otherwise = d : goPer x0 x'
          where (d, x') = properFraction (baseQ * x)
    first :: (a -> c) -> (a, b) -> (c, b)
    first f (a, b) = (f a, b)
    divides :: Integer -> Integer -> Bool
    factor `divides` number = number `mod` factor == 0

digitsToString :: [String] -> Digits -> String
digitsToString digits Digits
  { dNegative = sign
  , dInteger = int
  , dPreperiodic = pre
  , dPeriodic = per
  }
  = (if sign then "-" else "")
  ++ d int ++ "." ++ d pre ++ "(" ++ d per ++ ")"
  where
    d = concatMap (digits !!)

atBase :: Int -> Rational -> String
atBase base rational = digitsToString ds (digitsAtBase base rational)
  where
    ds | base <= 62 = map (:[]) $ ['0'..'9'] ++ ['A'..'Z'] ++ ['a'..'z']
       | otherwise = [ "<" ++ show d ++ ">" | d <- [0 .. base - 1] ]

main :: IO ()
main = do
  [sbase, sfraction] <- getArgs
  let (snum, _:sden) = break ('/' ==) sfraction
      base = read sbase
      num = read snum
      den = read sden
      rational = num % den
  putStrLn (atBase base rational)

Python

[edit | edit source]
# https://wiki.python.org/moin/BitManipulation
# binary string to integer 
>>> int('00100001', 2)
33
# conversion from binary string to  hex string
>>> print "0x%x" % int('11111111', 2)
0xff
>>> print "0x%x" % int('0110110110', 2)
0x1b6
>>> print "0x%x" % int('0010101110101100111010101101010111110101010101', 2)
0xaeb3ab57d55

其他方法[46]

如何在計算機程式中使用數字?

[edit | edit source]

首先閱讀

整數

[edit | edit source]
  • 型別
  • 限制和溢位

限制

[edit | edit source]
/*

gcc l.c -lm -Wall
./a.out

http://stackoverflow.com/questions/29592898/do-long-long-and-long-have-same-range-in-c-in-64-bit-machine
*/
#include <stdio.h>
#include <math.h> // M_PI; needs -lm also 
#include <limits.h> // INT_MAX, http://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html

int main(){

double lMax;

 lMax = log2(INT_MAX);
 printf("INT_MAX \t= %25d ; lMax = log2(INT_MAX) \t= %.0f \n",INT_MAX,  lMax);

 lMax = log2(UINT_MAX);
 printf("UINT_MAX \t= %25u ; lMax = log2(UINT_MAX) \t= %.0f \n", UINT_MAX,  lMax);

 lMax = log2(LONG_MAX);
 printf("LONG_MAX \t= %25ld ; lMax = log2(LONG_MAX) \t= %.0f \n",LONG_MAX,  lMax);

 lMax = log2(ULONG_MAX);
 printf("ULONG_MAX \t= %25lu ; lMax = log2(ULONG_MAX) \t= %.0f \n",ULONG_MAX,  lMax);

 lMax = log2(LLONG_MAX);
 printf("LLONG_MAX \t= %25lld ; lMax = log2(LLONG_MAX) \t= %.0f \n",LLONG_MAX, lMax);

 lMax = log2(ULLONG_MAX);
 printf("ULLONG_MAX \t= %25llu ; lMax = log2(ULLONG_MAX) \t= %.0f \n",ULLONG_MAX, lMax);

return 0;
}

結果

INT_MAX 	=                2147483647 ; lMax = log2(INT_MAX) 	= 31 
UINT_MAX 	=                4294967295 ; lMax = log2(UINT_MAX) 	= 32 
LONG_MAX 	=       9223372036854775807 ; lMax = log2(LONG_MAX) 	= 63 
ULONG_MAX 	=      18446744073709551615 ; lMax = log2(ULONG_MAX) 	= 64 
LLONG_MAX 	=       9223372036854775807 ; lMax = log2(LLONG_MAX) 	= 63 
ULLONG_MAX 	=      18446744073709551615 ; lMax = log2(ULLONG_MAX) 	= 64 

例如,Wolf Jung 在 程式 Mandel 中進行了一個靜默邊界檢查:[48]

// mndynamo.h  by Wolf Jung (C) 2007-2014
typedef  unsigned long long int  qulonglong;

// mndcombi.cpp  by Wolf Jung (C) 2007-2014
 qulonglong mndAngle::wake(int k, int r, qulonglong &n)
{  if (k <= 0 || k >= r || r > 64) return 0LL;

如果 r 對無符號長長整型太大,則返回 0 以防止整數溢位。

GMP 庫具有任意精度的有理數。

浮點數

[edit | edit source]

精度

[edit | edit source]

精度

  • GMP:每個浮點數的尾數具有使用者可選擇的精度(變數 prec 型別 mp_bitcnt_t)。多精度數字的位數在 C 型別 mp_bitcnt_t 中表示。目前這始終是一個無符號長整型
  • MPFR:精度是用於表示浮點數尾數(尾數)的位數;相應的 C 資料型別是 mpfr_prec_t。

有理數

[編輯 | 編輯原始碼]
圓上的有理點在立體投影下對應於直線上的有理點。

"任何具有有限小數展開式的數字都是有理數。"換句話說:"任何浮點數都可以轉換為有理數。" [49]

因此,在數值計算中,人們可以使用整數或浮點數(有理數)。

十進位制

[編輯 | 編輯原始碼]

二進位制

[編輯 | 編輯原始碼]

C 中,可以使用 

Maxima CAS 中,可以使用 

(%i1) ibase;
(%o1) 10
(%i2) obase;
(%o2) 10
(%i3) ibase:2;
(%o3) 2
(%i4) x=1001110;
(%o4) x=78

使用 **Haskell**(ghci)計算二進位制數,並將二進位制數表示為包含重複部分的字串。

-- by Claude Heiland-Allen
-- http://mathr.co.uk/blog/haskell.html
Prelude> let rep n s = concat (replicate n s)
Prelude> putStrLn $ ".(" ++ rep 88 "001" ++ "010)"
.(001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001010)

putStrLn $ ".(" ++ rep 87 "001" ++ "010001)"
.(001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001010001)

Prelude> putStrLn $ ".(" ++ rep 88 "001" ++ "0001)"
.(0010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010001)

Prelude> putStrLn $ ".(" ++ rep 88 "001" ++ "0010)"
.(0010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010)

在 **Python** 中 

>>> bin(173)
'0b10101101'
>>> int('01010101111',2)
687

字面量

[編輯 | 編輯原始碼]

在 Python 中,可以使用二進位制字面量:[51]

python
Python 2.7.5+ (default, Feb 27 2014, 19:37:08) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 0b101111
47

無理數 = 非有理數

[編輯 | 編輯原始碼]
無理數
            The problem is that we are exploring environments based upon irrational numbers through computer machinery which works with finite rationals ! ( Alessandro Rosa )

展開式不終止且不迴圈

型別

  • 代數數 = 代數方程的根。例如:sqrt(2),
  • 超越數 = 非代數數


如果要使用無理數,則應檢查 

  • 符號計算 
    • 精確數可以作為符號使用,但“無法列印整個無理數”。
    • 無限連分數
  • 數值計算:無理數的近似有理數 [52](丟番圖逼近 [53]
    • 整數的比率
    • 浮點數
    • 有限連分數

黃金分割的倒數

[編輯 | 編輯原始碼]

最無理的數字[54] 在連分數中,所有數字都為 1,表示所有無理數中最慢的收斂速度。


使用 Maxima CAS 

(%i10) print(float(%phi-1));
(%o10).6180339887498949
(%i11) rationalize(float(%phi-1));
(%o11) 347922205179541/562949953421312

和  


(%i14) print(float(1/%phi));
(%o14) .6180339887498948
(%i15) rationalize(float(1/%phi));
(%o15) 5566755282872655/9007199254740992

其中分母 


  • 複數冪的多值性會導致很大的問題(分支切割的人為產物,arg 的任意主值)。
  • 域著色 [55][56]


示例

如何查詢數字型別

[編輯 | 編輯原始碼]

請注意,在具有有限精度的數值計算中(在計算機上) 

  • 如果數字表示為比率(整數),則它是有理數。
  • 如果數字具有浮點表示形式,那麼它也是有理數,因為有限的精度等於有限的展開式。
/*

Maxima CAS batch file

*/

remvalue(all);
kill(all);

/*
input = ratio, which automatically changed to lowest terms by Maxima CAS
output = string describing a type of decimal expansion

---------------------------------------------------------------------------------
" The rules that determine whether a fraction has recurring decimals or 
not are really quite simple.

1. First represent the fraction in its simplest form, by dividing both 
numerator and denominator by common factors.

2. Now, look at the denominator.

3.
3.1 If the prime factorization of the denominator contains only the 
factors 2 and 5, then the decimal fraction of that fraction will not 
have recurring digits. In other words : Terminating decimals represent 
rational numbers of the form k/(2^n*5^m)

3.2
  A fraction in lowest terms with a prime denominator other than 2 or 5 
(i.e. coprime to 10) always produces a repeating decimal.

3.2.1
  If the prime factorization yields factors like 3, 7, 11 or other 
primes (other than 2 and 5), then that fraction will have a decimal 
representation that includes recurring digits.

3.2.2
   Moreover, if the denominator's prime factors include 2 and/or 5 in 
addition to other prime factors like 3, 7, etc., the decimal 
representation of the fraction will start with a few non-recurring 
decimals before the recurring part."

http://blogannath.blogspot.com/2010/04/vedic-mathematics-lesson-49-recurring.html

check :
http://www.knowledgedoor.com/2/calculators/convert_a_ratio_of_integers.html

wikipedia: Repeating_decimal
" A fraction in lowest terms with a prime denominator other than 2 or 5 (i.e. coprime to 10) always produces a repeating decimal.
The length of the repetend (period of the repeating decimal) of 1/p is equal to the order of 10 modulo p. 
If 10 is a primitive root modulo p, the repetend length is equal to p − 1; if not, 
the repetend length is a factor of p − 1. 
This result can be deduced from Fermat's little theorem, which states that 10p−1 = 1 (mod p)."

---------------------------------------------------------------------------------------

*/

GiveRatioType(ratio):=
block
(
   [denominator:denom(ratio),
    FactorsList ,
    Factor,
    Has25:false,
    HasAlsoOtherPrimes:false,
    type ], /* type of decimal expansion of the ratio of integers */

   /* compute list of prime factors ofd denominator */
   FactorsList:ifactors(denominator),
   FactorsList:map(first,FactorsList),
   print(denominator, FactorsList),
   /* check factors type :
          only 2 or 5
          also other primes then 2 or 5
  */
   if (member(2,FactorsList) or member(5,FactorsList)) then Has25:true,

   for Factor in FactorsList do
    if (not member(Factor,[2,5])) then
          HasAlsoOtherPrimes:true,
   print(Has25, HasAlsoOtherPrimes),

   /* find type of decimal expansion */
   if (not Has25 and HasAlsoOtherPrimes)     then type:"periodic",
   if (Has25 and HasAlsoOtherPrimes)     then type:"preperiodic",
   if (Has25 and not HasAlsoOtherPrimes) then type:"finite",

   return(type)
)$

compile(all)$

/* input numbers*/
a:1 $
b:3 $

r:a/b$

type :  GiveRatioType(r);

在數學(理論)中 

  • "... 有理數是可數集,而無理數是不可數集。換句話說,無理數比有理數更多。" [59]
  • "... 在實數集中,存在無理數的連續統和只有 aleph-zero 有理數。因此,任何隨機數是無理數的機率為 1;"(Bartek Ogryczak) [60] "為了精確起見,你應該說幾乎肯定為 1。"– David Hammen


以最簡形式表示的有理數的高度

[編輯 | 編輯原始碼]
托馬斯函式 = 1/q
  "a “height function” is some real-valued function that defines the “arithmetic complexity” of a point ... " Brian Lawrence[61]

在有理數集上定義的高度函式的型別

  • 對於有理數的(乘法)高度 [62] 也稱為 樸素高度
  • 對數高度或加性[63]

其中

  • p/q 是最簡形式的有理數


  "How complicated is a rational number? Its size is not a very good indicator for this. For instance, 1987985792837/1987985792836 is approximately 1, but so much more complicated than 1. We'll explain how to measure the complexity of a rational number using various notions of height. We'll  then see how heights are used to prove some basic finiteness theorems in number theory. One example will be the Mordell-Weil theorem: that on any rational elliptic curve, the group of rational points is finitely generated. " Alina Bucur (UCSD): Size Doesn't Matter: Heights in Number Theory


關鍵詞

  • 數域
  • 數論中的高度函式
  • 劃分函式 : "劃分數的行為類似於分形,具有無限重複的結構" [64]

隨機數

[編輯 | 編輯原始碼]

任何隨機數的機率 

  • 是無理數幾乎為 1(理論上,因為基數)
  • 是有理數為 1(數值計算中,因為精度有限)
  • 概括 : 標量 / 向量 / 張量
  • 欄位 : 標量 , 向量, 張量

參考文獻

[編輯 | 編輯原始碼]
  1. 探索二進位制:九種顯示浮點數的方式
  2. 維基百科 : 數制
  3. math.stackexchange 問題:是否存在既不是有理數又不是無理數的實數
  4. 如何使用一維二次對映 G. Pastor , M. Romera, G. Álvarez, and F. Montoya
  5. 每個程式設計師都應該知道的浮點數運算
  6. Stackoverflow : 為什麼浮點數不精確?
  7. 家庭學校數學  : 迷人的無理數
  8. 教程:Kip Irvine 的浮點二進位制
  9. 對偶數 & 自動微分
  10. 影片:虛數是實數,來自 Welch Labs
  11. math stackexchange 問題:是否存在數字的第三維
  12. 在浮點數的遊戲中獲勝:John L. Gustafson , Isaac Yonemoto 的 Posit 算術
  13. fractalforums.org : posits
  14. 維基百科:基數
  15. 浮點格式調查 Robert Munafo 在 AWS 上的網頁   © 1996-2022 Robert P. Munafo.  
  16. 物理 132 實驗手冊:如何使用有效數字編寫數字,作者:Brokk Toggerson 和 Aidan Philbin
  17. 如何使用一維二次對映 G. Pastor , M. Romera, G. Álvarez, and F. Montoya
  18. calculatorsoup:科學記數法轉換器
  19. 一種解決 Mandelbrot 集外部射線繪製中限制的方法 M. Romera,1 G. Pastor, A. B. Orue,1 A. Martin, M.-F. Danca,and F. Montoya
  20. 將分數轉換為數字字串,作者:Claude Heiland-Allen
  21. 從其小數展開式識別有理數,作者:William Stein
  22. basic-mathematics : 將迴圈小數轉換為分數
  23. 有理數的迴圈小數,作者:Yurii Lahodiuk
  24. Quora : 如何將迴圈分數轉換為不同的基數
  25. knowledgedoor 計算器:convert_a_ratio_of_integers
  26. R.Knott : 分數 - 小數計算器
  27. 基數 - 十進位制數轉換
  28. 十進位制到浮點轉換器,作者:Rick Regan
  29. wolframalpha 二進位制到十進位制轉換
  30. stackoverflow 問題 : 查詢重複模式的最佳演算法
  31. stackoverflow 問題 : 除了正則表示式之外,在字串中查詢重複模式的方法?noredirect=1&lq=1
  32. stackoverflow 問題:在字串中查詢重複模式
  33. stackoverflow 問題:在二進位制字串中查詢模式
  34. Jan Turoń 的 jsfiddle
  35. 弗吉尼亞理工大學線上 CS 模組
  36. Stackoverflow : 如何將分數轉換為二進位制?
  37. 將迴圈二進位制數轉換為十進位制(用級數表示?)
  38. 維基百科:幾何級數
  39. stackoverflow 問題:將重複的二進位制數轉換為十進位制數,用級數表示
  40. math.stackexchange 問題:給定重複的二進位制展開式,求分數
  41. Linux 中的 itoa 函式在哪裡?
  42. Stuart 編寫的 GCC 中的 itoa
  43. gcc - 二進位制常量
  44. Programowanie_w_systemie_UNIX:波蘭維基百科中的 GMP
  45. Claude Heiland-Allen 編寫的將分數轉換為數字字串
  46. stackoverflow:python 整數轉換為二進位制
  47. 每個計算機科學家都應該瞭解的浮點運算,作者 DAVID GOLDBERG
  48. wikipedia:邊界檢查
  49. stackoverflow 問題:檢查 python 中的數字是否為有理數
  50. Joe McCullough:位運算子
  51. Stackoverflow:如何在 Python 中表示二進位制字面量?
  52. John D Cook:最佳有理數逼近
  53. 發現有理數何時是無理數的最佳逼近,作者 KARI LOCK
  54. ams:最無理的數
  55. 複雜的美麗:數學日曆
  56. David Bau:複函式檢視器
  57. VBA 中的複數,作者 Pfadintegral
  58. dumpfp:用於檢查浮點數的工具,作者 Joshua Haberman
  59. 家庭學校數學:迷人的無理數
  60. stackoverflow 問題:無理數檢查函式
  61. 高度簡介,作者 Brian Lawrence
  62. sagemath:Rational.global_height
  63. 高度函式,作者 Michael Tepper
  64. 分割槽函式的分形結構。

另請參閱

[編輯 | 編輯原始碼]
華夏公益教科書