跳转到内容

模組:Complex Number/Calculate/doc.lua

本页使用了标题或全文手工转换
维基百科,自由的百科全书

local p={}
local getArgs = require('Module:Arguments').getArgs
local ext_mathlib = require("Module:Complex Number/Functions")._init
local baselib = require("Module:Complex Number")
local lib_calc = require('Module:Complex_Number/Calculate')
p.symbolType = {
	arithmetic = {
		name="基礎算术",
		page="算术",
		operators={" ","-","*","×","/","÷","%","^","e ","()"},
		functions={"div","dot","pow"},
	},
	elementary_function = {
		name="初等函<span></span>數",
		page="初等函數",
		operators={},
		functions={"abs","log","log ","sgn","sqrt","inverse","exp"},
	},
	special_function = {
		name="特殊函<span></span>數",
		page="特殊函數",
		operators={},
		functions={"binomial","factorial","gamma","LambertW"},
	},
	number_theory = {
		name="数论",
		page="数论",
		operators={"  ","- ","%"},
		functions={"gcd","lcm","digits","divisor","primedivisor","divisorsigma","eulerphi","findnext","findlast"},
	},
	algebra = {
		name="代数",
		page="代数",
		operators={"⋅","←","↦",":",","},
		functions={"norm","summation","product","<不定>","ele"},
	},
	calculus = {
		name="微積分",
		page="微积分学",
		operators={},
		functions={"limit","diff","integral"},
	},
	trigonometric = {
		name="三角函<span></span>数",
		page="三角函数",
		operators={"°","π"},
		functions={"sin","cos","tan","cot","sec","csc",
			"asin","acos","atan","acot","asec","acsc",
			"sinh","cosh","tanh","coth","sech","csch",
			"asinh","acosh","atanh","acoth","asech","acsch",
			"cis","gd","arcgd","cogd"
		},
	},
	statistics = {
		name="統計",
		page="統計",
		operators={},
		functions={"average","geoaverage","maximum","minimum","selectlist","σ"},
	},
	complex_analysis = {
		name="複變",
		page="複分析",
		operators={"* ","i"},
		functions={"re","im","nonRealPart","scalarPartQuaternion","vectorPartQuaternion","arg","cis","conjugate"},
	},
	rounding = {
		name="数值修约",
		page="数值修约",
		operators={"round "},
		functions={"floor","ceil","round","trunc"},
	},
	binary_relation = {
		name="二元关系",
		page="二元关系",
		operators={">","<","≥","≤","=","≠"},
		functions={},
	},
	boolean_algebra = {
		name="布尔代数",
		page="布尔代数",
		operators={"&","↑","|","↓","⊕","⇔","~ ","and","nand","or","nor","xor","xnor","not"},
		functions={},
	},
	technical = {
		name="技術性",
		operators={";","return"},
		functions={"hide","exprs","lastexpr","equalexpr","call","<functionName>AtModule<ModulePageName>","range","if","iff","ifelse","ifelsef","random","randomseed"},
	},
	constant = {
		name="常数",
		page="常数",
		operators={},
		functions={},
		values={1,0,-1,'e','i','j','k','nan','nil','°','π','ω'},
	}
}
p.other_data_table = {
	['°']={name="角度單位",title="度 (角)",othername={},value="°",priority=10,
		example="180°",description="用於表示角度單位的符號。", count = 1, calcmode="cmath"},
	['π']={name="圓周率",title="度 (角)",othername={"pi"},value="π",priority=10,
		example="3π",description="表示圓周率。", count = 1, calcmode="cmath"},
	['ω']={name="艾森斯坦整数單位",title="艾森斯坦整数",othername={},value="(2⋅ω)/2",nomath=true,
		example="3⋅ω",description="表達艾森斯坦整数單位。", count = 1, calcmode="cmath"},
	["()"] = {name="括弧",title="括号",othername={},priority="∞",
		example="2*(2 3)",description="改變運算優先順序", count = 1, calcmode="cmath"},
	abs = {name="絕對值",title="绝对值",othername={},
		example="abs(-3)",description="計算一數與原點的歐幾里得距離", count = 1, calcmode="cmath"},
	['and'] = {name="邏輯且",title="逻辑与",othername={},priority=5,
		example="(1=1) and (1=2)",description="邏輯且的字母模式。使用時須與前後文各間隔至少一個空格", count = 2, calcmode="cmath"},
	acos = {name="反餘弦",title="反餘弦",othername={},
		example="acos(1)",description="計算一數的反餘弦值", count = 1, calcmode="cmath"},
	acosh = {name="雙曲反餘弦",title="双曲函数",othername={},
		example="acosh(1)",description="計算一數的雙曲反餘弦值", count = 1, calcmode="cmath"},
	acot = {name="反餘切",title="反餘切",othername={},
		example="acot(1)",description="計算一數的反餘切值", count = 1, calcmode="cmath"},
	acoth = {name="雙曲反餘切",title="双曲函数",othername={},
		example="acoth(1.5)",description="計算一數的雙曲反餘切值", count = 1, calcmode="cmath"},
	acsc = {name="反餘割",title="反餘割",othername={},
		example="acsc(1)",description="計算一數的反餘割值", count = 1, calcmode="cmath"},
	acsch = {name="雙曲反餘割",title="双曲函数",othername={},
		example="acsch(1)",description="計算一數的雙曲反餘割值", count = 1, calcmode="cmath"},
	arcgd = {name="反古德曼函<span></span>數",title="古德曼函數",othername={},
		example="arcgd(1)",description="計算一數的反古德曼函<span></span>數值", count = 1, calcmode="cmath"},
	arg = {name="輻角",title="辐角",othername={},
		example="arg(3 7i)",description="計算一複數的輻角", count = 1, calcmode="cmath"},
	asec = {name="反正割",title="反正割",othername={},
		example="asec(1)",description="計算一數的反正割值", count = 1, calcmode="cmath"},
	asech = {name="雙曲反正割",title="双曲函数",othername={},
		example="asech(1)",description="計算一數的雙曲反正割值", count = 1, calcmode="cmath"},
	asin = {name="反正弦",title="反正弦",othername={},
		example="asin(1)",description="計算一數的反正弦值", count = 1, calcmode="cmath"},
	asinh = {name="雙曲反正弦",title="双曲函数",othername={},
		example="asinh(1)",description="計算一數的雙曲反正弦值", count = 1, calcmode="cmath"},
	atan = {name="反正切",title="反正切",othername={},
		example="atan(1)",description="計算一數的反正切值", count = 1, calcmode="cmath"},
	atanh = {name="雙曲反正切",title="双曲函数",othername={},
		example="atanh(0.5)",description="計算一數的雙曲反正切值", count = 1, calcmode="cmath"},
	average = {name="平均數",title="算术平均数",othername={},
		example="average(7,3,2,1)",description="計算數組的算術平均數。", count = "不定", calcmode="cmath"},
	binomial = {name="二項式係數",title="二項式係數",othername={},
		example="binomial(7,3)",description="計算二項式係數。亦可以被理解為從n個相異元素中取出k個元素的方法數。", count = 2, calcmode="cmath"},
	call = {name="呼叫函<span></span>數",othername={},
		example="call((:x,y↦sin(x) cos(y);),π,0)",description="呼叫一個函數。用於處理匿名函數或返回值是函數的情況。", count = "不定", calcmode="cmath"},
	ceil = {name="天花板函<span></span>數",title="取整函数",othername={},
		example="ceil(7.3)",description="向上取整", count = 1, calcmode="cmath"},
	cis = {name="純虛指數函<span></span>數",title="Cis函數",othername={},
		example="cis(π)",description="計算一數的純虛指數函<span></span>數值", count = 1, calcmode="cmath"},
	cogd = {name="餘古德曼函<span></span>數",title="古德曼函數",othername={},
		example="cogd(π)",description="計算一數的餘古德曼函<span></span>數值", count = 1, calcmode="cmath"},
	conjugate = {name="共軛複數",title="共轭复数",othername={},
		example="conjugate(7 3i)",description="", count = 1, calcmode="cmath"},
	cos = {name="餘弦",title="餘弦",othername={},
		example="cos(π)",description="計算一數的餘弦值", count = 1, calcmode="cmath"},
	cosh = {name="雙曲餘弦",title="双曲函数",othername={},
		example="cosh(π)",description="計算一數的雙曲餘弦值", count = 1, calcmode="cmath"},
	cot = {name="餘切",title="餘切",othername={},
		example="cot(div(π,2))",description="計算一數的餘切值", count = 1, calcmode="cmath"},
	coth = {name="雙曲餘切",title="双曲函数",othername={},
		example="coth(π)",description="計算一數的雙曲餘切值", count = 1, calcmode="cmath"},
	csc = {name="餘割",title="餘割",othername={},
		example="csc(div(π,2))",description="計算一數的餘割值", count = 1, calcmode="cmath"},
	csch = {name="雙曲餘割",title="双曲函数",othername={},
		example="csch(π)",description="計算一數的雙曲餘割值", count = 1, calcmode="cmath"},
	diff = {name="導數",title="导数",othername={},
		example="diff(cos,div(2⋅pi,3))",description="計算一函<span></span>數在x=x₀的導數。需注意此運算為估計,運算精度約僅有7位有效數字。"..
		"第一參數為欲求導數x=x₀的函<span></span>數;第二參數為x₀。", 
		count = 2, calcmode="cmath"},
	digits = {name="位數",title="数位_(数学)",othername={},nomath=true,
		example="digits(7321)",description="取得整數的位數個數", count = 1, calcmode="cmath"},
	divisor = {name="因數",title="因數",othername={},nomath=true,
		example="divisor(6,1),divisor(6,2),divisor(6,3),divisor(6,4)",description="取得某數的第n個正因數", count = 2, calcmode="cmath"},
	divisorsigma = {name="除數函<span></span>數",title="除數函數",othername={},
		example="divisorsigma(1,6)",description="計算特定整數的除數函<span></span>數", count = 2, calcmode="cmath"},
	div = {name="分數",title="分數",othername={},
		example="div(7,3)",description="用於在math輸出時,以分數的形式顯示", count = 2, calcmode="cmath"},
	dot = {name="內積",title="点积",othername={},
		example="dot(7,3)",description="計算兩數的內積。", count = 2, calcmode="cmath"},
	e={name="自然底數",title="E_(数学常数)",othername={},value="e",
		example="3⋅e",description="自然對數函<span></span>數的底數", count = 1, calcmode="cmath"},
	["e "] = {name="科學記號",title="科学记数法",othername={},priority="∞",
		example="12.3e4",description="當e左鄰一實數、右鄰一整數時,則為科學記號,以<code>256e-3</code>為例,其代表的結果為<math>256\\times 10^{-3}</math>。要注意的是左邊的數必為單一實數、右邊的數必為整數,可為負數,且中間不能有空格。", count = 2, calcmode="cmath"},
	eisenstein = {name="艾森斯坦整數",title="艾森斯坦整数",othername={},
		example="(7 3⋅ω)",description="", count = 1, calcmode="cmath"},
	elog = {name="自然對數",title="自然對數",othername={},
		example="elog(e)",description="", count = 1, calcmode="cmath"},
	ele = {name="代數單位元",title="單位元",othername={},
		example="ele(2)",description="取得特定代數空間(如四元數)的第n個單位元,如ele(2)即e₂=j", count = 1, calcmode="qmath"},
	equalexpr = {name="連續等式",othername={},
		example="equalexpr(2 2,2*2)",description="生成連續等式。", count = "不定", calcmode="cmath"},
	eulerphi = {name="歐拉函<span></span>數",title="欧拉函数",othername={},
		example="eulerphi(8)",description="取得小於等於n的正整數中與n互質的數的數目", count = 1, calcmode="qmath"},
	exp = {name="自然指數",title="指数函数",othername={},
		example="exp(π⋅i)",description="", count = 1, calcmode="cmath"},
	exprs = {name="一系列運算式",othername={},
		example="exprs(y←5,x←7,x⋅y),5",description="在math模式時顯示所有運算式,運算結果為最後一則運算式。可作為連續運算式的表達,所有已輸入的運算式皆會計算。", count = "不定", calcmode="cmath"},
	factorial = {name="階乘",title="階乘",othername={},
		example="factorial(7)",description="計算一數的階乘", count = 1, calcmode="cmath"},
	findlast = {name="向前尋找",othername={},nomath=true,
		example="findlast(:x↦x % 6 = 0;,10)",description="尋找前一個符合條件的整數", count = 2, calcmode="cmath"},
	findnext = {name="向後尋找",othername={},nomath=true,
		example="findnext(:x↦x % 6 = 0;,6)",description="尋找下一個符合條件的整數", count = 2, calcmode="cmath"},
	floor = {name="地板函<span></span>數",title="取整函数",othername={},
		example="floor(7.3)",description="向下取整", count = 1, calcmode="cmath"},
	gamma = {name="伽瑪函<span></span>數", title="Γ函数",othername={},
		example="gamma(7)",description="計算一數的Γ函数", count = 1, calcmode="cmath"},
	gcd = {name="最大公因數",title="最大公因數",othername={},
		example="gcd(7,21)",description="計算多個數的最大公因數。", count = "不定", calcmode="cmath"},
	gd = {name="古德曼函<span></span>數",title="古德曼函數",othername={},
		example="gd(e)",description="計算一數的古德曼函<span></span>數值", count = 1, calcmode="cmath"},
	geoaverage = {name="幾何平均數",title="几何平均数",othername={},nomath=true,
		example="geoaverage(7,3,2,1)",description="計算數組的幾何平均數", count = "不定", calcmode="cmath"},
	hide = {name="隱藏運算式",othername={},
		example="hide(y←5,x←7,x⋅y),5",description="在math模式下隱藏指定運算式。本函數的結果為最後一個參數。可作為連續運算式的表達,所有已輸入的運算式皆會計算,但結果會隱藏。亦可用於自訂函數中的多運算式表達。", count = "不定", calcmode="cmath"},
	i={name="虛數單位",title="虛數單位",othername={},value="i",
		example="3i",description="表達純虛數", count = 1, calcmode="cmath",priority="∞"},
	['if'] = {name="條件運算式",title="條件運算式",othername={},
		example="if(3>2,1,0)",description="指定特定條件下時的運算式。第一參數為條件、第二參數為條件為真時的運算式、第三參數為條件為假時的運算式。", count = 3, calcmode="cmath"},
	ifelse = {name="條件運算式 if...else",othername={},
		example="ifelse(3>2,10,3<2,20,30)",description="類似if,用法為ifelse(條件1, 條件1為真的結果, 條件2, 條件2為真的結果, ... , 條件n, 條件n為真的結果, 條件皆為假的結果)", count = "不定", calcmode="cmath"},
	ifelsef = {name="函數型條件運算式 if...else",othername={},
		example="ifelsef(3>2,:nil↦10;,3<2,:nil↦20;,:nil↦30;)",description="同ifelse,不過參數可以是函數,條件成立時才會呼叫。", count = "不定", calcmode="cmath"},
	iff = {name="函數型條件運算式",othername={},
		example="iff(3>2,:nil↦1;,:nil↦2;)",description="同if,不過參數可以是函數,條件成立時才會呼叫。", count = 3, calcmode="cmath"},
	im = {name="虛數部分",title="虚数",othername={},
		example="im(7 3i)",description="取得一數的虛數部分", count = 1, calcmode="cmath"},
	integral = {name="定積分",title="积分",othername={},
		example="integral(0,π,:x↦sin(x);)",description="計算一函<span></span>數在從a到b的定積分<math>\\int_a^b f(x)\\,dx </math>。需注意此運算為估計,運算精度約僅有7位有效數字,且積分範圍(a和b的距離)越大,精確度會越低。"..
		"第一參數為a、第一參數為b、第三參數為欲求定積分的函<span></span>數、第四參數為取樣數,若未填寫則使用預設值2000。", 
		count = 4, calcmode="cmath"},
	inverse = {name="倒數",title="倒数",othername={},
		example="inverse(7)",description="", count = 1, calcmode="cmath"},
	j={name="四元數單位j",title="四元數",othername={},value="j",
		example="3j",description="表達純四元數虛數j", count = 1, calcmode="qmath"},
	k={name="四元數單位k",title="四元數",othername={},value="k",
		example="3k",description="表達純四元數虛數k", count = 1, calcmode="qmath"},
	LambertW={name="朗伯W函数",title="朗伯W函数",othername={},
		example="LambertW(1)",description="計算一數的朗伯W函数", count = 2, calcmode="cmath"},
	lastexpr = {name="最後一則運算式",othername={},
		example="lastexpr(y←5,x←7,x⋅y),5",description="在math模式時顯示最後一則運算式,運算結果也為最後一則運算式。可作為連續運算式的表達,所有已輸入的運算式皆會計算。", count = "不定", calcmode="cmath"},
	lcm = {name="最小公倍數",title="最小公倍數",othername={},
		example="lcm(7,3,21)",description="計算多個數的最小公倍數。", count = "不定", calcmode="cmath"},
	limit = {name="極限",title="函數極限",othername={},
		example="limit(0,1,:x↦div(x,x);)",description="計算一函<span></span>數在x=x₀的極限。需注意此運算為估計,運算精度約僅有7位有效數字。第一參數為x₀;"..
		"第二參數為逼近方向,1表示右極限、-1表示左極限、0表示一般的極限,此時若極限不存在則返回nan;第三參數為欲求極限的函<span></span>數。", 
		count = 3, calcmode="cmath"},
	log = {name="自然對數",title="自然對數",othername={},
		example="log(e)",description="", count = 1, calcmode="cmath"},
	["log "] = {name="指定底數的對數",title="对数",othername={},
		example="log(2,16)",description="", count = 2, calcmode="cmath"},
	maximum = {name="最大值",title="极值",othername={},
		example="maximum(7,3,2,1)",description="計算數組的最大值", count = "不定", calcmode="cmath"},
	minimum = {name="最小值",title="极值",othername={},
		example="minimum(7,3,2,1)",description="計算數組的最小值", count = "不定", calcmode="cmath"},
	nan={name="非數",title="NaN",othername={},value="nan",
		example="nan",description="用於表示數學上未定義的數值,或計算發生錯誤的數值。", count = 1, calcmode="cmath"},
	nand = {name="邏輯與非",title="谢费尔竖线",othername={},priority=5,
		example="(1=1) nand (1=2)",description="邏輯與非的字母模式。使用時須與前後文各間隔至少一個空格", count = 2, calcmode="cmath"},
	norm = {name="範數",title="范数",othername={},
		example="norm(3 4i,2)",description="計算一數或向量的範數", count = 2, calcmode="cmath"},
	['nil']={name="空值",othername={"null"},value="nil",
		example="nil",description="空值。在math模式下顯示為空白,用於表達或傳遞無參數的函數之參數。請注意,由於此值為空值,因此請勿將此值參與運算,以免發生錯誤。", count = 1, calcmode="cmath"},
	nonRealPart = {name="非實數部分",title="四元數#四元數運算",othername={},nomath=true,
		example="nonRealPart(7 3i 2j k)",description="取得一數的非實數部分", count = 1, calcmode="qmath"},
	nor = {name="邏輯或非",title="逻辑或非",othername={},priority=4,
		example="(1=1) nor (1=2)",description="邏輯或非的字母模式。使用時須與前後文各間隔至少一個空格", count = 2, calcmode="cmath"},
	['not'] = {name="邏輯非",title="逻辑非",othername={},priority=13,
		example="not (1=2)",description="邏輯非的字母模式。使用時須與前後文各間隔至少一個空格", count = 1, calcmode="cmath"},
	['or'] = {name="邏輯或",title="逻辑或",othername={},priority=4,
		example="(1=1) or (1=2)",description="邏輯或的字母模式。使用時須與前後文各間隔至少一個空格", count = 2, calcmode="cmath"},
	pow = {name="指數",title="冪",othername={},
		example="pow(7,3)",description="計算兩數之冪運算", count = 2, calcmode="cmath"},
	primedivisor = {name="質因數",title="質因數",othername={},nomath=true,
		example="primedivisor(210,1),primedivisor(210,2),primedivisor(210,3),primedivisor(210,4)",description="取得某數的第n個質因數", count = 2, calcmode="cmath"},
	product = {name="求積符號",title="求積符號",othername={},
		example="product(1,5,:it↦it;)",description="計算以函<span></span>數表達之數列的連乘積。第一參數為數列首項;"..
		"第二參數為數列末項;第三參數為用以表達數列的函<span></span>數", 
		count = 3, calcmode="cmath"},
	random = {name="隨機數",title="随机数",othername={},nomath=true,
		example="random(1,10)",description="取一個隨機數。若無指定參數,或參數中包含非數([[NaN]]),則取0-1之間的隨機實數;若指定了參數1,則取1到參數1之間的隨機數;若指定了參數1與參數2,則取參數1到參數2之間的隨機數", count = 2, calcmode="cmath"},
	randomseed = {name="設定隨機種子碼",othername={},nomath=true,
		example="randomseed(10)",description="將隨機數的種子碼設定為輸入的參數,並返回實際設定的種子碼。若輸入的參數非實數則用當前時間隨機產生種子碼。", count = 1, calcmode="cmath"},
	range = {name="指定範圍",othername={},nomath=true,
		example="range(7,1,5),range(4,1,5)",description="指定一範圍,當一數落在該範圍外則視為非數([[NaN]])。第一參數為要判定的數,第二和第三參數分別為範圍的最小和最大值。", count = 3, calcmode="cmath"},
	re = {name="實數部分",title="虚数",othername={},
		example="re(7 3i)",description="取得一數的實數部分。", count = 1, calcmode="cmath"},
	['return'] = {name="返回值",title="Return語句",othername={},priority=2,
		example="return 7;8",description="返回數值。需注意return後方必須跟著一個數值或表達式,否則會變成[[未定義行為]]而出現預期外的結果。", count = 1, calcmode="cmath"},
	['round '] = {name="数值修约",title="数值修约",othername={},priority=8,
		example="π round 6",description="round 的運算子模式,會將一數四捨五入到指定的位數。使用時須與前後文各間隔至少一個空格", count = 2, calcmode="cmath"},
	round = {name="数值修约",title="数值修约",othername={},
		example="round(π,6)",description="對一數進行四捨五入。第一參數為欲四捨五入的數字;第二參數為欲四捨五入的位數;第三參數為當數值修約底數非十進制時的底數。", count = 3, calcmode="cmath"},
	scalarPartQuaternion = {name="純量部分",title="四元數#四元數運算",othername={},
		example="scalarPartQuaternion(7 3i 2j k)",description="取得四元數的純量部分", count = 1, calcmode="qmath"},
	sec = {name="正割",title="正割",othername={},
		example="sec(π)",description="計算一數的正割值", count = 1, calcmode="cmath"},
	sech = {name="雙曲正割",title="双曲函数",othername={},
		example="sech(π)",description="計算一數的雙曲正割值", count = 1, calcmode="cmath"},
	selectlist = {name="數組元素",title="数组",othername={},nomath=true,
		example="selectlist(2,7,3,2,1)",description="輸出數組中指定位置的元素。第一參數為要輸出的元素序號,第二參數之後為數組", count = "不定", calcmode="cmath"},
	sgn = {name="符號函<span></span>數",title="符号函数",othername={},
		example="sgn(-7)",description="", count = 1, calcmode="cmath"},
	sin = {name="正弦",title="正弦",othername={},
		example="sin(π)",description="計算一數的正弦值", count = 1, calcmode="cmath"},
	sinh = {name="雙曲正弦",title="双曲函数",othername={},
		example="sinh(π)",description="計算一數的雙曲正弦值", count = 1, calcmode="cmath"},
	sqrt = {name="平方根",title="平方根",othername={},
		example="sqrt(16)",description="計算一數的主平方根值", count = 1, calcmode="cmath"},
	summation = {name="求和符号",title="求和符号",othername={},
		example="summation(1,5,:x↦x^2;)",description="計算以函<span></span>數表達之數列的總和。第一參數為數列首項;"..
		"第二參數為數列末項;第三參數為用以表達數列的函<span></span>數", 
		count = 3, calcmode="cmath"},
	tan = {name="正切",title="正切",othername={},
		example="tan(π)",description="計算一數的正切值", count = 1, calcmode="cmath"},
	tanh = {name="雙曲正切",title="双曲函数",othername={},
		example="tanh(π)",description="計算一數的雙曲正切值", count = 1, calcmode="cmath"},
	trunc = {name="截尾函<span></span>數",title="截尾函數",othername={},
		example="trunc(π,6)",description="對一數取截尾函<span></span>數。第一參數為欲截尾的數字;第二參數為欲截尾的位數。", count = 2, calcmode="cmath"},
	vectorPartQuaternion = {name="四元數向量部分",title="四元數#四元數運算",othername={},
		example="vectorPartQuaternion(7 3i 2j k)",description="取得四元數的向量部分", count = 1, calcmode="qmath"},
	xnor = {name="邏輯若且唯若",title="当且仅当",othername={},priority=4,
		example="(1=1) xnor (1=2)",description="邏輯若且唯若的字母模式。使用時須與前後文各間隔至少一個空格", count = 2, calcmode="cmath"},
	xor = {name="邏輯異或",title="逻辑异或",othername={},priority=4,
		example="(1=1) xor (1=2)",description="邏輯異或的字母模式。使用時須與前後文各間隔至少一個空格", count = 2, calcmode="cmath"},
	["σ"] = {name="標準差",title="標準差",othername={},nomath=true,
		example="σ(7,3,2,1)",description="計算數組的標準差", count = "不定", calcmode="cmath"},
	["<functionName>AtModule<ModulePageName>"] = {name="调用其他模块",title="WP:Lua",othername={},nomath=true,
		example="getAtomicWeightAtModuleElement(10)",description="调用其他模块的函数。須注意函數名稱必須是純英文、模組名稱也必須是純英文,不能有空格或其他符號。例如若需要呼叫[[Module:Element]]中的<code>getAtomicWeight</code>函數,則須表示為<code>getAtomicWeightAtModuleElement</code>。", count = "不定", calcmode="cmath"},
	["<不定>"] = {name="自行定義函<span></span>數",title="函数",othername={},
		example="f:x↦x^2;,f(5)", description="调用自行定义的函<span></span>数,這些函<span></span>數通常是<math>\\mathbb{C}^n\\mapsto\\mathbb{C}</math>或<math>\\mathbb{R}^n\\mapsto\\mathbb{R}</math>。以<code>f:x↦x^2;;f(5)</code>為例,其中<code>f:x↦x^2;</code>定義了函<span></span>數<math>f(x)=x^2</math>,並调用了函<span></span>数<math>f</math>。函<span></span>數的語法為以名稱起始並以冒號區隔函<span></span>數名稱與定義(函<span></span>數名稱可留空,但冒號不能省去),整個語法要以分號(<code>;</code>)結尾。位於映射符號(<code>↦</code>)前方為函<span></span>數的變數或參數,後方為函<span></span>數主體定義。函<span></span>數可以有多個變數,但僅能有單個輸出;同時函<span></span>數語法不建議使用嵌套結構,即不建議將函<span></span>數定義內包含另一個函<span></span>數的定義,但可以分開定義再行組合;此外,函數定義內不能包含分號,因為分號會被視為函數結尾。", count = "不定", calcmode="cmath"},
}
function p.usageDoc(frame)
	return frame:preprocess( [[
{| class=wikitable
!項目
!語法
!說明
!範例
|-
!數字的表達
|
;實數
:<code>{{Background color|#ffdfc4| 或-}}{{Background color|#c1debf|實數值}}</code>、
;科學記號
:{{nowrap|<code>{{Background color|#ffdfc4| 或-}}{{Background color|#c1debf|實數值}}{{Background color|#cddae3|e}}{{Background color|#ffdfc4| 或-}}{{Background color|#edf6fd|科學記號值}}</code>}}、
;含單位的數
:<code>{{Background color|#ffdfc4| 或-}}{{Background color|#c1debf|實數值}}{{Background color|#edf6fd|單位}}</code>或
;含常數單位
:{{nowrap|<code>{{Background color|#c1debf|任何數值表達式}}{{0|&ensp;}}{{Background color|#cddae3|{{0|&ensp;}}⋅{{0|&ensp;}}}}{{0|&ensp;}}{{Background color|#ffdfc4|常數或單位的表達式}}</code>}}
|數字的表達可分為{{Link|實數}}表達、{{Link|科學記號}}和含單位的數。
*實數表達即一般的實數;
*科學記號為一實數緊接著一個{{nowrap|<code>{{Background color|#cddae3|{{0|&ensp;}}e{{0|&ensp;}}}}</code>}}和一個整數,例如{{nowrap|<code>{{Background color|#c1debf|實數值}}{{Background color|#cddae3|e}}{{Background color|#ffdfc4|整數值}}</code>}}則代表{{nowrap|<code>{{Background color|#c1debf|實數值}}×10<sup>{{Background color|#ffdfc4|整數值}}</sup></code>}};
*另一個表達方式為一個實數值緊接著一個複變單位或角度單位,例如<code>2i</code>表示兩倍的虛數單位。此表達式不能與科學記號一同使用。能使用的單位包括<code>i</code>、<code>j</code>、<code>k</code>、<code>°</code>和<code>π</code>。其餘需使用{{nowrap|<code>{{Background color|#cddae3|{{0|&ensp;}}⋅{{0|&ensp;}}}}</code>}}運算子來表達。
|<span style="font-size:0.9em">
*<code> 2.735</code>→{{計算| 2.735}}
*<code>-2735e-3</code>→{{計算|-2735e-3}}
*<code>2.735i</code>→{{計算|2.735i}}
*<code>-180°</code>→{{nowrap|{{計算|-180°}}}}</span>
|-
!四則運算與冪運算
|<code>{{Background color|#ffdfc4|運算式}}{{0|&ensp;}}{{Background color|#cddae3|運算符}}{{0|&ensp;}}{{Background color|#ffdfc4|運算式}}</code>
|依序以{{link|中綴表示法}}表達{{AnyLink|表達式|運算式}}即可。
|<code>2 3*5^2</code>→{{計算|2 3*5^2}}
|-
!函<span></span>數
|<code>{{Background color|#cddae3|函數}}{{0|&ensp;}}({{0|&ensp;}}{{Background color|#ffdfc4|參數1}},{{0|&ensp;}}{{Background color|#ffdfc4|參數2}}{{0|&ensp;}}...)</code>
|调用现有函<span></span>数。所有函<span></span>數都至少要傳入一個參數。
|<code>factorial(5)</code>→{{計算|factorial(5)}}
|-
!多組運算
|<code>{{Background color|#ffdfc4|運算式1}}{{0|&ensp;}}{{Background color|#cddae3|;}}{{0|&ensp;}}{{Background color|#ffdfc4|運算式2}}</code>
|僅會顯示最後一組運算的結果
|<code>2 3;2*3</code>→{{計算|2 3;2*3}}
|-
!變數定義
|<code>{{Background color|#c1debf|變數名稱}}{{0|&ensp;}}{{Background color|#cddae3|←}}{{0|&ensp;}}{{Background color|#ffdfc4|運算式}}</code>
|給特定名稱的變數賦值。需特別注意所有變數的範圍(Scope)皆相同(可想像所有變數皆為全域變數),包括函數中的參數,因此若函數外層已經定義了變數x則函數內部需避免使用同名變數x。
|<code>{{新增條文|x←5}};x</code>→{{計算|x←5;x}}
|-
!{{nowrap|函<span></span>數定義}}
|{{nowrap|<code>{{Background color|#c1debf|函數名稱}}{{0|&ensp;}}{{Background color|#cddae3|:}}{{0|&ensp;}}{{Background color|#edf6fd|參數1}},{{0|&ensp;}}{{Background color|#edf6fd|參數2}}{{0|&ensp;}}...{{Background color|#cddae3|↦}}{{0|&ensp;}}{{Background color|#ffdfc4|函數運算式}}{{0|&ensp;}}{{Background color|#cddae3|;}}</code>}}
|函<span></span>數的語法為以名稱起始並以冒號區隔函<span></span>數名稱與定義(函<span></span>數名稱可留空,但冒號不能省去),整個語法要以{{nowrap|分號(<code>;</code>)}}結尾。位於{{nowrap|{{link|映射}}符號(<code>↦</code>)}}前方為函<span></span>數的變數或參數,後方為函<span></span>數主體定義,即{{nowrap|<code>{{math|{{0|&thinsp;}}''f''{{0|&#32;}}:{{0|&#32;}}''x''{{0|&#32;}}↦{{0|&#32;}}''f''{{0|&thinsp;}}(''x''){{0|&thinsp;}};{{0|&thinsp;}}}}</code>}}。函<span></span>數可以有多個變數,但僅能有單個輸出,即<math>\mathbb{C}^n\mapsto\mathbb{C}</math>或<math>\mathbb{R}^n\mapsto\mathbb{R}</math>。同時函<span></span>數語法不建議寫成嵌套結構,即不建議將函<span></span>數定義內包含另一個函<span></span>數的定義,但可以分開定義{{AnyLink|复合函数|再行組合|函-{}-数的組合}};此外,函<span></span>數定義內不能包含分號,因為分號會視為函<span></span>數的結尾。
|{{nowrap|<code>{{新增條文|f:x↦x^2 1;}}(0);f(5)</code>}} →{{計算|f:x↦x^2 1;(0);f(5)}}
|-
!運算符優先序調整
|<code>({{Background color|#ffdfc4|運算式}}{{0|&ensp;}}{{Background color|#cddae3|要優先計算的運算符}}{{0|&ensp;}}{{Background color|#ffdfc4|運算式}}){{0|&ensp;}}{{Background color|#cddae3|運算符}}{{0|&ensp;}}{{Background color|#ffdfc4|運算式}}</code>
|使用括號來令特定運算優先進行。
|
*<code>2 3*5</code>→{{計算|2 3*5}}
*<code>{{新增條文|{{0|&ensp;}}({{0|&ensp;}}}}2 3{{新增條文|{{0|&ensp;}}){{0|&ensp;}}}}*5</code>→{{計算|(2 3)*5}}
|}
		]] )
end

local last_sort = '<span style="display:none;" class="sortkey">z</span>'
local first_sort = '<span style="display:none;" class="sortkey">a</span>'
local top_op_sort = '<span style="display:none;" class="sortkey">999</span>'

local function applyClass(class, text)
	return '<div class="'..class..'">'..text.."</div>"
end

function p.constantDoc(frame)
	local working_frame = frame
	local args
	local cmath = baselib.cmath.init()
	local qmath = baselib.qmath.init()
	local mathlib = ext_mathlib(cmath, cmath.toComplexNumber)

	if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = getArgs(frame, {
        	trim = false,
			removeBlanks = false
        }) --frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
        working_frame = mw.getCurrentFrame()
	end
	local otherdatas = {
		p.other_data_table
	}
	if args.json then 
		xpcall(function()
			otherdatas[#otherdatas 1] = mw.text.jsonDecode(args.json)
			local special_func = mw.text.split(args.ext or '',',')
			if #special_func > 0 and mw.text.trim(args.ext or '')~='' then
				for _,new_const in ipairs(special_func) do
					p.symbolType.constant.values[#(p.symbolType.constant.values)   1] = new_const
				end
			end
		end,function()end)
	end
	
	local ret = ''
	local function get_opdata(field)
		local result_data = lib_calc.symbol_table[field]
		if result_data~=nil then return result_data end
		for _,it in ipairs(otherdatas) do
			result_data = it[field]
			if result_data~= nil then break end
		end
		return result_data or {}
	end
	local local_ret = ''
	local type_data = p.symbolType.constant
	local_ret = local_ret .. (ret==''and''or'\n') .. '|-\n'

	for _, it_val in ipairs(type_data.values)do
		local val = it_val
		local val_data = get_opdata(val)
		if val_data then
			if not val_data.private then
				--public operator
				if val_data.name then
					local_ret = local_ret .. (local_ret==''and''or'\n') .. '|-\n!|'
					local_ret = local_ret .. '<code>' .. mw.text.nowiki(val)  .. '</code>' .. ' || '
					local_ret = local_ret .. (val_data.title and ("[[" .. val_data.title .. '|' .. val_data.name .. "]]") or val_data.name) .. ' \n||'
					local math_output = ''
					for __, it in ipairs(val_data.othername) do
						math_output = (math_output~=''and'、'or'')..'<code>' .. mw.text.nowiki(it)  .. '</code>'
					end
					local_ret = local_ret .. tostring(math_output) .. ' || '
					local_ret = local_ret .. val_data.description .. ' || '
					math_output = ''
					local calc_ex = (mw.text.trim(val_data.value or '')~='') and val_data.value or nil
					xpcall(function() 
						math_output = calc_ex and lib_calc.calculate({val_data.value,class=val_data.calcmode or 'cmath',useOtherModule='yes'}) or ''
					end,function()return''end)
					local_ret = local_ret .. tostring(math_output) .. ' || '
					math_output = ''
					
					if calc_ex and not val_data.nomath and (not val_data.value:find('%%')) and (not val_data.value:find('ω')) then xpcall(function() 
						math_output = lib_calc.calculate({calc_ex,class='mathtag'})
						math_output = working_frame:extensionTag{ name = 'math', content = tostring(math_output)}
					end,function()return''end)end
					local_ret = local_ret .. tostring(math_output)
				end
			end
		end
	end
	ret = ret .. (ret==''and''or'\n') .. '|-\n'
	ret = ret .. local_ret
	return working_frame:preprocess(ret)
end

function p.operatorDoc(frame)
	local working_frame = frame
	local args
	local cmath = baselib.cmath.init()
	local qmath = baselib.qmath.init()
	local mathlib = ext_mathlib(cmath, cmath.toComplexNumber)

	if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = getArgs(frame, {
        	trim = false,
			removeBlanks = false
        }) --frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
        working_frame = mw.getCurrentFrame()
	end
	local otherdatas = {
		p.other_data_table
	}
	if args.json then 
		xpcall(function()
			otherdatas[#otherdatas 1] = mw.text.jsonDecode(args.json)
			local special_func = mw.text.split(args.ext or '',',')
			if #special_func > 0 and mw.text.trim(args.ext or '')~='' then
				p.symbolType["template_special"] = {
					name="模板特有",
					operators={},
					functions=special_func,
				}
			end
		end,function()end)
	end
	local ret = ''
	local function get_opdata(field)
		local result_data = lib_calc.symbol_table[field]
		if result_data~=nil then return result_data end
		for _,it in ipairs(otherdatas) do
			result_data = it[field]
			if result_data~=nil then break end
		end
		return result_data or {}
	end
	for type_name,type_data in pairs(p.symbolType)do
		local local_ret = ''
		local has_text = false
		local_ret = local_ret .. (ret==''and''or'\n') .. '|-\n!colspan=8| '
		local_ret = local_ret .. last_sort .. (type_data.page and ("[[" .. type_data.page .. '|' .. type_data.name .. "]]") or type_data.name )
		local_ret = local_ret .. '\n|-\n'
		for _, op in ipairs(type_data.operators)do
			local operator_data = get_opdata(op)
			if operator_data then
				if not operator_data.private then
					--public operator
					if operator_data.name then
						local_ret = local_ret .. (local_ret==''and''or'\n') .. '|-\n!|'
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",'<code>' .. mw.text.nowiki(op)  .. '</code>') .. ' || '
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",operator_data.title and ("[[" .. operator_data.title .. '|' .. operator_data.name .. "]]") or operator_data.name) .. ' \n||'
						local_ret = local_ret .. tostring(
							operator_data.count and (
								(tonumber(operator_data.count)~=nil) and operator_data.count or ('<small>'..operator_data.count..'</small>')
							) or '') .. ' || '
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",
								(mw.ustring.len(operator_data.description) > 50 and
									applyClass("CalcDesc",operator_data.description) or operator_data.description
								)) .. ' || '
						local_ret = local_ret .. first_sort ..((operator_data.priority=='∞')and top_op_sort or '').. tostring(operator_data.priority) .. ' || '	
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",'<code>' .. mw.text.nowiki(operator_data.example)  .. '</code>') .. ' || '
						local math_output = ''
						local calc_ex = (mw.text.trim(operator_data.example or '')~='') and operator_data.example or nil
						xpcall(function() 
							math_output = calc_ex and lib_calc.calculate({operator_data.example,class=operator_data.calcmode or 'cmath',useOtherModule='yes'}) or ''
						end,function()return''end)
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",tostring(math_output)) .. ' || '
						math_output = ''
						if calc_ex and not operator_data.nomath and not operator_data.example:find('%%') then xpcall(function() 
							math_output = calc_ex and lib_calc.calculate({operator_data.example,class='mathtag'}) or ''
							math_output = working_frame:extensionTag{ name = 'math', content = tostring(math_output)}
						end,function()return''end)end
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",tostring(math_output))
						has_text=true
					end
				end
			end
		end
		if has_text then
			ret = ret .. (ret==''and''or'\n') .. '|-\n'
			ret = ret .. local_ret
		end
	end
	return working_frame:preprocess(ret)
end

function p.functionDoc(frame)
	local working_frame = frame
	local args
	local cmath = baselib.cmath.init()
	local qmath = baselib.qmath.init()
	local mathlib = ext_mathlib(cmath, cmath.toComplexNumber)

	if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = getArgs(frame, {
        	trim = false,
			removeBlanks = false
        }) --frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
        working_frame = mw.getCurrentFrame()
	end
	local otherdatas = {
		p.other_data_table
	}
	if args.json then 
		xpcall(function()
			otherdatas[#otherdatas 1] = mw.text.jsonDecode(args.json)
			local special_func = mw.text.split(args.ext or '',',')
			if #special_func > 0 and mw.text.trim(args.ext or '')~='' then
				p.symbolType["template_special"] = {
					name="模板特有",
					operators={},
					functions=special_func,
				}
			end
		end,function()end)
	end
	local ret = ''
	local function get_opdata(field)
		local result_data = lib_calc.symbol_table[field]
		if result_data~=nil then return result_data end
		for _,it in ipairs(otherdatas) do
			result_data = it[field]
			if result_data~= nil then break end
		end
		return result_data or {}
	end

	for type_name,type_data in pairs(p.symbolType)do
		local local_ret = ''
		local has_text = false
		local_ret = local_ret .. (ret==''and''or'\n') .. '|-\n!colspan=7| '
		local_ret = local_ret .. last_sort .. (type_data.page and ("[[" .. type_data.page .. '|' .. type_data.name .. "]]") or type_data.name )
		local_ret = local_ret .. '\n|-\n'
		for _, op in ipairs(type_data.functions)do
			local operator_data = get_opdata(op)
			if operator_data then
				if not operator_data.private then
					--public operator
					if operator_data.name then
						local_ret = local_ret .. (local_ret==''and''or'\n') .. '|-\n!|'
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",'<code>' .. mw.text.nowiki(op)  .. '</code>') .. ' || '
						local_ret = local_ret .. first_sort .. 
							applyClass("CalcFuncCell",operator_data.title and ("[[" .. operator_data.title .. '|' .. operator_data.name .. "]]") or operator_data.name) .. ' \n||'
						local_ret = local_ret .. tostring(
							operator_data.count and (
								(tonumber(operator_data.count)~=nil) and operator_data.count or ('<small>'..operator_data.count..'</small>')
							) or '') .. ' || '
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",
								(mw.ustring.len(operator_data.description) > 50 and
									applyClass("CalcDesc",operator_data.description) or operator_data.description
								)
							) .. ' || '
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",
								(mw.text.trim(operator_data.example or '')~='') and 
								('<code>' .. mw.text.nowiki(operator_data.example)  .. '</code>') or ''
							) .. ' || '
						local math_output = ''
						local calc_ex = (mw.text.trim(operator_data.example or '')~='') and operator_data.example or nil
						xpcall(function() 
							math_output = calc_ex and lib_calc.calculate({calc_ex,class=operator_data.calcmode or 'cmath',useOtherModule='yes'}) or ''
						end,function()return''end)
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",tostring(math_output)) .. ' || '
						math_output = ''
						if calc_ex and not operator_data.nomath and not operator_data.example:find('%%') then xpcall(function() 
							math_output = lib_calc.calculate({operator_data.example,class='mathtag'})
							math_output = working_frame:extensionTag{ name = 'math', content = tostring(math_output)}
						end,function()return''end)end
						local_ret = local_ret .. first_sort .. applyClass("CalcFuncCell",tostring(math_output))
						has_text=true
					end
				end
			end
		end
		if has_text then
			ret = ret .. (ret==''and''or'\n') .. '|-\n'
			ret = ret .. local_ret
		end
	end
	return working_frame:preprocess(ret)
end

function p.allOperator(frame)
	local working_frame = frame
	if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = getArgs(frame, {
        	trim = false,
			removeBlanks = false
        }) --frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame or {}
        if type(args) ~= type({}) then args = {args} end
        working_frame = mw.getCurrentFrame()
	end
	local comma = ', '
	local pattern = '%s'
	comma = args.comma or comma
	pattern = args.pattern or pattern
	local operator_map = {}
	local operators = {}
	for _,type_data in pairs(p.symbolType) do
		if type(type_data.operators) == type({}) then
			for __,operator in pairs(type_data.operators) do
				if type(operator) == type("string") then
					operator_map[mw.text.trim(operator)] = (({mw.ustring.find(operator,"%w")})[1]==nil)
				end
			end
		end
	end
	for operator, operator_flag in pairs(operator_map) do 
		if operator_flag==true then operators[#operators 1] = operator  end
	end
	local body = ''
	for i=1,#operators do
		if body~=''then body=body..comma end
		body=body..mw.ustring.format(pattern, operators[i])
	end
	return body
end

return p