Sunday, April 26, 2020

Notes on E&M

Notes on E&M

Definitions

E=Fq\vec E = \frac{\vec F}{q}
ϕE=EdA\phi_E = \int \vec E \cdot d\vec A
ϕB=Bdl\phi_B = \int \vec B \cdot d\vec l
ε=LFonchargeqqdl\varepsilon = \oint_{L} \frac{\vec F_{on \, charge \, q}}{q} \cdot d\vec l
ΔV=ABEdl\Delta V = -\int^B_A \vec E \cdot d\vec l    if LEdl=0\oint_L\vec E \cdot d\vec l= 0      E\vec E created by charges

Maxwell’s Equations

Gauss’s Law

EdA=qenclosedε0\oint \vec E \cdot d \vec A = \frac{q_{enclosed}}{\varepsilon_0}     → charges make E\vec E, which is path-independent
BdA=0\oint \vec B \cdot d \vec A = 0    → there is no magnetic monopole

Ampere’s Law

Bdl=μ0I+μ0ε0dϕEdt\oint \vec B \cdot d \vec l = \mu_0I + \mu_0 \varepsilon_0 \frac{d\phi_E}{dt}    → current and changing electric fulx make B\vec B

Faraday’s Law

ε=dϕBdt\varepsilon=-\frac{d\phi_B}{dt}    → changing magnetic flux makes emf

EMF

ε=LoopFonchargeqqdl\varepsilon = \oint_{Loop} \frac{\vec F_{on \, charge \, q}}{q} \cdot d\vec l
If Fonchargeq\vec F_{on \, charge \, q} comes from:

  1. B\vec B, then
    it is a motional emf

    e.g.
    A rectangular conductor with length L is moving in a uniform magnetic field, then charges on the conductor would separate by magnetic for and creates a electric field inside the conductor. The charges would keep separating until FE=FB|F_E|=|F_B|
    FE=FBF_E=F_B
    qE=qvBqE=qvB
    E=vB\therefore E=vB
    So, by ΔV=ABEdl\Delta V = -\int^B_A \vec E \cdot d\vec l,
    Get ΔV=vBL\Delta V =vBL

  2. E\vec E, then
    it is a tranformer emf
    In which LEdl0\oint_L\vec E \cdot d\vec l \neq 0, so by the Faraday’s Law,
    LEdl=ddt(BdA)\oint_L\vec E \cdot d\vec l = -\frac{d}{dt}(\int\vec B \cdot d\vec A) changing B\vec B makes E\vec E (i.e. changing B\vec B induces I).
    E\vec E here depends on path

Yet it seems that these two types of emf are different phenomena, both of them could be concluded by Faraday’s Law (i.e. changing magnetic flux)

Why E\vec E created by charges guarantees LEdl=0\oint_L\vec E \cdot d\vec l= 0

Loop ABCD as Loop L
path A to B: Edl\vec E \parallel d\vec l   so, we have ABkq/r2dl\int^B_A kq/r^2dl on path A to B
with the same logic, we have ABkq/r2(dl)\int^B_A kq/r^2(-dl) on path C to D
On path B to C and path D to A, since Edl\vec E \bot d\vec l , integrations on those two path would be zero.
So, LEdl=ABkq/r2dl+ABkq/r2(dl)=0\oint_L\vec E \cdot d\vec l= \int^B_A kq/r^2dl + \int^B_A kq/r^2(-dl) = 0

By contrast, for E\vec E created by changing B\vec B,
since Edl\vec E \parallel d\vec l,
LEdl0\oint_L\vec E \cdot d\vec l \neq 0

Wednesday, April 22, 2020

Deriving formulas of distance, velocity and acceleration

Deriving formulas of distance, velocity and acceleration

First, we know the average velocity is
vˉ=ΔxΔt \bar{v} = \frac{\Delta x}{\Delta t}
Thus the instantaneous velocity is
v=limΔt0ΔxΔt=dxdt v=\lim_{\Delta t \to 0}\frac{\Delta x}{\Delta t} = \frac{dx}{dt}
If we calculate the derivative of the instantaneous velocity, we can get the acceleration. In other words, if we calculate the second dericaive of displacement, we also can get the acceleration.
a=dvdt=d2xdt2 a=\frac{dv}{dt}=\frac{d^2x}{dt^2}
Now we can use the formula(3) to get the formula of instantaneous velocity with component of aa, tt, and v0v_0.
v=adt=at+C v = \int a dt = at+C
The value of C in fact is v0v_0.

