模板:Root/doc

維基百科,自由的百科全書
跳至導覽 跳至搜尋

本模板可以計算任意複數算術平方根或任意數的n次單位根,或一個四次(含)以下的多項式之

找出數字的平方根,表達式為:
{{root|數字}}(求<math>\sqrt{\text{數}\ \ \text{字}\quad}</math>)
找出數字的n方根,表達式為:(n可以是任意數字)
{{root|數字|n}}(求<math>\sqrt[n]{\text{數}\ \ \text{字}\quad}</math>)
找出數字的n方根的第k個根,表達式為:(<math>k\leqslant n</math>且<math>n,k\in \mathbb{N}</math>)
{{root|數字|n|number=k}}(求<math>\sqrt[n]{\text{數}\ \ \text{字}\quad}</math>第k個根)
若輸入超過2個參數則為多項式求根模式,能求四次或四次以下的一元多項式之(即存在「公式解」的方程式;五次及以上的方程式無公式解):
{{root|a|b|c}}(求<math>{ {{ {{ {a}\, {{ {x}^{2} }} }}+{{ {b}\, {x} }} }}+{c} } = 0 </math>的根)
※註:求根模式的number class僅支援複數域

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

Examples:

  • {{root|0.000001}} gives 0.001
  • {{root|0.0001}} gives 0.01
  • {{root|0.81}} gives 0.9
  • {{root|2}} gives 1.4142135623731
  • {{root|25}} gives 5
  • {{root|27|3}} gives 3
  • {{root|256|4}} gives 4
  • {{root|-1}} gives i (result if answer is not a real number)
  • {{root|-4}} gives 2i
  • {{root|-7}} gives 2.6457513110646i
  • {{root|i}} gives 0.70710678118655+0.70710678118655i[1]
  • {{root|pi}} gives 1.7724538509055(OEIS數列A002161
  • {{root|e}} gives 1.6487212707001(OEIS數列A019774
  • {{root|i|-i}} gives 0.20787957635076(OEIS數列A049006
  • {{root|-6|-3}} gives 0.27516060407455-0.47659214649847i[2]
  • {{root|5|7/5}} gives 3.1569251777946
  • {{root|2/7|7/3}} gives 0.58455850144128
  • {{root|-2|1/3}} gives -8
  • {{root|-2/9|1/3}} gives -0.010973936899863
  • {{root|{{root|2|1/3}}|2}} gives 2.8284271247462
  • {{root|3|{{root|3|2}}}} gives 1.8856717068806
  • {{root|{{root|3|2}}|{{root|3|2}}}} gives 1.3731976212041
  • 例如1個四次方根有4個根:
    {{root|1|4|number=1}} gives 1
    {{root|1|4|number=2}} gives i
    {{root|1|4|number=3}} gives -1
    {{root|1|4|number=4}} gives -i
  • 例如8個三次方根有3個根:
    {{root|8|3|number=1}} gives 2
    {{root|8|3|number=2}} gives -1+1.7320508075689i
    {{root|8|3|number=3}} gives -1-1.7320508075689i
    • {{複變運算|({{root|8|3|number=3}})^3}} gives 8

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

  • {{root| j+k |number class=四元數}} gives 0.84089641525371+0.59460355750136j+0.59460355750136k[3]
  • {{root|1+2i+3j+4k | 4+3i+2j+k|number class=四元數}} gives 1.4191927056231-0.20671979310212i+0.10820151725293j+0.054100758626467k[4]

求根模式:

  • {{root|1|-3|2}} gives 2,1(求<math>x^2-3x+2=0</math>的所有
  • {{root|2|-7|5|-7|3}} gives 3,-i,i,0.5(求<math>2x^4-7x^3+5x^2-7x+3=0</math>的所有
  • {{root|2|-7|5|-7|3|root=1}} gives 3(求<math>2x^4-7x^3+5x^2-7x+3=0</math>的第一個根,即可能是
  • {{root|3|-6|root=2}} gives 2(求<math>3x-6=0</math>的;<math>3x-6=0</math>只有1個根)
  • {{root|3|root=1}} gives (對應的式子為<math>3=0</math>,不存在返回空白)
  • {{root}} gives 1(甚麼都不輸入返回空積,即1)

模板資料[編輯]

以下是該模板的模板資料,適用於視覺化編輯器等工具。

Root模板資料

<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>

參見[編輯]

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

註釋[編輯]

  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]