Function Plotter

Function Plotter

📐 工作原理與說明
座標對映:sx = 左padding + (x − xMin) ÷ (xMax − xMin) × 繪圖寬,sy = 上padding + (yMax − y) ÷ (yMax − yMin) × 繪圖高;網格步長 = niceStep(量程 ÷ 10)(橫)/ ÷ 8(縱);取樣點 N = max(200, 繪圖寬 × 2);相鄰 |Δy| > 量程 × 2 時斷筆(處理漸近線)
使用 Canvas 繪製常見函式影像:一次函式、二次函式、三角函式、指數函式、對數函式,支援自定義引數與座標範圍Plot mathematical functions over a chosen range with adjustable parameters
移動滑鼠檢視座標

📐 使用說明

自定義函式:輸入以 x 為變數的表示式,可用 sin, cos, tan, exp, log, sqrt, abs, pow, PI, E 等白名單函式與常量;不支援 Math.sin 等成員訪問、賦值或其他變數名,此類寫法會繪製失敗。
示例:sin(x)*2、x*sin(x)、exp(-x*x)、sqrt(abs(x))。
互動:在影像上移動滑鼠可顯示對應座標值;自適應 Y 範圍會根據當前 X 範圍自動調整。

📚 深度解析:數學圖形繪製

💡 常見使用場景

  • 函式教學中,輸入 y=f(x) 觀察影像形態、零點、單調性與極值,輔助理解導數與積分概念。
  • 工程波形分析裡,繪製 sin/cos、衰減振盪等曲線,讀取週期、振幅與相位。
  • 資料探索時,先畫出經驗公式的曲線,再與散點對比,判斷擬合是否合理。
算例:正弦函式 f(x)=sin x
振幅 A=1,週期 T=2π≈6.2832,零點位於 x=kπ(k∈ℤ)。在 [−10,10] 內零點為 k=−3…3 即 −9.4248、−6.2832、…、9.4248。公式:f(x)=sin x,max=1、min=−1。
算例:引數對圖形的影響
對 f(x)=A·sin(ωx+φ),振幅由 A 決定、週期 T=2π/ω、相位平移 −φ/ω。將 A=2、ω=1、φ=π/2 代入可得振幅 2、週期 6.2832、左移 π/2。

❓ 常見問題(FAQ)

影像出現鋸齒或斷裂怎麼辦?
多為取樣點數不足或定義域跨度過大導致。增大采樣解析度、合理設定 x 範圍即可;在奇點(如 1/x 在 x=0)附近,工具可能自動斷開或限幅,屬正常現象。
如何讀取週期與極值?
對週期函式讀相鄰兩個同相位點(如兩個相鄰波峰)的橫座標差即為週期;波峰縱座標為最大值、波谷為最小值。繪圖工具的游標/座標讀數可輔助精確定位。

Formula & Standard References

Item Formula / Note Source / Standard
Definition of a function Each x in the domain determines a unique y = f(x) ISO 80000-2:2019, Quantities and units - Part 2: Mathematics
Cartesian coordinates Two perpendicular axes locate every point of the plane Descartes R., La Geometrie (1637)
Common function families Polynomials, power, exponential, logarithmic and trigonometric functions ISO 80000-2:2019, Quantities and units - Part 2: Mathematics
Sampling for plotting Sample the interval uniformly, evaluate and join the points to approximate the curve Press WH et al., Numerical Recipes (3rd ed.), sampling practice
⚠️ 使用說明與注意事項