Let t=0,
v=C v = C
Thus,
v0=C v_0 = C
Now we got the formula of instantaneous velocity :
v=at+v0 v = at+v_0
The derivative of displacement is the instantaneous velocity, thus the indefinite integral of the instantaneous welocity is displacement.
x=vdt=(at+v0)=12at2+v0t+B x = \int v dt = \int (at+v_0) = \frac{1}{2}at^2 + v_0t + B
The calue of B in fact is x0x_0.

Let t=0
x=B x = B
Thus,
x0=B x_0 = B
So we had the formula of displacement:
x=12at2+v0t+x0 x = \frac{1}{2}at^2 + v_0t + x_0
From the formula(7), we got
t=vv0a t = \frac{v-v_0}{a}
Plugging formula(12) into the formula(11), we had:
x=12a(vv0a)2+v0vv0a+x0 x=\frac{1}{2}a(\frac{v-v_0}{a})^2+v_0\frac{v-v_0}{a}+x_0
Finally,
2a(xx0)=v2v02 2a(x-x_0) = v^2-v_0^2

Saturday, April 4, 2020

Notes on World Politics: The Menu for Choice

Chapter 7: Why States And Other Actors Resort To Force

Table of contents generated with markdown-toc

The costs of a nuclear war would be huge since both the state used them and the state be attacked could not get benefit from it.
More nuclear weapon each state have, less trust between each state.

Kenneth Waltz’s three images of war

First Image

Focus on individual-level

“The locus of the causes of war is found in the nature and behavior of
man. Wars result from selfishness, from misdirected aggressive
impulses, from stupidity.” 1

The question here is whether war is the result of human nature. Do innate genetic characteristics and physiology or the social and cultural environment account for human actions?

One extreme view is that human behaviors are the result of human biological influences.
Another view says that some behaviors are influenced by biological factors since they are needed for humans to survive.

Relative Deprivation

The feeling of relative deprivation is the reason why people act violently. This feeling can arise when a society experiences an economic setback.

A hypothesis points out that when a condition of steady improving suddenly has a sharp setback, it would be the most dangerous time for society. That is, the condition makes people have an optimistic expectation, then when this condition suddenly changed, it would cause more distress than that of unchanged condition.

Another perspective says that comparisons of people are an important factor in human behavior.

One group may be satisfied, even with a bad lot, as long as others are doing no better. But to the degree that the group finds its situation relatively poor compared to others, it is likely to be dissatisfied.2

These two perspectives can be usefully combined.

States’ Conflict

Military conflicts of states have varied in terms of severity and scope.
Severity: the extent of death and destruction involved
Scope: the number of participants involved

Reasons for Wars

  • Holsti: territorial disputes (e.g. creation of new states)
  • Economic issues
  • Ideology (e.g. religion and ethnicity)

Kenneth Waltz’s Second Image of War

“the internal organization of the state is the key to understanding war and peace.” 3

One view on the state’s internal organization is the democratic peace, that democracies are not likely to go into war with other democracies.

Another view is about the economic system- Capitalism and Socialist.

For the realist, each state has different economic systems that would not matter since states, having more or less power, should have the same goals no matter what their economic system is.

For liberalist, the economic systems would matter. That is, free trade and prosperous of the foreign markets could lead to world peace.

For Marxists and other radicals, capitalist countries are being aggressive on foreign policies. That is, capitalism could be the factor of imperialist acts.
Some radicals: the capitalist system as a whole (or at least the capitalist economy of any major power) is dependent on military spending or continued access to foreign markets for goods or investment opportunities.

Others point to the interests and powers of particular groups or classes.

Third image of Kenneth’s Waltz

“The requirements of state action are, in this view, imposed by the circumstances in which all states exit.”4

That is, the characteristics of global society could explain wars.

Especially for the distribution of power.

