#10 ふれてみよう高校数学 解析(微分・積分・極限)
接線と法線の方程式
接線の方程式
「カーブを走る車が急ハンドルをやめた瞬間、まっすぐ進む方向」——これが接線のイメージです。曲線のある点でどの方向に向いているかを示す直線が接線です。
曲線 上の点 における接線(tangent line)の方程式は:
つまり、傾きが で点 を通る直線です——「傾き = 微分係数」がここで役立ちます。
法線の方程式
「接線と直角に交わる直線」——法線(normal line)は接線に直交する直線です。傾き の直線に垂直な直線の傾きは ( のとき)——「傾きの積が になると垂直」なので:
例: の接線と法線
「放物線のある点での接線と法線を求める」——、 なので、 での接線:
法線:
数値例: のとき
- 接線:(傾き )——「 での放物線の傾きは 2」
- 法線:(傾き )——「接線の傾き 2 の逆数は 、符号を反転して 」
デモ: の接線と法線
マウスを左右に動かして接点 を変えてください。接線(黄)と法線(オレンジ)がリアルタイムに更新されます。両者が直交していることを視覚的に確認できます。
y=x² の接線(黄)と法線(橙)。マウスで接点を移動。
function loop() {
ctx.clearRect(0, 0, W, H);
var scale=55;
var ox=W/2, oy=H*0.7;
function toSx(x){return ox+x*scale;}
function toSy(y){return oy-y*scale;}
function drawAxes(){
ctx.strokeStyle='rgba(255,255,255,0.13)';
ctx.lineWidth=1;
ctx.beginPath();ctx.moveTo(0,oy);ctx.lineTo(W,oy);ctx.stroke();
ctx.beginPath();ctx.moveTo(ox,0);ctx.lineTo(ox,H);ctx.stroke();
ctx.fillStyle='rgba(255,255,255,0.25)';
ctx.font='10px monospace';
ctx.textAlign='center';
for(var i=-5;i<=5;i++){
if(i===0)continue;
ctx.fillText(i,toSx(i),oy+14);
}
ctx.textAlign='right';
for(var j=1;j<=4;j++){
ctx.fillText(j,ox-6,toSy(j)+4);
}
}
function plotCurve(fn,color,lw){
ctx.strokeStyle=color;ctx.lineWidth=lw||2;
ctx.beginPath();
var first=true;
for(var xi=-W/2;xi<=W/2;xi+=1){
var x=xi/scale;
var y=fn(x);
if(!isFinite(y)||y>H/scale+0.5||y<-1){first=true;continue;}
if(first){ctx.moveTo(toSx(x),toSy(y));first=false;}
else ctx.lineTo(toSx(x),toSy(y));
}
ctx.stroke();
}
function drawInfiniteLine(x0,y0,slope,color,dash){
// extend to canvas edges
ctx.strokeStyle=color;ctx.lineWidth=1.5;
if(dash)ctx.setLineDash(dash);else ctx.setLineDash([]);
// find x where y goes out of bounds
var ext=6;
var sx1=toSx(x0-ext), sy1=toSy(y0+slope*(-ext));
var sx2=toSx(x0+ext), sy2=toSy(y0+slope*ext);
ctx.beginPath();ctx.moveTo(sx1,sy1);ctx.lineTo(sx2,sy2);ctx.stroke();
ctx.setLineDash([]);
}
ctx.fillStyle='#0d1117';
ctx.fillRect(0,0,W,H);
drawAxes();
var f=function(x){return x*x;};
var fd=function(x){return 2*x;};
plotCurve(f,'#4fc3f7',2.5);
// Mouse x
var a=(mx-ox)/scale;
a=Math.max(-2.8,Math.min(2.8,a));
var fa=f(a);
var slope=fd(a);
// Tangent line
drawInfiniteLine(a,fa,slope,'rgba(255,202,40,0.9)',[]);
// Normal line (perpendicular)
if(Math.abs(slope)>0.05){
var normalSlope=-1/slope;
drawInfiniteLine(a,fa,normalSlope,'rgba(255,138,101,0.85)',[5,4]);
}
// Right angle marker at tangent point
if(Math.abs(slope)>0.05){
var ang=Math.atan(slope);
var sz=10;
var px1=toSx(a)+Math.cos(ang)*sz;
var py1=toSy(fa)-Math.sin(ang)*sz; // careful with y-flip
// just draw a small square
ctx.save();
ctx.translate(toSx(a),toSy(fa));
ctx.rotate(-ang);
ctx.strokeStyle='rgba(255,255,255,0.5)';
ctx.lineWidth=1;
ctx.strokeRect(6,-6,8,8);
ctx.restore();
}
// Point on curve
ctx.beginPath();ctx.arc(toSx(a),toSy(fa),6,0,Math.PI*2);
ctx.fillStyle='#fff';ctx.fill();
ctx.strokeStyle='#ffca28';ctx.lineWidth=2;ctx.stroke();
// Info panel
ctx.fillStyle='rgba(0,0,0,0.7)';
ctx.fillRect(8,8,280,100);
ctx.font='12px monospace';ctx.textAlign='left';
ctx.fillStyle='#4fc3f7';
ctx.fillText('接点: ('+a.toFixed(3)+', '+fa.toFixed(3)+')',14,28);
ctx.fillStyle='#ffca28';
ctx.fillText("接線傾き f'(a) = "+slope.toFixed(3),14,46);
var tangentEq='y = '+slope.toFixed(2)+'x + '+(fa-slope*a).toFixed(2);
ctx.fillText('接線: '+tangentEq,14,64);
ctx.fillStyle='#ff8a65';
if(Math.abs(slope)>0.05){
var ns=-1/slope;
var normalEq='y = '+ns.toFixed(2)+'x + '+(fa-ns*a).toFixed(2);
ctx.fillText('法線: '+normalEq,14,82);
} else {
ctx.fillText('法線: x = '+a.toFixed(2)+' (垂直線)',14,82);
}
// Legend
ctx.font='12px sans-serif';ctx.textAlign='right';
ctx.fillStyle='#ffca28';ctx.fillText('── 接線',W-10,H-28);
ctx.fillStyle='#ff8a65';ctx.fillText('- - 法線',W-10,H-10);
requestAnimationFrame(loop);
}
loop(); 別の曲線での例
の接線
「 のグラフで、 の点に接する直線」—— なので での接線:
の接線
「 での接線は原点を通る」——、 での接線:
特別なケース
(水平接線)
「山頂や谷底では接線が水平になる」——接線が水平( の定数関数)になります。法線は垂直線 。
原点を通る接線
「放物線の上のどの点から引いた接線が原点を通るか」——曲線上の点 における接線が原点 を通る条件:
例: の場合、(頂点のみ)。
陰関数の接線
「 の形で表せていない円の方程式でも接線を求められる」——(円)上の点 での接線:両辺を で微分すると:
での傾き:。接線:
まとめ
- 接線の傾き 微分係数 ——「微分値がそのまま傾きになる」
- 法線は接線に直交、傾きは ——「傾きの積が になると直交」
- 陰関数微分を使えば陰関数でも接線が求められる——「 の形でなくても OK」
次回からは積分——「面積」を計算する逆の演算を学びます。まず不定積分からスタートです。