対数関数
対数関数の定義
「 だから 」——対数とは「何乗すればその数になるか」を表す記号です。
「何乗すれば?」という問いは日常でも出てきます。「銀行の金利が年率10%で、預金が2倍になるのは何年後?」——これは を解く問題で、答えは 年です。
指数関数 の逆関数が対数関数です。「を何乗すれば になるか」がわかれば、逆向きに「 から指数を求める」ことができます。
つまり、「 の何乗が か」を表す関数です:
「定義域が だけ」という点に注意——マイナスの数や0の対数は定義されません(「 の何乗が0以下になるか?」というのは答えがない問いだからです)。
対数の基本性質
「掛け算は対数にすると足し算になる」——これが対数の最大の便利さです。昔の天文学者たちは巨大な数の掛け算を対数を使って足し算に変換して計算していました。
インタラクティブデモ:指数関数と対数関数の対称性
(青)と (オレンジ)は直線 について対称です(逆関数の関係)——「一方のグラフを に対して折り返すともう一方になる」という鏡のような関係です。マウスを左右に動かすと、 座標が変わり、対称点が強調表示されます。
function loop() {
ctx.clearRect(0, 0, W, H);
var ox = W / 2 - 60, oy = H / 2 + 60;
var scale = 45;
var xVal = (mx / W) * 5 - 0.5;
function toScreen(x, y) {
return { sx: ox + x * scale, sy: oy - y * scale };
}
// Grid
ctx.strokeStyle = 'rgba(255,255,255,0.06)';
ctx.lineWidth = 1;
for (var gx = -2; gx <= 7; gx++) {
var gs = toScreen(gx, 0);
ctx.beginPath(); ctx.moveTo(gs.sx, 0); ctx.lineTo(gs.sx, H); ctx.stroke();
}
for (var gy = -2; gy <= 7; gy++) {
var gs2 = toScreen(0, gy);
ctx.beginPath(); ctx.moveTo(0, gs2.sy); ctx.lineTo(W, gs2.sy); ctx.stroke();
}
// Axes
ctx.strokeStyle = 'rgba(255,255,255,0.3)';
ctx.lineWidth = 1.5;
ctx.beginPath(); ctx.moveTo(0, oy); ctx.lineTo(W, oy); ctx.stroke();
ctx.beginPath(); ctx.moveTo(ox, 0); ctx.lineTo(ox, H); ctx.stroke();
// Axis labels
ctx.fillStyle = 'rgba(255,255,255,0.4)';
ctx.font = '12px sans-serif';
for (var lx = -1; lx <= 6; lx++) {
if (lx === 0) continue;
var ls = toScreen(lx, 0);
ctx.fillText(lx, ls.sx - 4, oy + 16);
}
for (var ly = -1; ly <= 6; ly++) {
if (ly === 0) continue;
var ls2 = toScreen(0, ly);
ctx.fillText(ly, ox + 6, ls2.sy + 4);
}
// y=x line (green dashed)
ctx.strokeStyle = 'rgba(102,187,106,0.5)';
ctx.lineWidth = 1.5;
ctx.setLineDash([6,4]);
ctx.beginPath();
var s1 = toScreen(-1, -1), s2 = toScreen(7, 7);
ctx.moveTo(s1.sx, s1.sy); ctx.lineTo(s2.sx, s2.sy);
ctx.stroke();
ctx.setLineDash([]);
ctx.fillStyle = 'rgba(102,187,106,0.7)';
ctx.font = '13px sans-serif';
ctx.fillText('y = x', toScreen(5.5, 5.8).sx, toScreen(5.5, 5.8).sy);
// y=2^x - blue
ctx.strokeStyle = '#4fc3f7';
ctx.lineWidth = 2.5;
ctx.beginPath();
var st1 = false;
for (var xi = -2; xi <= 7; xi += 0.03) {
var yi = Math.pow(2, xi);
if (yi > 8 || yi < -2) { st1 = false; continue; }
var s = toScreen(xi, yi);
if (!st1) { ctx.moveTo(s.sx, s.sy); st1 = true; } else ctx.lineTo(s.sx, s.sy);
}
ctx.stroke();
ctx.fillStyle = '#4fc3f7';
ctx.font = 'bold 13px sans-serif';
ctx.fillText('y = 2ˣ', toScreen(2.6, 7.5).sx, toScreen(2.6, 7.5).sy);
// y=log2(x) - orange
ctx.strokeStyle = '#ffb74d';
ctx.lineWidth = 2.5;
ctx.beginPath();
var st2 = false;
for (var xi2 = 0.05; xi2 <= 7; xi2 += 0.03) {
var yi2 = Math.log2(xi2);
if (yi2 < -2 || yi2 > 8) { st2 = false; continue; }
var s2b = toScreen(xi2, yi2);
if (!st2) { ctx.moveTo(s2b.sx, s2b.sy); st2 = true; } else ctx.lineTo(s2b.sx, s2b.sy);
}
ctx.stroke();
ctx.fillStyle = '#ffb74d';
ctx.fillText('y = log₂x', toScreen(6.5, 2.7).sx, toScreen(6.5, 2.7).sy);
// Symmetric pair highlight
var xCl = Math.max(0.1, Math.min(4.5, xVal));
var yExp = Math.pow(2, xCl);
var yLog = Math.log2(Math.max(0.1, xCl));
// Mirror point: (xCl, yExp) and (yExp, xCl)
var pExp = toScreen(xCl, yExp);
var pMirror = toScreen(yExp, xCl);
var pLog = toScreen(xCl, yLog);
var pLogMirror = toScreen(yLog, xCl);
// Arrow connecting mirror pair
if (yExp < 8) {
ctx.strokeStyle = 'rgba(255,235,59,0.5)';
ctx.lineWidth = 1.5;
ctx.setLineDash([3,3]);
ctx.beginPath(); ctx.moveTo(pExp.sx, pExp.sy); ctx.lineTo(pMirror.sx, pMirror.sy); ctx.stroke();
ctx.setLineDash([]);
ctx.fillStyle = '#4fc3f7';
ctx.beginPath(); ctx.arc(pExp.sx, pExp.sy, 6, 0, Math.PI*2); ctx.fill();
ctx.fillStyle = '#ffb74d';
ctx.beginPath(); ctx.arc(pMirror.sx, pMirror.sy, 6, 0, Math.PI*2); ctx.fill();
}
// Info panel
ctx.fillStyle = 'rgba(0,0,0,0.65)';
ctx.beginPath(); ctx.roundRect(10, 10, 220, 90, 8); ctx.fill();
ctx.fillStyle = '#ffeb3b';
ctx.font = 'bold 13px monospace';
ctx.fillText('x = ' + xCl.toFixed(2), 18, 32);
ctx.fillStyle = '#4fc3f7';
ctx.font = '13px monospace';
ctx.fillText('2ˣ = ' + (yExp <= 9 ? yExp.toFixed(3) : '>8'), 18, 52);
ctx.fillStyle = '#ffb74d';
ctx.fillText('log₂(x) = ' + yLog.toFixed(3), 18, 72);
ctx.fillStyle = 'rgba(102,187,106,0.8)';
ctx.font = '11px sans-serif';
ctx.fillText('↔ 対称(y=x に関して)', 18, 90);
requestAnimationFrame(loop);
}
loop(); 底の変換公式
「 を電卓で計算したい」——でも電卓のボタンは か しかない。そこで使うのが底の変換公式:
「どんな底の対数も、常用対数か自然対数に変換できる」——これで電卓でどんな対数も計算できます。
例
対数の計算例
例① を計算する
「」を考えます—— なので
例② を計算する
「4を何乗すると8になるか」——底の変換で解決します:
例③ を計算する
「対数の足し算は中身の掛け算」——この性質を使います:
常用対数の応用:桁数の計算
「 は何桁か?」——実際に計算しなくても対数で桁数がわかります:
なので 、つまり4桁(実際 )。
一般に、正の整数 の桁数は です——「桁数を知りたいときは を取って切り捨てに1を足す」という便利な公式です。
練習問題
- を求めよ。
- を計算せよ。
- のとき を常用対数で表せ()。
解答
- なので
まとめ
- は の逆関数( に関して対称)——「鏡像の関係」
- 定義域:、値域:すべての実数
- で単調増加、 で単調減少
- 、( と を必ず通る)
- 底の変換:——「常用対数か自然対数に変換して計算」
次回は指数・対数を使った方程式と不等式を解きます。「底をそろえて比較する」という考え方が基本です。