Some would say the bipolar system is the best system to avoid wars since neither of the states has a bigger chance to dominate the war. So, if there were wars happened within a bipolar system, it would be a high-costing war.

Conflict Within States

Failed states: “states that are internationally recognized but whose governments (if they exist) cannot provide their citizens with even the minimum level of security and well-being expected of sovereign states.”( World Politics the menu of choice p.175)

Conflict within states could be destructive and may extend the conflict to another state as well. Example: French Revolution.

The lack of democracy could promote civil war. “Especially for wars that stem from ethnic or religious conflicts, a group’s lack of democratic rights can threaten the core of its ethnic identity and reduce the possibility of overdressing its grievances.”

But it doesn’t mean greater democracy will have a lower risk of civil war since those wars could be suppressed by overwhelming force if the state can do that.

Ethnic Conflict

“Although we commonly refer to entities in the international system as
nation-states, there are in fact many multinational states and
multistate nations.”5

it may lead to the ethnopolitical conflict (also known as communal conflict): X.

Deprivation, unequal distribution of economic and political rewards could be the reasons for civil war. another reason could be external assistance, presence of lootable resources.

Unconventional Conflict: a conflict which does not involve military operations on the battlefield

e.g. Guerrilla warfare

Global Terrorism

“The principal purpose of terrorism is not the destruction produced by the attack, but its stunning psychological effects on populations and governments.”(184)

Forms of Terrorism

  • establishment terrorism

  • state terrorism

  • state-sponsored terrorism

Chapter 8

Armed Forces

Why states need arm?

One simple explanation is that state arms itself since other states arm as well.

“very strong motive of fear, which moves each group to increase its armaments because of the existence of those of the opposing group.” 6

So, when both states are arming themselves, the arms race happened.

Another explanation is about the domestic influences. That is, the government’s budget is related to military organizations. So, there would have strong resistance when their budget needs reallocation. To respond to it that resistance, some would maintain that military-industrial complexes are needed.

Gun or Butter

The state’s economy has to transfer to a wartime economy from a peacetime economy when they get into a war. Sometimes the priority of the war preparation is even higher than that of economic activities. These relationships between military and economic are expressed as “guns versus butter”7. It will bring up two issues:

  1. “is there a connection between peacetime defense activities, especially military spending, and the overall economic heal of the nation or regions within it?”7
  2. "does production by the military-industrial complex (guns) absorb resources that might otherwise go to social programs (butter) designed to improve a lot of society’s poor and dispossessed? "7

Radicals: a politician is using the spending of the military as a fiscal stimulus during periods of slow growth.
Liberals: too large spending on the military would have a negative influence on a nation’s overall economic health.
Peacetime military preparedness could have economic effects on the local economy as well.

Mass Destructive Weapon

Weapons of Mass Destruction (WMD) aka Nuclear Weapons
National missile defense (NMD)

The Strategic Nuclear Age

First-strike capability: attacking other states and limit their ability to retaliate.
In contrast to MAD, there is minimum deterrence, similar to other nuclear powers, which required only a second-strike capability and also costs relatively small when no other states are practicing it.

Weapons proliferation

“Second nuclear age” refers to the proliferation of nuclear weapons.

Weapons other than nuclear weapons

chemical weapons
biological weapons

Security Dilemma


  1. Kenneth Waltz, Man, the State, and War: A theoretical Analysis (New York: Columbia University Press, 1959), p.16. ↩︎

  2. Kinsella, D., Russett, B. M., & Starr, H. (2013). World politics: the menu for choice. Boston, MA, etc.: Wadsworth Cengage Learning, p.163 ↩︎

  3. Kenneth Waltz, Man, the State, and War: A theoretical Analysis (New York: Columbia University Press, 1959), p.81 ↩︎

  4. Kenneth Waltz, Man, the State, and War: A theoretical Analysis (New York: Columbia University Press, 1959), p.160 ↩︎

  5. Kinsella, D., Russett, B. M., & Starr, H. (2013). World politics: the menu for choice. Boston, MA, etc.: Wadsworth Cengage Learning,p.178 ↩︎

  6. Lewis F. Richardson, Arms and Insecurity: A Mathematical Study of the Causes and Origins of War (Pittsburgh: Boxwood Press, 1960), p.13. ↩︎

  7. Kinsella, D., Russett, B. M., & Starr, H. (2013). World politics: the menu for choice. Boston, MA etc.: Wadsworth Cengage Learning, p.195 ↩︎ ↩︎ ↩︎

