Template:Root/doc

来自testwiki
跳转到导航 跳转到搜索

Template:Documentation subpage Template:Lua 本模板可以计算任意複數算術平方根或任意數的n次单位根,或一個四次(含)以下的多項式之

找出數字的平方根,表達式為:
{{root|-{zh-hant:數;zh-hans:数;}-字}}(求-{zh-hant:  ;zh-hans:  ;}-)
找出數字的Template:Math方根,表達式為:(Template:Math可以是任意數字)
{{root|-{zh-hant:數;zh-hans:数;}-字|Template:Math}}(求-{zh-hant:  n;zh-hans:  n;}-)
找出數字的Template:Math方根的第Template:Math個根,表達式為:(knn,k
{{root|-{zh-hant:數;zh-hans:数;}-字|Template:Math|number=Template:Math}}(求-{zh-hant:  n;zh-hans:  n;}-第Template:Math個根)
若輸入超過2個參數則為多項式求根模式,能求四次或四次以下的一元多項式之(即存在「公式解」的方程式;五次及以上的方程式無公式解):
{{root|Template:Math|Template:Math|Template:Math}}(求Template:計算結果的根)
※註:求根模式的number class僅支援複數域

本模板的輸入值可以是任一複數(包含實數負數虛數

Examples:

本模板也可以透過指定number class來支援其他數字,如四元數

求根模式:

  • {{root|1|-3|2}} gives Template:Root(求x23x+2=0的所有
  • {{root|2|-7|5|-7|3}} gives Template:Root(求2x47x3+5x27x+3=0的所有
  • {{root|2|-7|5|-7|3|root=1}} gives Template:Root(求2x47x3+5x27x+3=0的第一個根,即可能是
  • {{root|3|-6|root=2}} gives Template:Root(求3x6=03x6=0只有1個根)
  • {{root|3|root=1}} gives Template:Root(對應的式子為3=0不存在返回空白)
  • {{root}} gives Template:Root(甚麼都不輸入返回空积,即1)

模板資料

Template:TemplateDataHeader <templatedata> { "params": { "1": { "label": "要計算方根的數字或領導係數", "description": "要用來計算方根的數字。在多項式求根模式下為領導係數", "type": "number", "required": true }, "2": { "label": "方根的次數或第二係數", "description": "計算方根時的係數,如輸入3為求立方根。若為多項式求根模式則為第二高次項係數。", "type": "number" }, "number": { "label": "方根數", "description": "求第幾個方根。1為主方根。以平方根為例,1為正平方根、2為負平方根。n次方根即會有n個方根值。", "type": "number" }, "root": { "label": "多項式根數", "description": "多項式求根模式時指定輸出第幾個根。若要求實根可輸入1。有輸入本參數時就會以多項式求根模式進行計算。", "type": "number" }, "3": { "label": "第三係數", "description": "多項式求根模式的第三高次項係數", "type": "number" }, "4": { "label": "第四係數", "description": "多項式求根模式的第四高次項係數", "type": "number" }, "5": { "label": "第五係數", "description": "多項式求根模式的第五高次項係數", "type": "number" }, "number class": { "label": "數字模式", "description": "計算時使用的數學模組。可輸入math、cmath(複數)或qmath(四元數)", "type": "string", "suggestedvalues": [ "math", "cmath", "qmath", "實數", "複數", "四元數" ] }, "use math": { "label": "使用數學輸出", "description": "是否使用數學公式模式輸出", "type": "boolean" } }, "description": "計算方根或多項式的根", "format": "inline" } </templatedata>

參見

  • Template:Tl:不含求值的多次方根模板
  • Template:Tl:專門用於表示平方根的模板,但不含求值功能

註釋

Template:Reflist

  1. 已由Mathematica驗算,代碼為N[Sqrt[I],14],結果為0.70710678118655 + 0.70710678118655 I
  2. 已由Mathematica驗算,代碼為N[(-6)^(1/(-3)), 14],結果為0.27516060407455 - 0.47659214649847 I
  3. 已由Mathematica驗算,代碼為<< Quaternions`;MyPow[p_, q_] := Exp[q ** Log[p]];N[MyPow[Quaternion[0, 0, 1, 1], Quaternion[1/2, 0, 0, 0]], 14],結果為Quaternion[0.84089641525371, 0, 0.59460355750136, 0.59460355750136]
  4. 已由Mathematica驗算,代碼為<< Quaternions`;MyPow[p_, q_] := Exp[q ** Log[p]];N[MyPow[Quaternion[1, 2, 3, 4], Quaternion[4, 3, 2, 1]^-1], 14],結果為Quaternion[1.4191927056231, -0.20671979310212, 0.10820151725293, 0.054100758626467]