Windson’s study site
Sophomore in NCHU | Mathematics | Ubuntu 25.10 | CTF Player | AI Developer
Learning FastAPI, and x86 Assembly.
Root Finding Bisection Method By Intermediate Value Theorem (IVT). If a continuous function f(x) change sign in [a ,b], there must be at least one root in [a ,b] Algorithm right = a left = b mid = (right + left)/2 while abs(f(mid)) > tolerance and abs(left - right) > tolerance: if f(mid) == 0: return mid elif f(mid) * f(right) > 0: right = mid else: left = mid return (right+left)/2 Advantage It definitely can find a root. Error Analysis
CH1 INTRO 資料庫是多user 使用。以下是名詞定義 DBMS 資料庫管理套件(程式),負責處理資料儲存、同步、資料庫安全。 Improve data sharing, security, access Better data integration Minimized data inconsistency (資料不一致性) For decision making Improve programmers production Metadata 定義資料庫中所有表格結構、格式,表格間的關係。 SQL language 呼叫 DBMS 使用的語言,只藉由他使用資料庫。 Logical vs Physical Logical: how humans view the data Physical: how the computer work with the data Primary key vs Foreign key Primary Key (PK) :是用來「唯一識別」資料表中每一筆紀錄(資料列)的一個屬性(或一組屬性的組合)。它是由候選鍵(Candidate key)中被挑選出來作為主要識別依據的鍵。 唯一性 值不可為空 不可更改 範例: 在一個「學生(STUDENT)」資料表中,「學號(STU_NUM)」就是一個適合的主鍵,因為每個學生的學號都不一樣,且每個學生都一定會有學號。 Foreign key(FK) :存在於某個資料表中的屬性(或屬性組合),它的值必須「對應到另一個資料表的主鍵值」,或者是空值(Null)。 範例: 假設有「產品(PRODUCT)」與「供應商(VENDOR)」兩個資料表。供應商資料表的主鍵是「供應商代碼(VEND_CODE)」。若我們將 VEND_CODE 加入產品資料表中,它在產品資料表裡就是一個「外來鍵」,用來標示該產品是由哪一家現有的供應商所提供的。 CH2 Data Models 2.1 Data Models 在資料庫設計中,資料模型(Data model) 是一個用來呈現複雜現實世界資料結構的相對簡單(通常是圖形化)的表示法或抽象概念。 它的主要功能與重要性包括以下幾點: ...
CH6 6.4 Hardware Support for Synchronization 6.4.1 Memory Barriers 現在的電腦為了提升效能,有可能會做reorder instructions。重新排序在單執行緒的系統下是可以的,但在多執行緒的系統中,會造成資料不一致的問題。因此,電腦架構必須定義一組規則,來說明: 記憶體讀寫在多執行緒環境中,什麼情況下是「保證可見的」、以及哪些重新排序是允許的。 這叫做 Memory Model。 Memory model 有兩種 Strongly ordered;:在 A processor 更新的記憶體 會 上被其他的 processor 看到 Weakly ordered:在 A processor 更新的記憶體 不會 上被其他的 processor 看到 現在的 Memory 有很多種類,所以不知道會是哪一種。為了解決問題,電腦提供一些instruction可以強迫把更改的資訊傳送給所有processor,這些指令也被稱為memory barrier或是memory fence。這些指令是atomic的指令,意思就是不可分割的。具體是這樣實作: do { acquire lock; critical section; release lock; remainder section; }while(true); 6.4.2 Hardware instructions 為了使用方便,現在的電腦提供一些指令可以使用。 test_and_set bool test and set(boolean *target) { boolean rv = *target; *target = true; return rv; } do { while (test and set(&lock)); /* do nothing */ /* critical section */ lock = false; /* remainder section */ } while (true); 它是atomic。所以如果兩個同時(parallelism),他們會被以一個任意的順序執行。 可以藉由控制lock達到mutual exclusion的目的。 初始值lock = false。 compare_and_swap (CAS) int compare and swap(int *value, int expected, int new value) { int temp = *value; if (*value == expected) *value = new value; } return temp; } CAS 是一個atomic的指令,所以如果兩個同時(parallelism),他們會被以一個任意的順序執行。操作需要三個參數: ...
2-1 Integrating Factor $\mu (x)$ In general first-order linear differential equation in standard form: $$ \frac{dy}{dt} + p(t) y = g(t) $$In convenient ,we also write the equation in this form: $$ P(t)\frac{dy}{dt} + Q(t) y = G(t) $$then ,to solve this ODE, we tend to find a integrating factor $\mu (x)$ s.t. $(\mu (t) y)' = k(t)$ How to find the Integrating Factor $$ P(t) \frac{dy}{dt} + Q(t)y = G(t) $$$$ \mu (x) P(t) \frac{dy}{dt} + \mu (x) Q(t)y = \mu (t)G(t) $$$$ \mu (t) \frac{dy}{dt} + \mu (t) \frac {Q(t)}{P(t)}y = \frac {\mu (t) G(t)}{P(t)} $$$$ [\mu (t) y]' = \frac{\mu (t) G(t)}{P(t)} $$we can imply that $\mu '(t) = \frac{Q(t)}{P(t)} \mu (t)$ ,then ...
About Error Define absolute error : $|P - P^{*}|$ , if $P$ is an approximate for $P^{*}$. relative error : $\frac{|P - P^{*}|}{|P^{*}|}$, if $|P^{*}| \neq 0$ We want to find the solution of $x^{*}$ s.t. $f(x^*) = 0$ Ch2 Solution of Equation in one variable Bisection Method Necessary Condition: $f$ is a function $\in C(a ,b)$ and $f(a) f(b) < 0$ Algorithms Given $f(x), f(a), f(b)$ with tolerance $\epsilon_1$, $\epsilon_2$ ...