Monday, February 17, 2020

Mathematica Notes: Input & Define a Function

Input

ac\frac{a}{c}
Press [Ctrl]+[/]
xax^a
Press [Ctrl]+[^]
x\sqrt{x}
Press [Ctrl]+[@]

Define a function

f(x)=x2+x+1 f(x)=x^2+x+1

Input:
f[x_] := x^2 + x + 1
f[1]
Output:
3

What difference between f[x_]:= and f[x_]= ?

:= means delayed assignment, the value will recompute everytime it needed.
= means assign value immediately
** =. means clear assignment

What difference between f[x_] and f[x] ?

input:
f[x_] := x^2 + x + 1
f[1]
g[y] := x^2 + x + 1
g[1]

output:
3
g[1]

Monday, August 13, 2018

【自動化】AppleScript 學習筆記

【自動化】AppleScript 學習筆記

輸出

簡單輸出

Code:

"Hello~"

Output:

Result:
"Hello"

log

Code:

log "Hello"

log 輸出的內容可在Messages Tab, Events Tab 或 Replies Tab中查看;Result Tab只會留存最後指定輸出的字串

Output:

(*Hello~*)

簡單輸出的方法只會留存最後指定輸出的字串,而log 則不會有這樣的問題

變量

set

Code:

set num to 10

log num

Output:

(*10*)

控制

tell

Code:

tell application "Finder" --指定Finder
	-- code here
end tell

display dialog

顯示對話框

Code:

display dialog "Hi"

Output:
img

say

播放語音

Code:

say "Hello"

if

Code:

set num to 100
if num > 99 then
	display dialog "Hi"
end if

Output:

img

if…else

set num to 10
if num > 99 then
	return "Hello"
else
	return "Bye"
end if

Output:
return 的內容顯示於Result tab

"Hello"

repeat

Code:
loop 10次

set num to 0
repeat until num = 10
	set num to (num + 1)
	log num
end repeat

Output:

(*1*)
(*2*)
(*3*)
(*4*)
(*5*)
(*6*)
(*7*)
(*8*)
(*9*)
(*10*)

do script

Code:
打開Terminal 並於Desktop建立Folder—FolderName: abcd

Terminal 指令:

cd ~/Desktop
mkdir abcd

Code:

’ & '用於連接字符串

tell application "Terminal"
	do script "cd ~/Desktop; " & "mkdir abcd"
end tell

activate

將應用程序啟動並置於最前
Code:

tell application "Terminal"
	activate
end tell

launch

如果應用程序未啟動,則啟動它,但不發送命令

Code:

tell application "Terminal"
	launch
end tell

delay

Code:

display dialog 1 buttons {"Next is dialog 2"} --設定button內容
delay 2 --等待2秒
display dialog "I'm dialog 2"

Output:

Delay 1

按下 ’Next is dialog 2’後

等待2 秒

Delay 2

quit

退出應用程式

Code:
打開Terminal 並放置到最前
輸入date 指令
等待 5秒
退出應用程式

tell application "Terminal"
	activate
	do script "date"
	delay 5
	quit
end tell

輸入

User Input

Code:

set myans to display dialog "1 + 1 = ?" default answer ""
set ans to text returned of myans
if ans = "2" then --從dialog取得的ans為字符串
	return "Right"
else
	return "Wrong"
end if

Output:

userInput1

輸入正確答案
Result:
"Right"
輸入錯誤答案
Result:
"Wrong"

注釋

AppleScript中注釋方法有兩種

--我是單行注釋
(*我
 是
 多
 行
 注
 釋*)

Reference

http://applescript.wikia.com/wiki/Wiki
https://developer.apple.com/library/archive/documentation/AppleScript/
http://downloads.techbarrack.com/books/programming/AppleScript/website/

Installing xAct (Mac)

Download from http : www.xact.es . Before unpack the tar/tgz file, remove attributes with xattr -c xAct_1.x.x.tgz then place the un...