<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <id>https://www.yunseo.kim/ja/</id><title>Yunseo Kim's Study Notes</title><subtitle>Yunseo Kim's personal blog on mathematics, physics, and engineering, now expanding to business, AI agent ecosystems, software supply chains, and digital trust.</subtitle> <updated>2026-04-11T20:14:35+09:00</updated> <author> <name>Yunseo Kim</name> <uri>https://www.yunseo.kim/ja/</uri> </author><link rel="self" type="application/atom+xml" href="https://www.yunseo.kim/ja/feed.xml"/><link rel="alternate" type="text/html" hreflang="en" href="https://www.yunseo.kim/" /><link rel="alternate" type="text/html" hreflang="ko" href="https://www.yunseo.kim/ko/" /><link rel="alternate" type="text/html" hreflang="ja" href="https://www.yunseo.kim/ja/" /><link rel="alternate" type="text/html" hreflang="zh-TW" href="https://www.yunseo.kim/zh-TW/" /><link rel="alternate" type="text/html" hreflang="es" href="https://www.yunseo.kim/es/" /><link rel="alternate" type="text/html" hreflang="pt-BR" href="https://www.yunseo.kim/pt-BR/" /><link rel="alternate" type="text/html" hreflang="fr" href="https://www.yunseo.kim/fr/" /><link rel="alternate" type="text/html" hreflang="de" href="https://www.yunseo.kim/de/" /><link rel="alternate" type="text/html" hreflang="pl" href="https://www.yunseo.kim/pl/" /><link rel="alternate" type="text/html" hreflang="cs" href="https://www.yunseo.kim/cs/" /><link rel="alternate" type="text/html" hreflang="sw" href="https://www.yunseo.kim/sw/" /><link rel="alternate" type="text/html" hreflang="am" href="https://www.yunseo.kim/am/" /> <generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator> <rights> © 2026 Yunseo Kim </rights> <icon>/assets/img/favicons/favicon.ico</icon> <logo>/assets/img/favicons/favicon-96x96.png</logo> <entry><title xml:lang="ja">コントリビューター・コヴェナント（Contributor Covenant）3.0 行動規範（Code of Conduct）の韓国語翻訳ノート</title><link href="https://www.yunseo.kim/ja/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/" rel="alternate" type="text/html" hreflang="am" /><published>2026-03-20T00:00:00+09:00</published> <updated>2026-03-22T23:34:27+09:00</updated> <id>https://www.yunseo.kim/ja/posts/notes-on-the-korean-translation-of-the-contributor-covenant-3.0-code-of-conduct/</id> <author> <name>Yunseo Kim</name> </author> <category term="Dev" /> <category term="Dev Culture" /> <summary xml:lang="ja">12025年7月に公開されたコントリビューター・コヴェナント（Contributor Covenant）3.0版の韓国語翻訳を進めるにあたり、検討した点やいくつかの表現をそのように訳した理由、個人的な所感を記しておく。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>12025年7月に公開されたコントリビューター・コヴェナント（Contributor Covenant）3.0版の韓国語翻訳を進めるにあたり、検討した点やいくつかの表現をそのように訳した理由、個人的な所感を記しておく。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><blockquote class="prompt-info"><p>コントリビューター・コヴェナント 3.0 行動規範（Contributor Covenant 3.0 Code of Conduct）の公式韓国語訳を追加する PR: <a href="https://github.com/EthicalSource/contributor_covenant/pull/1590">feat(i18n): add Korean translation for Contributor Covenant 3.0 (#1590)</a></p></blockquote><h2 id="コントリビューターコヴェナント">コントリビューター・コヴェナント</h2><p><a href="https://www.contributor-covenant.org/">コントリビューター・コヴェナント（Contributor Covenant）</a>は、12014年に <strong>コーラライン・エイダ・エムキ（Coraline Ada Ehmke）</strong> が初めて作成・公開し、12021年からは <strong>OES（Organization for Ethical Source）</strong> に移管され、そのコントリビューターたちによって保守と改善が行われている、今日の世界で最も広く使われているデジタルコミュニティの行動規範である。コミュニティが共有しうる暗黙の価値観を明文化し、誰もが歓迎され、安全でいられるコミュニティ文化を育むことを目標としている。</p><p>かつての開発者コミュニティでは、能力主義という美名のもとで荒い言動や差別的発言などが黙認されることが珍しくなく、コントリビューター・コヴェナントは、開発者コミュニティが自浄作用を経て多様な人々を包摂し、相互尊重と建設的なフィードバックを重視する人間中心の文化へと変わっていく重要な契機となった。今日では、クリエイティブ・コモンズ、Linux、Apple、Mastodon、Microsoft、WordPress、IBM など、世界中の数十万ものオープンソースプロジェクトがこの誓約を採択している。</p><h2 id="コントリビューターコヴェナント30への改訂で変わった点">コントリビューター・コヴェナント3.0への改訂で変わった点</h2><p>OES は 12024年にコントリビューター・コヴェナント10周年を記念して作業に着手し、約1年の作業を経て 12025年7月に公開した 3.0 版では、前版の 2.1 と比べて次のような主要な変更点がある。</p><ul><li>参考資料:<ul><li><a href="https://ethicalsource.dev/blog/contributor-covenant-3/">https://ethicalsource.dev/blog/contributor-covenant-3/</a><li><a href="https://www.contributor-covenant.org/faq/">https://www.contributor-covenant.org/faq/</a></ul></ul><h3 id="柔軟性の拡大">柔軟性の拡大</h3><ul><li>オープンソースコミュニティに最適化されていた従来版に比べ、ソフトウェア開発以外にもさまざまなオンライン／オフラインコミュニティに適用できるよう設計した<ul><li>e.g. <strong>「プロジェクト保守担当者（Project Maintainers）」</strong> の代わりに、より中立的で包摂的な <strong>「コミュニティモデレーター（Community Moderators）」</strong> という用語を用いている</ul><li>アメリカ中心の慣用句を削除し、他文化圏の話者もより容易に理解し翻訳できる明確な表現へ置き換えた</ul><h3 id="応報的正義から修復的正義へのパラダイム転換">応報的正義から修復的正義へのパラダイム転換</h3><p>コントリビューター・コヴェナント 3.0 版で前版と比べて最も大きく変わった点の一つは、<strong>応報的正義（Retributive Justice）</strong> から <strong>修復的正義（Restorative Justice）</strong> へのパラダイム転換を成し遂げたことである。従来、段階的な制裁執行基準に集中していた <strong>執行指針（enforcement guidelines）</strong> の段落を、<strong>被害への対応と修復（Addressing and Repairing Harm）</strong> の段落として再構成した。</p><ul><li>一部の対応段階の名称を変更<li>従来の対応（Consequence）項目に加え、修復（Repair）指針項目を新たに記述し、一次的な加害者制裁にとどまらず、その後どのように当事者間の壊れた関係を回復し、対立を収め、誤りを正すかについても扱うようになった<li>第三者による執行と処罰だけを強調するのではなく、可能であれば自発的な省察と和解、改善を促し、問題発生後にコミュニティを再び健全にする方策を考える方向へと性格が変化した</ul><h3 id="より明確になった指針">より明確になった指針</h3><ul><li><strong>標準（Our Standards）</strong> 段落を <strong>推奨される行動（Encouraged Behaviors）</strong> と <strong>制限される行動（Restricted Behaviors）</strong> の二段落に明確に分け、可読性を高めた<li>特に <strong>制限される行動（Restricted Behaviors）</strong> 段落では、どのような悪質行為も実際に実行することだけでなく、実行すると脅したり助長したりすることも明示的に制限し、予防力を強化している<blockquote><p>We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct.</p></blockquote><li>また <strong>制限される行動（Restricted Behaviors）</strong> の下位段落として <strong>その他の制限事項（Other Restrictions）</strong> を新設し、従来は明示的な制限規定が不十分だった身元の偽装（Misleading identity）と出典の不記載（Failing to credit sources）、宣伝資料（Promotional materials）、無責任なコミュニケーション（Irresponsible communication）に対する制限指針を新たに明記した<li>コントリビューター・コヴェナントを実際に採択・運用していたコミュニティ関係者を対象としたアンケートの回答を反映し、段階的執行基準（enforcement ladder）はあくまで一つのベースラインにすぎず、コミュニティ管理者による裁量権行使を制約しないことを明確にした<blockquote><p>This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community.</p></blockquote></ul><h3 id="平等権および差別禁止条項の強化">平等権および差別禁止条項の強化</h3><p>冒頭段落である <strong>誓約（Our Pledge）</strong> における平等権および差別禁止条項を補強し、一部の用語をより包摂的な表現に置き換え、いくつかの現代的な多様性の価値を追加で明記するなど、より具体化した。</p><ul><li>「身体の大きさ（body size）」と「個人的外見（personal appearance）」という二つの表現を、より包摂的な「身体的特徴（physical characteristics）」に置き換えた<li>「宗教（religion）」を、より包摂的な「思想または宗教（philosophy or religion）」に置き換えた<li>「国籍（nationality）」を、より包摂的な「出身国または社会的背景（national or social origin）」に置き換えた<li>「神経多様性（neurodiversity）」を追加で明記した<li>「言語（language）」を追加で明記し、非英語話者により配慮した<li>ジェンダー平等と多様性に関して全体的な文言修正を適用した<blockquote><p><strong>v2.1</strong><br /> sex characteristics, gender identity and expression, or sexual identity and orientation</p><p><strong>v3.0</strong><br /> sex or gender, gender identity or expression, sexual orientation</p></blockquote></ul><h2 id="今回の韓国語翻訳作業で考慮した点">今回の韓国語翻訳作業で考慮した点</h2><h3 id="共通の検討事項">共通の検討事項</h3><h4 id="敬体の使用">敬体の使用</h4><p>誓約および行動規範を韓国語で書くとき、敬体と常体のどちらを選ぶかは、目指す方向性、組織文化、そして伝えたい態度にかかっている。過去には権威と規律を強調する常体が主流だったが、近年では水平的で尊重し合う文化を強調するため、敬体で書く場合も多い。</p><table><thead><tr><th>文体<th>敬体（「~합니다」「~하겠습니다」）<th>常体（「~한다」）<tbody><tr><td>ニュアンス<td>相互尊重、自発的な約束、勧奨<td>断固さ、法的効力、客観的な規定<tr><td>組織文化<td>柔軟で水平的な文化<td>相対的に厳格な文化<tr><td>主な適用場面<td>行動規範、倫理宣言文<td>セキュリティ誓約書、<br />労働契約書、法的懲戒規定<tr><td>心理的効果<td>「私たちは共に守る」（自発的同意）<td>「守らなければならない」<br />（拘束性をより強調）</table><p><a href="https://github.com/EthicalSource/contributor_covenant/pull/895#pullrequestreview-563210153">過去の議論</a>を見ると、過去に 2.0 版を韓国語に移す際にも最初は敬体が検討されたものの、<a href="https://github.com/EthicalSource/contributor_covenant/commit/3971299d81149b3fc0ce603a5dd26400509f090f">常体で書き直された</a>ようである。過去の議論とその結論は尊重するが、それでも今回あらためて敬体で翻訳した理由は次のとおりである。</p><p>今日のオープンソースコミュニティの文化は、基本的に拘束、厳格さ、強制性をもつ執行などとはやや距離があり、それよりも相互尊重、自発的な参加と貢献などを志向している。<a href="#応報的正義から修復的正義へのパラダイム転換">今回のコントリビューター・コヴェナント3.0では、とりわけそのような哲学が全体に強く反映されている</a>。今回の改訂で原文が伝えようとした核心的価値と哲学、そしてコミュニティ文化や動向を考慮すると、この文章を韓国語に移す際には敬体が適切だと判断した。同様に敬体を用いている <a href="https://rust-kr.org/pages/code-of-conduct/">韓国 Rust ユーザーグループ</a> と <a href="https://pythonkr.github.io/pycon-code-of-conduct/ko/coc/a_intent_and_purpose.html">PyCon KR 行動規範（PyCon KR CoC）</a>、<a href="https://kubernetes.io/ko/community/code-of-conduct/">Kubernetes コミュニティ韓国語行動規範</a> の事例も参考にした。</p><h4 id="不要な受動表現の回避">不要な受動表現の回避</h4><p>受動態を頻繁に用いる英語と異なり、韓国語は基本的に受動表現より能動表現を好む言語である。英語原文で受動態が使われていたからといって、これを機械的に受動表現で移すと、いかにも翻訳文らしいやや不自然な文章になり、文法的にも不適切になる。</p><p>韓国語でも受動表現をまったく使わないわけではないが、文意を歪めない範囲で、原文では受動態で書かれた表現であっても、韓国語訳ではできるだけ能動表現に移すようにした。</p><p><strong>e.g.</strong></p><ul><li>“Encouraged Behaviors”: “장려<strong>되는</strong> 행동”(X), “장려<strong>하는</strong> 행동”(O)<li>“enforcement actions are carried out in private”: “집행 조치는 비공개로 진행<strong>된다</strong>“(X), “집행 조치는 비공개로 진행<strong>한다</strong>“(O)<li>“its own established enforcement process”: “자체적으로 확립<strong>된</strong> 집행 절차”(X), “자체적으로 확립<strong>한</strong> 집행 절차”(O)<li>“the following enforcement ladder may be used”: “다음의 단계적 집행 기준<strong>이 사용될</strong> 수 있습니다”(X), “다음의 단계적 집행 기준<strong>을 사용할</strong> 수 있습니다”(O)<li>“are provided at”: “에서 제공<strong>됩니다</strong>“(X), “에서 제공<strong>합니다</strong>“(O)</ul><h4 id="辞書的機械的な語の翻訳よりもその語が文章の中で使われる文脈を考慮する">辞書的機械的な語の翻訳よりもその語が文章の中で使われる文脈を考慮する</h4><p>英語と韓国語はかなり距離のある言語であるため、当然ながら単語と単語が正確に一対一で対応するわけではない。辞書上は同じ意味だとされていても、それは同じである。</p><p>たとえば、次の箇所での “intimate” は、文脈上 “친밀한” ではなく “성적인” の意味で使われている。</p><blockquote><p><strong>Sexualization.</strong> Behaving in a way that would generally be considered inappropriately <u>intimate</u> in the context or purpose of the community.</p></blockquote><p>また、次の箇所で “process” を辞書的に “처리할” と訳すと不自然である。文章の文脈上、ここでの “process” は “추스를” と移すのが適切である。</p><blockquote><p>… give the community members involved time to <u>process</u> the incident.</p></blockquote><blockquote class="prompt-tip"><p>(<a href="https://stdict.korean.go.kr/">표준국어대사전</a> 표제어 중)</p><p><strong>추스르다「3」</strong>: 일이나 생각 따위를 수습하여 처리하다.</p></blockquote><p>一方で、移しうる固有語表現がぴったり存在しない外来語もある。たとえば “community” の場合、固有語に移すなら “공동체” ほどにもできるが、英語における “community” という語のニュアンスと、韓国語における “공동체” という語のニュアンスにはかなり差があると判断した。できるだけ外来語は固有語に言い換えて書くようにしたが、このように原文の意味やニュアンスを歪めるおそれが大きいと判断した場合には “커뮤니티” のようにそのまま維持した。</p><p>このような点を考慮し、辞書的・機械的な語の単純置換作業をするのではなく、原文の意味と文脈に最も近い韓国語表現を選んで翻訳するよう努めた。</p><h4 id="そのほか韓国語の語文規範の順守">そのほか韓国語の語文規範の順守</h4><p>ハングル正書法や標準語規程など、韓国語の語文規範をできるだけ正確に守るよう努めた。</p><h3 id="서약our-pledge-段落">“서약(Our Pledge)” 段落</h3><h4 id="小見出し">小見出し</h4><p>“Our Pledge” を直訳すると “우리의 맹세” になるが、<a href="https://www.contributor-covenant.org/ko/version/2/1/code_of_conduct/">既存の韓国語訳</a>では “서약” と移されており、文章の自然さを考えても十分に許容範囲だと判断したため、今回も “서약” のまま維持した。</p><h4 id="caste-という語の翻訳">“caste” という語の翻訳</h4><p><a href="https://www.contributor-covenant.org/ko/version/2/1/code_of_conduct/">既存の 2.1 版韓国語訳</a>では、これをそのまま “카스트 제도” と訳している。caste という語には <u>世界各地の精緻に固定化された身分秩序制度</u> を指す学術的一般名詞としての意味もあるため、必ずしも誤訳とまでは言えないが、そのような詳しい背景情報が与えられていない状況で、日常的に韓国語で “카스트 제도” と言えば、大多数は「マヌ法典などに由来するインドのヒンドゥー教徒特有の身分制」と理解するため、原文の文脈を考慮して “계급” と訳した。ここでの “caste” は、特定の国家（インド）や宗教（ヒンドゥー教）に限定されず、あらゆる種類・形態の身分制とそれに伴う階級を意味すると解釈するのが妥当である。</p><h4 id="성별-대신-성-표현-사용">“성별” 대신 “성” 표현 사용</h4><blockquote><p>We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of … sex or gender, gender identity or expression, sexual orientation … or other status.</p></blockquote><p>原文が伝えようとしている価値と文脈を考えると、ここでいう “sex”, “gender”, “sexual orientation” などが意味するものは、男女二分法による区別ではないはずである。したがって、男女二分法による区分の意味をほのかに含意する “성별” ではなく “성” という語を用い、人文社会学的に sex, gender, sexuality の三語が持つ意味の差をできるだけ生かして、次のように訳した。</p><blockquote><p>… 생물학적 또는 사회적 성, 성 정체성 또는 성 표현, 성적 지향…</p></blockquote><h3 id="장려하는-행동encouraged-behaviors-および-제한하는-행동restricted-behaviors-段落">“장려하는 행동(Encouraged Behaviors)” および “제한하는 행동(Restricted Behaviors)” 段落</h3><h4 id="コロンの削除">コロン（<code class="language-plaintext highlighter-rouge">:</code>）の削除</h4><blockquote><p>With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including:</p><ol><li>Respecting the <strong>purpose of our community</strong>, our activities, and our ways of gathering.<li>Engaging <strong>kindly and honestly</strong> with others. …</ol></blockquote><p>英語原文では、完結した一文の後に例示の一覧を並べる目的で上のようにコロンを使う用法がよく見られるが、現代韓国語の語文規範では、コロンの用法は見出しの後に該当項目を挙げたり説明を付けたりする場合など、主として箇条書き調の表現に限定される。したがって、最初から箇条書き形式で書いた文章ならともかく、次のように書くのは非常に不自然であり、機械翻訳や LLM で雑に訳したという印象を与えやすい。個人的には、<a href="https://www.contributor-covenant.org/ko/version/2/1/code_of_conduct/">2.1 版の韓国語訳</a>でもかなり惜しかった点の一つである。</p><blockquote><p>이러한 점을 유념하며, 우리는 서로를 사려 깊게 대하고 우리가 공유하는 다음 가치를 중심으로 행동할 것에 동의합니다:</p><ol><li>우리 <strong>공동체의 목적</strong>, 활동 및 모임 방식을 존중합니다.<li><strong>친절하고 정직하게</strong> 다른 사람들과 소통합니다. …</ol></blockquote><p>そのため、韓国語の用法に合わせ、コロンを使っていた部分をそのままコロンで移すのではなく、ピリオド（<code class="language-plaintext highlighter-rouge">.</code>）に置き換えて自然な文章になるようにした。</p><h4 id="that-would-generally-be-considered-inappropriately-という表現の翻訳">“that would generally be considered inappropriately” という表現の翻訳</h4><p>ここで “generally” は “일반적으로” と直訳するよりも、文脈上より自然な “대부분의 사람들에게” と訳した。</p><blockquote><p>…<u>대부분의 사람들이</u> 부적절하다고 간주할 만한…</p></blockquote><h3 id="act-on-という表現の翻訳">“act on” という表現の翻訳</h3><p>当初は “act on” を単純に “이용하다” と訳すことも考えたが、文脈上、<u>意図を問わず他人の身上情報または個人的情報をもとに行う</u> あらゆる行為を禁じる内容に近く、これを “이용하다” と訳すと意味を狭めてしまうように思われたため、次のように訳した。</p><blockquote><p><strong>비밀 침해.</strong> 타인의 신상 관련 정보 또는 개인적인 정보를 당사자의 허락 없이 공유하거나, 그 정보<u>를 바탕으로 행하는</u> 모든 행위.</p></blockquote><h3 id="문제-신고reporting-an-issue-段落">“문제 신고(Reporting an Issue)” 段落</h3><ul><li>“this Code of Conduct <strong>reinforces</strong> encouraged behaviors and norms that …”: “본 행동 강령은 …는 권장 행동 방식과 규범을 <strong>증진합니다</strong>“로 번역<li>“in a timely manner”: “적시에”로 번역<li>“while prioritizing safety and confidentiality”: “안전과 비밀 유지를 우선시한다는 전제 하에”로 번역<li>“In order to <strong>honor</strong> these values”: “이들 가치를 <strong>지키기</strong> 위해”로 번역<blockquote class="prompt-tip"><p>(<a href="https://www.oxfordlearnersdictionaries.com/">Oxford Learner’s Dictionaries</a> 표제어 중)</p><p><a href="https://www.oxfordlearnersdictionaries.com/definition/english/honor_2"><strong>honor</strong></a> <em>verb</em><br /> <u>keep promise</u> 3. <strong>honor something</strong> <em>(formal)</em> to do what you have agreed or promised to do</p></blockquote></ul><h3 id="피해-대응-및-교정addressing-and-repairing-harm-段落">“피해 대응 및 교정(Addressing and Repairing Harm)” 段落</h3><ul><li>“Addressing”: “대응”으로 번역<li>“Repairing”: “교정”으로 번역</ul><h4 id="event-consequence-repair-の翻訳"><code class="language-plaintext highlighter-rouge">Event:</code>, <code class="language-plaintext highlighter-rouge">Consequence:</code>, <code class="language-plaintext highlighter-rouge">Repair:</code> の翻訳</h4><p>韓国語に移すのが微妙で、かなり悩んだ箇所である。”사건”, “결과”, “교정” と直訳すると、文章がかなり不自然になる。</p><p>自然な文章でありつつ、<a href="#応報的正義から修復的正義へのパラダイム転換">原文の哲学</a>を可能な限り損なわずに伝えるため悩んだ末、次のように訳した。</p><ul><li>“Event”: “적용 상황” と訳した。<li>“Consequence”: “대응 조치” と訳した。<li>“Repair”: 当初は “회복 조치” を検討したが、”조치” という表現は、当事者の自発的な省察と改善よりも、他者が介入して執行するというニュアンスがあり、原文の趣旨に反すると考えて退けた。最終的には “교정 노력” と訳した。</ul><h4 id="seeking-clarification-on-expectations-という表現の翻訳">“seeking clarification on expectations” という表現の翻訳</h4><p>“expectations” は “기대 사항” と直訳することもでき、そうしても意味は通るが、より滑らかな文章にするため “준수 사항” と訳した。</p><blockquote class="prompt-tip"><p>(<a href="https://www.oxfordlearnersdictionaries.com/">Oxford Learner’s Dictionaries</a> 표제어 중)</p><p><a href="https://www.oxfordlearnersdictionaries.com/definition/english/expectation"><strong>expectation</strong></a> <em>noun</em><br /> 3. [countable, usually plural] a strong belief about the way something should happen or how somebody should behave</p></blockquote><p>“seeking clarification” は “해명(clarification) 요구(seeking)” と訳すこともできるが、文脈上、修復努力（Repair）項目では問題を起こした人が取るべき望ましい事後行動と態度を記しているため、clarification, seeking をそれぞれ 해명, 요구 と訳すと意味がおかしくなる。ここでは、自ら反省し同じ過ちを繰り返さないために、<u>준수 사항</u>（expectations）を <u>명확히 확인하고 숙지하기</u>（clarification） 위한 <u>노력</u>（seeking）と訳すのが最も適切だと考えた。</p><blockquote class="prompt-tip"><p>(<a href="https://www.oxfordlearnersdictionaries.com/">Oxford Learner’s Dictionaries</a> 표제어 중)</p><p><a href="https://www.oxfordlearnersdictionaries.com/definition/english/seek"><strong>seek</strong></a> <em>verb</em><br /> 2. [transitive] to ask somebody for something; to try to obtain or achieve something</p><p><a href="https://www.oxfordlearnersdictionaries.com/definition/english/clarification"><strong>clarification</strong></a> <em>noun</em><br /> [uncountable, countable] (formal)<br /> the act or process of making something clearer or easier to understand</p><ul><li><em>I am <strong>seeking clarification of</strong> the regulations.</em></ul></blockquote><h4 id="cooldown-という表現の翻訳">“cooldown” という表現の翻訳</h4><p>辞書的には冷却、（本運動後の）クールダウン、鎮静などの意味があり、ここでは文脈上「落ち着く」「頭を冷やす」に最も近い意味で使われている。</p><p>ただし、”time-limited cooldown period” を “한시적 진정 기간” と移すと少し不自然なので、今回の韓国語訳では “cooldown period” を “자숙 기간” と訳した。</p><h4 id="time-to-process-the-incident-という表現の翻訳">“time to process the incident” という表現の翻訳</h4><p><a href="#辞書的機械的な語の翻訳よりもその語が文章の中で使われる文脈を考慮する">前述のとおり</a>、”해당 일을 추스를 시간” と訳した。</p><h4 id="suspension-および-ban-という表現の翻訳">“suspension” および “ban” という表現の翻訳</h4><p><a href="https://www.contributor-covenant.org/ko/version/2/1/code_of_conduct/">既存の 2.1 版韓国語訳</a>では “ban” を “제재” と訳していたが、제재 とは下位段階である警告や一時的活動制限など、違反行為に対して取りうるあらゆる措置を包括する意味であるため、何を指すかが曖昧である。そして英単語 “ban” はその意味が停止する、禁止するで明確であるうえ、「（アカウントなどの）永久停止」という表現は韓国語でも日常的によく使う自然な表現なので、あえてこれを避けて意訳する理由もないと考えた。</p><p>“suspension” も同様で、停職、停学など「停止」という意味が明確であり、あえて意訳する必要がない。</p><p>したがって “Temporary Suspension”, “Permanent Ban” は、それぞれ “일시적 정지”, “영구 정지” と訳した。</p><h4 id="this-enforcement-ladder-is-intended-as-a-guideline-という文の翻訳">“This enforcement ladder is intended as a guideline.” という文の翻訳</h4><p>“enforcement ladder” という表現は “단계적 집행 기준” と訳した。またこの文は、上述した段階的執行基準が、あくまで複数ある選択肢の一つとして提示されるものであり、コミュニティ管理者の裁量と決定権を保障するという文脈で使われているため、冠詞 “a” を “하나의” と訳した。そこで翻訳文では次のように書いた。</p><blockquote><p><u>이 단계적 집행 기준은 하나의 기준선으로 마련한 것입니다.</u> 이는 커뮤니티의 최선의 이익에 부합하는 커뮤니티 관리자의 재량권과 판단 권한을 제한하지 않습니다.</p></blockquote><h2 id="おわりに">おわりに</h2><p>この種の公益的性格をもつ文書やプロジェクトの多くは、ボランティアやコントリビューターによって複数言語への翻訳作業が進められることが少なくない。しかし残念ながら、韓国語訳の場合はコントリビューターがいなくて翻訳版そのものが存在しなかったり、存在していても機械的に訳したことが見て取れる不自然な文章であったりして、韓国人であるにもかかわらず「いっそ英語で読んでしまおう」と思って英語ページに切り替えた経験が少なからずあった。</p><p>今回、韓国語翻訳への貢献を決めて作業しながら、どうせ貢献するなら、読む人が「韓国人の著者が最初から韓国語で書いた文章だ」と言われても違和感を覚えない程度の、質の高い翻訳文を出したいと努めた。原文が込めた哲学と微妙な文脈、特に既存の 2.1 版に比べて今回の 3.0 版ではどのような表現が変わっており、原著者たちがなぜそのような選択をしたのかを理解し、それを訳文に溶け込ませようと考えた。</p><p>自然言語の性質上、翻訳というものは、同じ原文を入力として与えられたからといって関数のように同じ出力が出てくるものではない。翻訳者ごとに少しずつ異なる訳が出てくるものであり、これは翻訳者の力量も力量だが、本質的には唯一の定まった正解がない翻訳、ひいては作文という営みの性質に由来する。最近の私は、ほとんどあらゆる作業に AI を補助的に活用しており、今このブログの記事さえ LLM API をつないで複数言語に自動翻訳・公開している。しかし今回のこの作業だけは、本当に気合いを入れてきちんとした、自分にできる最善の翻訳をしたいと思った。一つ一つの表現を自分で何度も見直し、どの表現を使えば原文の意味を最も歪めず、しかも自然に盛り込めるかを考え、その結果として、自分の主観的ではあるが最善の判断と解釈を反映した訳を出した。誰も彼もが AI を活用する今、少なくともこのような誓約や行動規範のような重要文書の翻訳においては、AI に原文をそのまま投げて訳してもらった結果物に対して比較優位があってこそ、翻訳版としての価値があると信じている。少なくとも 12026年3月時点の現在、機械翻訳や LLM では十分に生かしきれない原文の微妙なニュアンスや文脈などを、<a href="https://github.com/EthicalSource/contributor_covenant/pull/1590">今回の翻訳版</a>では十全に保存できたと自負している。</p><p>12026年3月20日現在、コントリビューター・コヴェナント 3.0 版は、英語原文と今回私が提出するこの韓国語訳を除けば、ベンガル語、ドイツ語、中国本土の中国語のわずか3言語でしか翻訳が完了しておらず、<a href="https://github.com/EthicalSource/contributor_covenant/pulls">開いている PR の一覧</a>を見ると、翻訳版の草案が PR として提出されてはいるものの、レビューアがいないため最終承認に至っていない言語も多い。3.0 版どころか、いまだに 1.4 版にとどまっている言語もかなり多い。どのような理由であれこの文章を読む韓国語以外の言語話者がいるなら、<a href="https://github.com/EthicalSource/contributor_covenant?tab=contributing-ov-file#translators-and-native-speakers">貢献方法はそれほど複雑ではないので</a>、週末などに1日ほど時間を取って貢献してくれれば、きっと OES とその言語の利用者たちに大きな助けになるだろう。私もこのような翻訳作業に貢献した経験も、行動規範全文を通読したのも今回が初めてだったが、数時間ほど時間をかける価値は十分にある作業だったと思う。韓国は総人口に比べて GitHub などのオープンソースコミュニティで活発に活動する開発者数がかなり多い国に属するが、それだけに、今回翻訳して提出したコントリビューター・コヴェナント 3.0 行動規範の <a href="https://github.com/EthicalSource/contributor_covenant/pull/1590">韓国語訳版</a> についても、ほかの韓国の方々がレビューに参加し、さらにできれば多くの方々にさまざまな場所で有用に採択・活用してもらえればうれしい。</p><p><a href="https://ethicalsource.dev/blog/contributor-covenant-3/">OES のブログ記事</a>で引用されている <strong>ネイサン・シュナイダー（Nathan Schneider）教授</strong> の言葉のとおり、コントリビューター・コヴェナント（Contributor Covenant）は、責任ある透明なコミュニティを構築するうえで不可欠な土台として機能し、実際に対立の解消にも寄与してきた。慣例的に GitHub などで “Add a code of conduct” ボタンを押してテンプレートを貼り付けることが多いだろうが、GitHub が自動提供するテンプレートは、なぜか 2.0 版を最後に更新されていない。3.0 版は、従来の 2.0、2.1 版に比べて大きな変化と改善があったので、せっかくなら <a href="https://www.contributor-covenant.org/adopt/">公式ページ</a> を通じて最新版本を採択してみてはどうかと勧めたい。内容も実際にはそれほど長くないので、その過程で一度くらい全文をじっくり読んでみれば、なおさら意味があると思う。コントリビューター・コヴェナント 3.0 行動規範と、今回作業した <a href="https://github.com/EthicalSource/contributor_covenant/pull/1590">韓国語訳版</a> に多くの関心を寄せてもらえることを願い、ここで筆を置く。</p>]]> </content> </entry> <entry><title xml:lang="ja">IR資料の作り方（How to Prepare IR Materials）</title><link href="https://www.yunseo.kim/ja/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/how-to-prepare-ir-materials/" rel="alternate" type="text/html" hreflang="am" /><published>2026-01-11T00:00:00+09:00</published> <updated>2026-01-11T00:00:00+09:00</updated> <id>https://www.yunseo.kim/ja/posts/how-to-prepare-ir-materials/</id> <author> <name>Yunseo Kim</name> </author> <category term="Startup" /> <category term="IR" /> <summary xml:lang="ja">IR資料とは何かを理解し、投資誘致を成功させるために、良いIR資料に盛り込むべき内容を整理する。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>IR資料とは何かを理解し、投資誘致を成功させるために、良いIR資料に盛り込むべき内容を整理する。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="ir資料とは">IR資料とは？</h2><p><strong>IR</strong>は<strong>Investor Relations</strong>の略であり、投資家に向けて企業を説明・PRし、関係を構築して投資を呼び込むために必要なあらゆる資料と活動を包括的に指す用語である。IR資料という場合、一般には資金調達のために企業が投資家へ提示する紹介資料を意味する。</p><h2 id="ir資料に入れるべき内容">IR資料に入れるべき内容</h2><p>IR資料の目的は投資誘致であるため、投資家の視点から「なぜこの会社に投資すべきか」を説得力をもって示す必要がある。したがって、サービス概要、市場環境、製品/サービス説明、競争環境、実績、事業モデル、今後の成長計画、チーム構成など、事業全体に関わる内容を含めるべきである。</p><ul><li><strong>ピッチデック（Pitch Deck）</strong>:<ul><li><strong>短く強く</strong>、幅広い潜在投資家に<strong>ポジティブな第一印象</strong>を残すことが目的<li>初期段階の資金調達で使用<li>スライド10〜15枚程度で、簡潔かつ視覚的な資料中心で構成</ul><li><strong>IRデック（IR Deck）</strong>:<ul><li>会社の<strong>深い財務情報と長期戦略</strong>を提供<li>ある程度関心を示し始め、意思決定を控えた専門投資家に提供<li>投資家が<strong>より深い評価と判断</strong>を下せるようにする<li>スライド20〜30枚程度で、より具体的な<strong>財務計画、市場分析、チーム構成、競合分析</strong>など詳細情報を提供</ul></ul><h3 id="ミッションビジョンmissionvision">ミッション/ビジョン（Mission/Vision）</h3><ul><li>当社が提供しようとする本質的な価値は何か？</ul><blockquote class="prompt-tip"><p>会社の核となるアイデンティティと言える部分であり、IR資料の最初に、当社のミッションとビジョンをそれぞれ1文で、簡潔かつ明確に表現するのがよい。</p></blockquote><h3 id="サービス概要">サービス概要</h3><h4 id="課題problem">課題（Problem）</h4><ul><li>当該サービスが解決しようとする市場の課題は何か？<li>消費者はその課題をどれほど不便だと感じているか？<li>その課題はなぜ重要なのか？<li>課題解決への需要はあるか？ターゲットは誰か？</ul><h4 id="ソリューションsolution">ソリューション（Solution）</h4><ul><li>先に述べた課題を具体的にどう解決するのか？<li>既存手法と比べて、消費者および最終ユーザーが得られる利点は何か？</ul><blockquote class="prompt-tip"><p>投資家が当該分野の専門家でないケースも多いため、開発者の視点ではなく消費者の視点でサービスを説明し、技術的な詳細は後で質問が来た場合などに個別対応するのがよい。</p></blockquote><h3 id="市場規模market-size">市場規模（Market Size）</h3><p>市場規模を金額で直接設定すると、算出方法や複数の変数によって結果が大きく変わり得るうえ、反論が出るリスクも比較的大きい。<br /> 潜在ユーザー数、取引回数/頻度などの別指標を設定して提示すると、より安全かつ効果的に市場規模を示せる。</p><ul><li><strong>TAM（Total Addressable Market, 全体市場）</strong>: すべての競合を排除して世界市場シェア100%を達成するという理想的状況を仮定し、製品・サービスを全世界に提供する場合に理論的に到達可能な最大市場規模<li><strong>SAM（Service Available Market, 有効市場）</strong>: 地理的・インフラ的・規制的制約を考慮したうえで現実的にサービス提供が可能で、当社が実際に狙う範囲の市場規模<li><strong>SOM（Service Obtainable Market, 収益市場）</strong>: 競争環境、会社の実行能力、マーケティング戦略などを考慮したとき、SAMの中でも初期に実際に獲得できる市場規模</ul><blockquote class="prompt-tip"><p>市場規模を推計する際、全体市場や有効市場の規模については第三者の市場調査資料を引用して具体的な数値・指標を示しつつ、肝心のスタートアップにとって当面重要な収益市場規模については「当該市場でシェアを何%達成すれば売上はいくらになる」という形で説明することが多い。正直に言うと、私も起業準備を始めた頃に社内で最初に作ったIR資料のドラフトでは、このように書いていた。</p><p>しかしこのやり方の問題は、投資家の立場からすると「市場の何%を取るか」という計画は信頼しにくい点にある。サービスを出したからといって簡単に市場を獲れるわけでもなく、漠然と当該市場の全構成員を対象にシェア何%を達成すると言っても説得力に欠ける。</p><p>狙う全体市場および有効市場が十分大きいことを示すと同時に、<strong>初期顧客層（Immediate Market）</strong>をどう捉えているか、そしてその後どの顧客層を段階的に追加攻略して収益市場を拡大していくのか、その論理を提示することが重要である。</p></blockquote><blockquote class="prompt-tip"><p><strong>事業タイミング</strong></p><ul><li>事業においてタイミングも非常に重要<li>なぜ「今」この事業がうまくいき得るのか、なぜ「今」投資すべきなのかを投資家に説明できなければならない<li>技術的実現可能性、人々の行動様式の変化、社会的潮流、環境変化など、今この事業を実行するのに適している理由を提示すべき</ul></blockquote><h3 id="製品サービス説明product">製品/サービス説明（Product）</h3><ul><li>製品/サービスの主要な特徴・機能は何か？<li>具体的な動作方式、例は何か？</ul><h3 id="事業モデルbusiness-model">事業モデル（Business Model）</h3><ul><li>どのように収益を得るのか？<li>誰が支払うのか？（最終ユーザーと支払者が常に一致するとは限らないため、実際に売上を発生させる顧客が誰かを明確にすべき）<li>どこを課金するのか？価格設定はどうするのか？</ul><h3 id="競争環境competition">競争環境（Competition）</h3><ul><li>主要な競合は誰か？<li><strong>顧客の視点で</strong>、他社のサービス/製品に比べて当社のサービス/製品がどの点で優れており、どんな強みがあるか？<li>どのサービスを競合サービスと定め、どの顧客を主要ターゲットとするのか？</ul><blockquote class="prompt-tip"><p>競合をきちんと分析してこそ、投資家に対して市場状況を把握していることを効果的にアピールできる。</p></blockquote><h3 id="実績および市場参入戦略go-to-market-strategy">実績および市場参入戦略（Go-to Market Strategy）</h3><ul><li>事業成功において最も重要なKPIは何か？<ul><li>e.g. 注文件数、月間アクティブユーザー（MAU）、月間取扱高 など</ul><li>その指標を中心に、どのような実績があったか？<li>会社の主要なマーケティング手段・チャネルは？<li>新規顧客獲得の手段とコストはいくらか？<li>*<strong>顧客生涯価値（LTV）</strong>はいくらか？</ul><blockquote class="prompt-info"><p>*<strong>顧客生涯価値（Customer Lifetime Value, LTV）</strong>: 1人のユーザーが当該サービスを利用する全期間にわたって、総額いくらの利益をもたらすかを数値化したもの</p></blockquote><blockquote class="prompt-tip"><p>KPI以外の付随的な指標は除くのがよい。</p></blockquote><blockquote class="prompt-tip"><p><strong>まだ売上のない超初期フェーズのスタートアップであれば</strong></p><ul><li>提供したいサービスの<strong>損益分岐点</strong>を設定して提示<li>このとき収益関連指標を盛らず、保守的な観点で現実的に設定すべき<li>収益発生初年度の収益シナリオを提示し、その後数年間の売上計画を添えて、実際に継続成長できる確信を与えるのがよい<ul><li>1年の短期予測<li>3年の中期予測<li>5年の長期予測</ul><li>内容を一目で確認できるよう、グラフや表を積極的に活用<li><strong>仮説検証スライド</strong>を含め、なぜそのKPIと売上シナリオを設定したのかを説得力をもって提示し、根拠を強化するのがよい<ul><li>複数回の実験と仮説検証を通じて、想定売上シナリオに対する堅固な根拠を用意すべき</ul></ul></blockquote><h3 id="チーム構成the-team">チーム構成（The Team）</h3><ul><li>全員を紹介するのではなく、代表自身を含め、核心的役割を担う主要メンバー中心に紹介<li>経歴・スキルは2〜3個程度に絞り、ロゴ等を活用して可読性よく提示<li>重要な役割を果たしてくれた/果たしている投資家や顧問がいれば、併せて記載するのもよい</ul><h3 id="今後の成長計画milestones">今後の成長計画（Milestones）</h3><ul><li>時期別・フェーズ別に達成したい目標を提示<li>次の投資ラウンドまでの目標を設定するのが一般的（シードならシリーズA前まで、シリーズAならシリーズB前まで）<li>希望調達額と資金使途を提示<li>このとき、区分単位を半年以上のように長く取りすぎず、2か月程度の単位で区切って提示</ul><h3 id="財務計画financials">財務計画（Financials）</h3><p>IRデックの場合、財務計画を含める必要がある。</p><ul><li>今後3〜5年の財務計画表<li><strong>ユニットエコノミクス（Unit Economics）</strong>: 顧客単位あたりの収入とコスト<li><strong>バーンレート（Burn rate）</strong>: スタートアップにおける現金支出（創業費、研究開発費、その他費用など）のペース/比率<li>総収入と総費用<li>EBITDAまたはキャッシュフロー計算書 など</ul><blockquote class="prompt-warning"><ul><li>非現実的な財務計画を提示しないよう注意すべき<li>予想売上は過大評価、必要コストは過小評価しがちなので、予想売上規模の算定は慎重に行うべき<li>必要コストは製品/サービス開発費および運営費などを考慮し、可能な限り正確に見積もる</ul></blockquote><h2 id="投資ステージ別に強調すべきポイント">投資ステージ別に強調すべきポイント</h2><h3 id="シード">シード</h3><ul><li>MVPを開発して市場反応を確認し、事業モデルの妥当性を検証する段階<li>初期仮説と事業モデル検証結果、MVP実験結果とそれに伴う売上を集中的に強調すべき</ul><h3 id="pre-a">Pre-A</h3><ul><li>成長可能性を証明し、プロダクト開発・マーケティング・採用などに必要な追加資金を確保すべき段階<li>事業の主要KPIは何か、どのような活動を通じてどれだけ成長しているか、今後の成長可能性についての説明が必要</ul><h3 id="シリーズa">シリーズA</h3><ul><li>本格的に成長し、企業価値を高めていく段階<li>この時点では仮説検証が終わっているべきであるため、事業成果の定量的結果で投資家の信頼を獲得すべき</ul><h2 id="いくつかのtips">いくつかのTips</h2><ul><li>最初の5枚は特に力を入れ、第一印象をポジティブにできるようにする<li>1枚目のミッション/ビジョンは最終スライドにもう一度入れるのもよい<li>すべての内容は結論ファーストで伝える<li>投資対象は<strong>会社</strong>であるため、IR資料でもサービス名より会社名を優先する<li>IR資料を読む潜在投資家は業界関係者とは限らないため、できるだけ易しい用語で噛み砕いて説明し、やむを得ず専門用語を使う場合は補足説明を付ける<li>市場課題とソリューションは混同せず分ける<li>テキストはキーワード中心にし、画像を使う場合はスクリーンショットの多用を避けて可読性を高める<li>正確かつ具体的な数値は表やグラフで記載する<li>チーム紹介、希望調達額と資金使途を漏らさないよう注意する<li>投資回収戦略も併せて提示するとよい<li>株主構成比率の計画も、完璧でなくても簡潔に提示する<li>本文に資料を詰め込みすぎず、必要なら別添資料として分ける<li>最終スライドには連絡先（メール、電話番号、氏名）を記載する<li>フォントも非常に重要なので、<a href="https://cactus.tistory.com/306">Pretendard</a>など可読性の高いフォントを使い、崩れないようPDFで用意する</ul><h2 id="参考資料">参考資料</h2><h3 id="企業開示チャネル-kind">企業開示チャネル KIND</h3><p><a href="https://kind.krx.co.kr/corpgeneral/irschedule.do?method=searchIRScheduleMain&amp;gubun=iRMaterials">https://kind.krx.co.kr/corpgeneral/irschedule.do?method=searchIRScheduleMain&amp;gubun=iRMaterials</a></p><ul><li>韓国取引所が運営する企業開示チャネル<li>KOSPI、KOSDAQ、KONEXに上場する企業の開示情報を提供<li>上場企業のIR資料を確認でき、最近作成された他社IR資料の構成方法を確認できる</ul>]]> </content> </entry> <entry><title xml:lang="ja">暗号学の基本概念</title><link href="https://www.yunseo.kim/ja/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/basic-concepts-of-cryptography/" rel="alternate" type="text/html" hreflang="am" /><published>2025-11-26T00:00:00+09:00</published> <updated>2025-11-26T00:00:00+09:00</updated> <id>https://www.yunseo.kim/ja/posts/basic-concepts-of-cryptography/</id> <author> <name>Yunseo Kim</name> </author> <category term="Dev" /> <category term="Cryptography" /> <summary xml:lang="ja">暗号学とは何かを理解し、対称鍵暗号・非対称鍵暗号、ケルクホフスの原則など、現代暗号の基本的な概念と役割を概観する。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>暗号学とは何かを理解し、対称鍵暗号・非対称鍵暗号、ケルクホフスの原則など、現代暗号の基本的な概念と役割を概観する。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="暗号学とは">暗号学とは</h2><p><strong>暗号学（cryptography）</strong>とは本質的には、敵対的な行為から<strong>プロトコル（protocol）</strong>を防御することを目的とする、科学の一分野である。</p><p>ここで言うプロトコルとは、1人以上の人間が何かを達成するために従うべき手順のリストである。たとえば、デバイス間でクリップボードを共有したいとしよう。次のような手順は、クリップボード共有のためのプロトコルの一例である。</p><ol><li>いずれかのデバイスでクリップボードに変更があったら、その内容をコピーしてサーバにアップロードする。<li>サーバは、共有クリップボードに変更があったことを他のデバイスに通知する。<li>他のデバイスは、その共有クリップボードの内容をサーバからダウンロードする。</ol><p>ただし、これは良いプロトコルとは言えない。クリップボードの内容を平文のままサーバにアップロードし、またダウンロードする場合、通信の途中で第三者が、あるいはサーバ運営側がその内容を盗み見ることができてしまうからである。ここで、クリップボードの内容を盗み見ようとする敵の存在を考慮し、防御することが暗号学の役割である。</p><h2 id="対称鍵暗号">対称鍵暗号</h2><h3 id="対称鍵暗号化">対称鍵暗号化</h3><blockquote><p>アリス（Alice）がボブ（Bob）に手紙を送らなければならない状況を考えよう。アリスはボブに機密情報を伝えるため、伝令（messenger）に手紙を持たせて届けるよう命じる。 しかしアリスは伝令を完全には信頼しておらず、伝えるメッセージが、手紙を運ぶ伝令を含めてボブ以外のすべての人に対して秘密に保たれることを望んでいる。</p></blockquote><p>このような状況で使うために昔から発明されていた暗号アルゴリズムが、まさに<strong>対称鍵暗号アルゴリズム（symmetric encryption algorithm）</strong>である。</p><blockquote class="prompt-info"><p><strong>プリミティブ（primitive）</strong><br /> プリミティブ（primitive）という単語は、辞書的には「原始的な」「原始的なもの」という意味を持つ。 暗号学でもこのプリミティブという用語がよく使われるが、ここでのプリミティブとは、暗号システムを構成する最小単位の関数やアルゴリズムを意味する。 「基本要素」「基盤となるロジック」といった程度に捉えることができる。</p></blockquote><p>次の2つの関数を提供するあるプリミティブを考えてみよう。</p><ul><li><code class="language-plaintext highlighter-rouge">ENCRYPT</code>: <strong>秘密鍵（secret key）</strong>（通常は大きな数）と<strong>メッセージ（message）</strong>を入力として受け取り、一連の数列を暗号化されたメッセージとして出力する関数<li><code class="language-plaintext highlighter-rouge">DECRYPT</code>: <code class="language-plaintext highlighter-rouge">ENCRYPT</code> の逆関数で、同じ秘密鍵と暗号化されたメッセージを入力として受け取り、元のメッセージを出力する関数</ul><p>このような暗号プリミティブを用いて、伝令を含む第三者がアリスのメッセージを読めないよう隠すには、まずアリスとボブが事前に会って、どの秘密鍵を使うかを決めておく必要がある。その後、アリスは <code class="language-plaintext highlighter-rouge">ENCRYPT</code> 関数を使い、取り決めた秘密鍵でメッセージを暗号化し、この暗号化されたメッセージを伝令を介してボブに届ける。ボブは同じ秘密鍵を使って <code class="language-plaintext highlighter-rouge">DECRYPT</code> 関数を適用し、元のメッセージを得る。</p><p>このように秘密鍵を用いて対象を暗号化し、見た目には意味のないノイズと区別がつかないようにする過程は、暗号学においてプロトコルを保護する一般的な方法である。</p><p>対称鍵暗号化は、<strong>対称鍵暗号（symmetric cryptography）</strong>あるいは<strong>秘密鍵暗号（secret key cryptography）</strong>と呼ばれる、より大きなカテゴリの暗号アルゴリズムに属し、場合によっては鍵が2つ以上になることもある。</p><h2 id="ケルクホフスの原則">ケルクホフスの原則</h2><p>今日の私たちは、紙の手紙よりはるかに強力な通信手段であるコンピュータとインターネットを使って、ほぼリアルタイムにやり取りできる。しかし、言い換えれば悪意ある「伝令」もまた強力になったということでもある。それはカフェなどの安全でない公共Wi‑Fiかもしれないし、通信事業者（ISP）をはじめインターネットを構成しメッセージを伝達するさまざまな通信機器やサーバ、政府機関、さらにはアルゴリズムを実行している自分自身のデバイスの中に潜んでいるかもしれない。敵はより多くのメッセージをリアルタイムに観察し、気づかれないようナノ秒単位でメッセージを改ざん・盗聴・検閲できる。</p><p>長年の試行錯誤を経て、信頼できる安全性を備えるための大原則が導かれた。それは、<u>プリミティブを公開の場で分析しなければならないということである</u>。これと対比される方法論は<strong>秘匿による安全性（security by obscurity）</strong>と呼ばれ、その限界は明らかであり、今日では廃れている。</p><p>この大原則を初めて定式化したのは、11883年にオランダの言語学者かつ暗号研究者であったオーギュスト・ケルクホフス（Auguste Kerckhoffs）であり、<strong>ケルクホフスの原則（Kerckhoffs’s principle）</strong>と呼ばれる。同じ原則を、アメリカの数学者・計算機科学者・暗号研究者であり情報理論の父であるクロード・シャノンは「敵はシステムを知っている（The enemy knows the system）」、すなわち「システムを設計する際には、そのシステムが敵に把握されると仮定しなければならない」と表現した。これは<strong>シャノンの格言（Shannon’s maxim）</strong>と呼ばれる。</p><p>暗号方式の安全性は鍵の秘匿性のみに依存すべきであり、暗号方式自体が知られても問題があってはならない。むしろAESの例のように積極的に公開し、多くの<strong>暗号解析者（cryptanalyst）</strong>によって検証されるようにしなければならない。秘密というものは常に漏洩の危険があり、したがって潜在的な故障点となるため、秘密として保持しなければならない部分が小さければ小さいほど、防御側にとって有利である。暗号方式のような大きく複雑なシステム全体を長期間秘密に保つことは非常に難しいが、鍵だけを秘密に保つことは比較的容易だからである。さらに、仮に秘密が漏洩したとしても、暗号方式全体を入れ替えるよりも、漏洩した鍵だけを新しい鍵に差し替えるほうがはるかに簡単である。</p><h2 id="非対称鍵暗号">非対称鍵暗号</h2><p>多くのプロトコルは、実際には対称鍵暗号に基づいて動作している。しかしこの方式は、鍵を決めるために参加者2人が最初に一度は直接会わなければならないことを前提としている。そのため、事前に鍵をどのように決定し、安全に共有するかが問題となり、これを<strong>鍵配布（key distribution）</strong>と呼ぶ。鍵配布問題は長らく難題であったが、11970年代後半に<strong>非対称鍵暗号（asymmetric cryptography）</strong>あるいは<strong>公開鍵暗号（public key cryptography）</strong>と呼ばれる暗号アルゴリズムが開発されて、ようやく解決された。</p><p>代表的な非対称鍵暗号プリミティブとして、<strong>鍵共有（key exchange）</strong>、<strong>非対称鍵暗号化（asymmetric encryption）</strong>、<strong>電子署名（digital signature）</strong>がある。</p><h3 id="鍵共有">鍵共有</h3><p><strong>鍵共有</strong>は概略的には次のように動作する。</p><ol><li>アリスとボブが、あるパラメータ集合 $G$ を共通に使うことに合意する。<li>アリスとボブが、それぞれが用いる<strong>秘密鍵（private key）</strong> $a, b$ を決める。<li>アリスとボブは、はじめに合意した共通パラメータ $G$ にそれぞれの秘密鍵 $a$, $b$ を組み合わせて<strong>公開鍵（public key）</strong> $A = f(G,a)$, $B = f(G,b)$ を計算し、それを公開の場で共有する。<li>アリスはボブの公開鍵 $B = f(G,b)$ と自分の秘密鍵 $a$ を使って $f(B,a) = f(f(G,b),a)$ を計算し、ボブも同様にアリスの公開鍵 $A = f(G,a)$ と自分の秘密鍵 $b$ を使って $f(A,b) = f(f(G,a),b)$ を計算する。<li>ここで $f(f(G,a),b) = f(f(G,b),a)$ という性質を持つ適切な $f$ を用いれば、最終的にアリスとボブは同じ秘密を共有することになる。一方で第三者は $G$ と公開鍵 $A = f(G,a)$, $B = f(G,b)$ を知っているものの、それだけでは $f(A,b)$ を求めることができないため、秘密は保たれる。</ol><p>通常は、このようにして共有した秘密を<a href="#対称鍵暗号化">対称鍵暗号化</a>の秘密鍵として用い、その後のメッセージのやり取りに利用する。</p><p>最初に発表され、かつ最も代表的な鍵共有アルゴリズムは、考案者2人の姓であるディフィー（Diffie）とヘルマン（Hellman）にちなみ命名されたディフィー–ヘルマン鍵共有アルゴリズムである。</p><p>しかし、ディフィー–ヘルマン鍵共有にも限界がある。攻撃者が公開鍵共有の段階で、公開鍵 $A = f(G,a)$, $B = f(G,b)$ を途中で傍受し、自分のもの $M = f(G,m)$ に差し替えてアリスとボブに渡す状況を考えよう。この場合、アリスと攻撃者は偽の秘密 $f(M, a) = f(A, m)$ を、ボブと攻撃者は別の偽の秘密 $f(M, b) = f(B, m)$ を共有することになる。こうなると、攻撃者はアリスの前ではボブのふりをし、ボブの前ではアリスのふりをすることができる。このような状況を<u><strong>中間者（man-in-the-middle, MITM）</strong></u>がプロトコルの攻撃に成功したと言う。このため鍵共有は信頼性の問題自体は解決せず、あくまで参加者が多い場合に手続きを単純化する効果を持つにとどまる。</p><h3 id="非対称鍵暗号化">非対称鍵暗号化</h3><p>ディフィー–ヘルマン鍵共有アルゴリズムの発明の後、すぐに後続の発明がなされた。それが、発明者であるロナルド・リベスト（Ronald Rivest）、アディ・シャミア（Adi Shamir）、レナード・アデルマン（Leonard Adleman）の姓の頭文字を取って命名された<strong>RSAアルゴリズム（RSA algorithm）</strong>である。RSAは公開鍵暗号化（非対称鍵暗号化）と電子署名という2つのプリミティブを含み、どちらも非対称鍵暗号の一部である。</p><p><strong>非対称鍵暗号化</strong>の場合、機密性を確保するためメッセージを暗号化するという基本的な目的は<a href="#対称鍵暗号化">対称鍵暗号化</a>と似ている。しかし、暗号化と復号の両方に同じ共通鍵を用いる対称鍵暗号化とは異なり、非対称鍵暗号化は次のような特徴を持つ。</p><ul><li>公開鍵と秘密鍵という2種類の鍵で動作する。<li>誰でも公開鍵を使って暗号化できるが、復号できるのは秘密鍵を持つ人だけである。</ul><ol><li>誰でも中にメッセージを入れて施錠できるが、一度鍵をかけるとボブが持つ鍵（秘密鍵）でしか開けられない開いた箱（公開鍵）が存在する。<li>アリスは送りたいメッセージを箱に入れて鍵をかけ（暗号化し）、ボブに送る。<li>ボブは、鍵のかかった箱（暗号化されたメッセージ）を受け取り、自分の持つ鍵（秘密鍵）で箱を開けてメッセージを取り出す（復号する）。</ol><h3 id="電子署名">電子署名</h3><p>RSAは非対称鍵暗号化だけでなく<strong>電子署名</strong>も提供する。この電子署名プリミティブは、アリスとボブの間の信頼構築に非常に大きく貢献した。メッセージに署名するときには自分の秘密鍵を用い、他者がその署名の真偽を確認するときには、署名付きメッセージと署名、そして署名者の公開鍵を使って検証する、という形で動作する。</p><h2 id="暗号学の効用">暗号学の効用</h2><p>暗号学の目的は敵対的な行為からプロトコルを保護することであるから、そのプロトコルが達成しようとする目標が何かによって、暗号学の効用が決まる。ほとんどの暗号プリミティブやプロトコルは、次のうち1つ以上の性質を持つ。</p><ul><li><strong>機密性（confidentiality）</strong>: 見てはいけない人から、情報の一部を隠し保護する。<li><strong>認証（authentication）</strong>: 会話相手を識別する（例: 受け取ったメッセージが本当にアリスから送られたものか確認する）。</ul><h2 id="暗号学エコシステム">暗号学エコシステム</h2><pre><code class="language-mermaid">flowchart TD
    Alice[暗号研究者]-- プリミティブ発明 --&gt;Primitive(新しいプリミティブの提案)
    Alice-- プロトコル発明 --&gt;Protocol(新しいプロトコルの提案)
    Alice-. コンテスト開催 .-&gt;C(アルゴリズムコンテスト)

    David[民間産業界]-. 資金提供 .-&gt;Alice
    David-. コンテスト開催 .-&gt;C

    Eve[政府機関]-. 資金提供 .-&gt;Alice
    Eve-. コンテスト開催 .-&gt;C

    Primitive --&gt; t1{"実装可能か？"}
    t1-- はい --&gt;Protocol
    t1-- いいえ --&gt;term1@{ shape: framed-circle, label: "Stop" }

    Protocol-- コンテスト参加 --&gt;C
    Protocol-- 標準化 --&gt;Standard(標準)
    Protocol-- 特許出願 --&gt;Patent(特許の有効期限切れ)
    Protocol-- 実装 --&gt;Library(ライブラリ)
    
    C-- コンテスト勝利 --&gt;Standard
    C-- 淘汰 --&gt;term2@{ shape: framed-circle, label: "Stop" }

    Standard-- 実装 --&gt;Library
    Standard-- 淘汰 --&gt;term3@{ shape: framed-circle, label: "Stop" }

    Patent-- 淘汰 --&gt;term2@{ shape: framed-circle, label: "Stop" }
    Patent-- 標準化 --&gt;Standard
    Patent-- 実装 --&gt;Library

    Library-- 標準化 --&gt;Standard
    Library-- セキュリティ破り --&gt;term4@{ shape: framed-circle, label: "Stop" }
</code></pre>]]> </content> </entry> <entry><title xml:lang="ja">線形変換、零空間、像</title><link href="https://www.yunseo.kim/ja/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/linear-transformation-nullspace-and-image/" rel="alternate" type="text/html" hreflang="am" /><published>2025-09-18T00:00:00+09:00</published> <updated>2025-09-18T00:00:00+09:00</updated> <id>https://www.yunseo.kim/ja/posts/linear-transformation-nullspace-and-image/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Linear Algebra" /> <summary xml:lang="ja">線形変換の定義を概観し、関連する2つの重要な部分空間である零空間（null space）と像（image）、それらの次元（ヌルティとランク）、次元定理や単射・全射との同値条件、基底との関係まで解説します。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>線形変換の定義を概観し、関連する2つの重要な部分空間である零空間（null space）と像（image）、それらの次元（ヌルティとランク）、次元定理や単射・全射との同値条件、基底との関係まで解説します。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/vectors-and-linear-combinations/">ベクトルと線形結合</a><li><a href="/ja/posts/vector-spaces-subspaces-and-matrices/">ベクトル空間、部分空間、そして行列</a><li><a href="posts/linear-dependence-and-independence-basis-and-dimension/">線形従属と線形独立、基底と次元</a><li>単射、全射</ul><h2 id="線形変換">線形変換</h2><p>ベクトル空間の構造を保存する特別な関数を<strong>線形変換（linear transformation）</strong>といい、これは純粋数学、応用数学、社会科学、自然科学、そして工学を通じて非常に頻出する重要な概念である。</p><blockquote class="prompt-info"><p><strong>定義</strong><br /> $\mathbb{V}$ と $\mathbb{W}$ が $F$-ベクトル空間とする。すべての $\mathbf{x}, \mathbf{y} \in \mathbb{V},\ c \in F$ に対して次の 2 条件を満たす関数 $T: \mathbb{V} \to \mathbb{W}$ を、$\mathbb{V}$ から $\mathbb{W}$ への<strong>線形変換（linear transformation）</strong>という。</p><ol><li>$T(\mathbf{x}+\mathbf{y}) = T(\mathbf{x}) + T(\mathbf{y})$<li>$T(c\mathbf{x}) = cT(\mathbf{x})$</ol></blockquote><p>$T$ が線形変換であることを簡潔に「$T$ は<strong>線形（linear）</strong>である」ともいう。線形変換 $T: \mathbb{V} \to \mathbb{W}$ は次の 4 性質を満たす。</p><blockquote class="prompt-info"><ol><li>$T$ が線形 $\quad \Rightarrow \quad $ $T(\mathbf{0}) = \mathbf{0}$<li>$T$ が線形 $\quad \Leftrightarrow \quad $ $T(c\mathbf{x} + \mathbf{y}) = cT(\mathbf{x}) + T(\mathbf{y}) \; \forall \, \mathbf{x}, \mathbf{y} \in \mathbb{V},\, c \in F$<li>$T$ が線形 $\quad \Rightarrow \quad $ $T(\mathbf{x} - \mathbf{y}) = T(\mathbf{x}) - T(\mathbf{y}) \; \forall \, \mathbf{x}, \mathbf{y} \in \mathbb{V}$<li>$T$ が線形 $\quad \Leftrightarrow \quad $ $T\left( \sum_{i=1}^n a_i \mathbf{x}_i \right) = \sum_{i=1}^n a_i T(\mathbf{x}_i)$</ol></blockquote><blockquote class="prompt-tip"><p>ある関数が線形であることを示す際は、通常 2 番目の性質を用いると便利である。</p></blockquote><blockquote class="prompt-tip"><p>線形代数は幾何でも広く多様に使える。その理由は、多くの重要な幾何変換が線形だからである。とくに主要な 3 つの幾何変換である<strong>回転</strong>、<strong>反射</strong>、<strong>射影</strong>は線形変換に当たる。</p></blockquote><p>次の 2 種類の線形変換はとくに頻出である。</p><blockquote class="prompt-info"><p><strong>恒等変換と零変換</strong><br /> $F$-ベクトル空間 $\mathbb{V}, \mathbb{W}$ について</p><ul><li><strong>恒等変換（identity transformation）</strong>: すべての $\mathbf{x} \in \mathbb{V}$ に対し $I_\mathbb{V}(\mathbf{x}) = \mathbf{x}$ と定義される関数 $I_\mathbb{V}: \mathbb{V} \to \mathbb{V}$<li><strong>零変換（zero transformation）</strong>: すべての $\mathbf{x} \in \mathbb{V}$ に対し $T_0(\mathbf{x}) = \mathbf{0}$ と定義される関数 $T_0: \mathbb{V} \to \mathbb{W}$</ul></blockquote><p>このほかにも多様な概念が線形変換に該当する。</p><blockquote class="prompt-tip"><p><strong>線形変換の例</strong></p><ul><li>回転<li>反射<li>射影<li><a href="/ja/posts/vector-spaces-subspaces-and-matrices/#転置行列対称行列反対称行列">転置</a><li>微分可能な関数の微分<li>連続関数の積分</ul></blockquote><h2 id="零空間と像">零空間と像</h2><h3 id="零空間と像の定義">零空間と像の定義</h3><blockquote class="prompt-info"><p><strong>定義</strong><br /> ベクトル空間 $\mathbb{V}, \mathbb{W}$ と線形変換 $T: \mathbb{V} \to \mathbb{W}$ に対して</p><ul><li><p><strong>零空間（null space）</strong>または<strong>核（kernel）</strong>: $T(\mathbf{x}) = \mathbf{0}$ を満たす $\mathbf{x} \in \mathbb{V}$ を元とする集合。$\mathrm{N}(T)$ と表記</p>\[\mathrm{N}(T) = \{ \mathbf{x} \in \mathbb{V}: T(\mathbf{x}) = \mathbf{0} \}\]<li><p><strong>値域（range）</strong>または<strong>像（image）</strong>: $T$ の値を元とする $\mathbb{W}$ の部分集合。$\mathrm{R}(T)$ と表記</p>\[\mathrm{R}(T) = \{ T(\mathbf{x}): \mathbf{x} \in \mathbb{V} \}\]</ul></blockquote><blockquote class="prompt-tip"><p><strong>例</strong> ベクトル空間 $\mathbb{V}, \mathbb{W}$ と恒等変換 $I: \mathbb{V} \to \mathbb{V}$、零変換 $T_0: \mathbb{V} \to \mathbb{W}$ について次が成り立つ。</p><ul><li>$\mathrm{N}(I) = \{\mathbf{0}\}$<li>$\mathrm{R}(I) = \mathbb{V}$<li>$\mathrm{N}(T_0) = \mathbb{V}$<li>$\mathrm{R}(T_0) = \{\mathbf{0}\}$</ul></blockquote><p>今後繰り返し重要になるが、線形変換の零空間と像はベクトル空間の<a href="/ja/posts/vector-spaces-subspaces-and-matrices/#部分空間">部分空間</a>である。</p><blockquote class="prompt-info"><p><strong>定理 1</strong><br /> ベクトル空間 $\mathbb{V}, \mathbb{W}$ と線形変換 $T: \mathbb{V} \to \mathbb{W}$ に対して、$\mathrm{N}(T), \mathrm{R}(T)$ はそれぞれ $\mathbb{V}, \mathbb{W}$ の部分空間である。</p><p><strong>証明</strong><br /> $\mathbb{V}, \mathbb{W}$ の零ベクトルをそれぞれ $\mathbf{0}_\mathbb{V}, \mathbf{0}_\mathbb{W}$ と表す。</p><p>$T(\mathbf{0}_\mathbb{V}) = \mathbf{0}_\mathbb{W}$ なので $\mathbf{0}_\mathbb{V} \in \mathrm{N}(T)$ であり、また $\mathbf{x}, \mathbf{y} \in \mathrm{N}(T),\ c \in F$ に対し次が成り立つ。</p>\[\begin{align*} T(\mathbf{x} + \mathbf{y}) &amp;= T(\mathbf{x}) + T(\mathbf{y}) = \mathbf{0}_\mathbb{W} + \mathbf{0}_\mathbb{W} = \mathbf{0}_\mathbb{W}, \\ T(c\mathbf{x}) &amp;= cT(\mathbf{x}) = c\mathbf{0}_\mathbb{W} = \mathbf{0}_\mathbb{W}. \end{align*}\]<p>$\therefore$ <a href="/ja/posts/vector-spaces-subspaces-and-matrices/#部分空間">$\mathbf{0}_\mathbb{V} \in \mathrm{N}(T),\ \mathbf{x} + \mathbf{y} \in \mathrm{N}(T),\ c\mathbf{x} \in \mathrm{N}(T)$ なので $\mathrm{N}(T)$ は $\mathbb{V}$ の部分空間である</a>。</p><p>同様に、$T(\mathbf{0}_\mathbb{V}) = \mathbf{0}_\mathbb{W}$ なので $\mathbf{0}_\mathbb{W} \in \mathrm{R}(T)$ であり、$\forall \mathbf{x}, \mathbf{y} \in \mathrm{R}(T),\ c \in F \ (\exists \mathbf{v}, \mathbf{w} \in \mathbb{V} \ (T(\mathbf{v}) = \mathbf{x}\ \wedge \ T(\mathbf{w}) = \mathbf{y}))$ より</p>\[\begin{align*} T(\mathbf{v} + \mathbf{w}) &amp;= T(\mathbf{v}) + T(\mathbf{w}) = \mathbf{x} + \mathbf{y}, \\ T(c\mathbf{v}) &amp;= cT(\mathbf{v}) = c\mathbf{x}. \end{align*}\]<p>$\therefore$ <a href="/ja/posts/vector-spaces-subspaces-and-matrices/#部分空間">$\mathbf{0}_\mathbb{W} \in \mathrm{R}(T),\ \mathbf{x} + \mathbf{y} \in \mathrm{R}(T),\ c\mathbf{x} \in \mathrm{R}(T)$ なので $\mathrm{R}(T)$ は $\mathbb{W}$ の部分空間である</a>。$\blacksquare$</p></blockquote><p>一方、ベクトル空間 $\mathbb{V}, \mathbb{W}$ と線形変換 $T: \mathbb{V} \to \mathbb{W}$ に対し、$\mathbb{V}$ の<a href="/ja/posts/linear-dependence-and-independence-basis-and-dimension/#基底">基底</a> $\beta = \{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_n \}$ が分かっているとき、像 $\mathrm{R}(T)$ の<a href="/ja/posts/vectors-and-linear-combinations/#生成">生成集合</a>を次のように求められる。</p><blockquote class="prompt-info"><p><strong>定理 2</strong><br /> ベクトル空間 $\mathbb{V}, \mathbb{W}$ と線形変換 $T: \mathbb{V} \to \mathbb{W}$、$\mathbb{V}$ の<a href="/ja/posts/linear-dependence-and-independence-basis-and-dimension/#基底">基底</a> $\beta = \{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_n \}$ に対し次が成り立つ。</p>\[\mathrm{R}(T) = \mathrm{span}(\{T(\mathbf{v}): \mathbf{v} \in \beta \}) = \mathrm{span}(\{T(\mathbf{v}_1), T(\mathbf{v}_2), \dots, T(\mathbf{v}_n) \})\]<p><strong>証明</strong></p>\[T(\mathbf{v}_i) \in \mathrm{R}(T) \quad \forall \mathbf{v}_i \in \beta.\]<p>$\mathrm{R}(T)$ は部分空間なので、<a href="/ja/posts/vector-spaces-subspaces-and-matrices/#部分空間">ベクトル空間、部分空間、そして行列</a>の<strong>定理 2</strong>により</p>\[\mathrm{span}(\{T(\mathbf{v}_1), T(\mathbf{v}_2), \dots, T(\mathbf{v}_n) \}) = \mathrm{span}(\{T(\mathbf{v}_i): \mathbf{v}_i \in \beta \}) \subseteq \mathrm{R}(T).\]<p>また、</p>\[\forall \mathbf{w} \in \mathrm{R}(T) \ (\exists \mathbf{v} \in \mathbb{V} \ (\mathbf{w} = T(\mathbf{v}))).\]<p>$\beta$ は $\mathbb{V}$ の基底なので</p>\[\mathbf{v} = \sum_{i=1}^n a_i \mathbf{v}_i \quad \text{(ただし } a_1, a_2, \dots, a_n \in F \text{)}.\]<p>$T$ は線形なので</p>\[\mathbf{w} = T(\mathbf{v}) = \sum_{i=1}^n a_i T(\mathbf{v}_i) \in \mathrm{span}(\{T(\mathbf{v}_i): \mathbf{v}_i \in \beta \})\] \[\mathrm{R}(T) \subseteq \mathrm{span}(\{T(\mathbf{v}_i): \mathbf{v}_i \in \beta \}) = \mathrm{span}(\{T(\mathbf{v}_1), T(\mathbf{v}_2), \dots, T(\mathbf{v}_n) \}).\]<p>$\therefore$ $\mathrm{R}(T) \supseteq \mathrm{span}({T(\mathbf{v}_i): \mathbf{v}_i \in \beta })$ かつ $\mathrm{R}(T) \subseteq \mathrm{span}({T(\mathbf{v}_i): \mathbf{v}_i \in \beta })$ なので、$\mathrm{R}(T) = \mathrm{span}({T(\mathbf{v}): \mathbf{v} \in \beta })$。$\blacksquare$</p></blockquote><p>この定理は基底 $\beta$ が無限集合の場合にも成り立つ。</p><h3 id="次元定理">次元定理</h3><p>零空間と像は非常に重要な部分空間なので、<a href="/ja/posts/linear-dependence-and-independence-basis-and-dimension/#次元">次元</a>にも特別な名称を与える。</p><blockquote class="prompt-info"><p>ベクトル空間 $\mathbb{V}, \mathbb{W}$ と線形変換 $T: \mathbb{V} \to \mathbb{W}$ に対し、$\mathrm{N}(T), \mathrm{R}(T)$ が有限次元とする。</p><ul><li><strong>零空間の次元（nullity）</strong>: $\mathrm{N}(T)$ の次元。$\mathrm{nullity}(T)$ と表記<li><strong>階数（rank）</strong>: $\mathrm{R}(T)$ の次元。$\mathrm{rank}(T)$ と表記</ul></blockquote><p>線形変換では零空間の次元が大きくなるほど階数は小さくなり、逆に階数が大きくなるほど零空間の次元は小さくなる。</p><blockquote class="prompt-info"><p><strong>定理 3: 次元定理（dimension theorem）</strong><br /> ベクトル空間 $\mathbb{V}, \mathbb{W}$ と線形変換 $T: \mathbb{V}\to \mathbb{W}$ に対して、$\mathbb{V}$ が有限次元なら次が成り立つ。</p>\[\mathrm{nullity}(T) + \mathrm{rank}(T) = \dim(\mathbb{V})\]</blockquote><h4 id="証明">証明</h4><p>$\dim(\mathbb{V}) = n$, $\mathrm{nullity}(T) = \dim(\mathrm{N}(T)) = k$ とし、$\mathrm{N}(T)$ の基底を $\{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_k \}$ とする。</p><p><a href="/ja/posts/linear-dependence-and-independence-basis-and-dimension/#部分空間の次元">「線形従属と線形独立、基底と次元」の<strong>系 6-1</strong></a>により、$\{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_k \}$ を拡張して $\mathbb{V}$ の基底 $\beta = \{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_n \}$ を得ることができる。</p><p>いま、$S = \{T(\mathbf{v}_{k+1}), T(\mathbf{v}_{k+2}), \dots, T(\mathbf{v}_n) \}$ が $\mathrm{R}(T)$ の基底であることを示す。まず $1 \leq i \leq k$ では $T(\mathbf{v}_i) = 0$ なので、<a href="#零空間と像の定義"><strong>定理 2</strong></a> により</p>\[\begin{align*} \mathrm{R}(T) &amp;= \mathrm{span}(\{T(\mathbf{v}_1), T(\mathbf{v}_2), \dots, T(\mathbf{v}_n) \}) \\ &amp;= \mathrm{span}(\{T(\mathbf{v}_{k+1}), T(\mathbf{v}_{k+2}), \dots, T(\mathbf{v}_n) \}) \\ &amp;= \mathrm{span}(S). \end{align*}\]<p>すなわち $S$ は $\mathrm{R}(T)$ の生成集合である。ここで<a href="/ja/posts/linear-dependence-and-independence-basis-and-dimension/#次元"><strong>交換定理の系 5-2</strong></a> により、$S$ が線形独立であることを示せば $S$ が $\mathrm{R}(T)$ の基底であることが分かる。</p><p>$\sum_{i=k+1}^n b_i T(\mathbf{v}_i) = 0$（ただし $b_{k+1}, b_{k+2}, \dots, b_n \in F$）とすると、$T$ が線形なので</p>\[\sum_{i=k+1}^n b_i T(\mathbf{v}_i) = 0 \Leftrightarrow T\left(\sum_{i=k+1}^n b_i \mathbf{v}_i \right) = 0 \Leftrightarrow \sum_{i=k+1}^n b_i \mathbf{v}_i \in \mathrm{N}(T).\]<p>したがって、</p>\[\begin{align*} &amp;\exists c_1, c_2, \dots, c_k \in F, \\ &amp;\sum_{i=k+1}^n b_i \mathbf{v}_i = \sum_{i=1}^k c_i \mathbf{v}_i \\ \Leftrightarrow &amp;\sum_{i=1}^k (-c_i)\mathbf{v}_i + \sum_{i=k+1}^n b_i \mathbf{v}_i = 0. \end{align*}\]<p>$\beta$ は $\mathbb{V}$ の基底であるから、$\sum_{i=1}^k (-c_i)\mathbf{v}_i + \sum_{i=k+1}^n b_i \mathbf{v}_i = 0$ の唯一の解は</p>\[c_1 = c_2 = \cdots = c_k = b_{k+1} = b_{k+2} = \cdots = b_n = 0\]<p>であり、これより</p>\[\sum_{i=k+1}^n b_i T(\mathbf{v}_i) = 0 \quad \Rightarrow \quad b_i = 0.\]<p>すなわち $S$ は線形独立であり、$\mathrm{R}(T)$ の基底である。</p>\[\therefore \mathrm{rank}(T) = n - k = \dim{\mathbb{V}} - \mathrm{nullity}(T). \blacksquare\]<h3 id="線形変換と単射全射">線形変換と単射・全射</h3><p>線形変換において単射（injection）と全射（surjection）は階数や零空間の次元と密接に関係する。</p><blockquote class="prompt-info"><p><strong>定理 4</strong><br /> ベクトル空間 $\mathbb{V}, \mathbb{W}$ と線形変換 $T: \mathbb{V} \to \mathbb{W}$ に対して</p>\[T\text{ は単射である} \quad \Leftrightarrow \quad \mathrm{N}(T) = \{\mathbf{0}\}.\]</blockquote><blockquote class="prompt-info"><p><strong>定理 5</strong><br /> 有限次元ベクトル空間 $\mathbb{V}, \mathbb{W}$ の次元が等しいとき、線形変換 $T: \mathbb{V} \to \mathbb{W}$ について次の 4 命題は同値である。</p><ol><li>$T$ は単射である。<li>$\mathrm{nullity}(T) = 0$<li>$\mathrm{rank}(T) = \dim(\mathbb{V})$<li>$T$ は全射である。</ol></blockquote><p><a href="#次元定理">次元定理</a>と<a href="#線形変換">線形変換の性質 1, 3</a>、そして<a href="/ja/posts/linear-dependence-and-independence-basis-and-dimension/#部分空間の次元">「線形従属と線形独立、基底と次元」の<strong>定理 6</strong></a>を用いて、<strong>定理 4</strong> と <strong>定理 5</strong> を証明できる。</p><p>これら 2 つの定理は、与えられた線形変換が単射または全射かどうかを判定する際に有用である。</p><blockquote class="prompt-warning"><p>無限次元ベクトル空間 $\mathbb{V}$ と線形変換 $T: \mathbb{V} \to \mathbb{V}$ については、単射と全射は同値ではない。</p></blockquote><p>また、ある線形変換が単射であれば、場合によっては与えられたベクトル空間の部分集合が線形独立かどうかを判定する際に、次の定理が有用である。</p><blockquote class="prompt-info"><p><strong>定理 6</strong><br /> ベクトル空間 $\mathbb{V}, \mathbb{W}$ と単射な線形変換 $T: \mathbb{V} \to \mathbb{W}$、および $\mathbb{V}$ の部分集合 $S$ に対して次が成り立つ。</p>\[S\text{ が線形独立} \quad \Leftrightarrow \quad \{T(\mathbf{v}): \mathbf{v} \in S \}\text{ が線形独立}.\]</blockquote><h2 id="線形変換と基底">線形変換と基底</h2><p>線形変換の重要な特徴は、基底に対してどのように作用するかで線形変換が決まる、という点にある。</p><blockquote class="prompt-info"><p><strong>定理 7</strong><br /> $F$-ベクトル空間 $\mathbb{V}, \mathbb{W}$ と $\mathbb{V}$ の基底 $\{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_n \}$、およびベクトル $\mathbf{w}_1, \mathbf{w}_2, \dots, \mathbf{w}_n \in \mathbb{W}$ に対して、次の条件を満たす線形変換 $T: \mathbb{V} \to \mathbb{W}$ が一意に存在する。</p>\[i = 1, 2, \dots, n \text{ に対して } T(\mathbf{v}_i) = \mathbf{w}_i\]<p><strong>証明</strong><br /> $\mathbf{x} \in \mathbb{V}$ に対して次の線形結合表現は一意である。</p>\[\mathbf{x} = \sum_{i=1}^n a_i \mathbf{v}_i \text{ (}a_1, a_2, \dots, a_n \in F \text{)}\]<p>線形変換 $T: \mathbb{V} \to \mathbb{W}$ を</p>\[T(\mathbf{x}) = T\left( \sum_{i=1}^n a_i \mathbf{v}_i \right) = \sum_{i=1}^n a_i \mathbf{w}_i\]<p>とおく。</p><p>i) $i = 1, 2, \dots, n$ に対して $T(\mathbf{v}_i) = \mathbf{w}_i$。</p><p>ii)</p><p>もう一つの線形変換 $U: \mathbb{V} \to \mathbb{W}$ が $i = 1, 2, \dots, n$ に対して $U(\mathbf{v}_i) = \mathbf{w}_i$ を満たすと仮定すると、$\mathbf{x} = \sum_{i=1}^n a_i \mathbf{v}_i \in \mathbb{V}$ に対して</p>\[U(\mathbf{x}) = \sum_{i=1}^n a_i U(\mathbf{v}_i) = \sum_{i=1}^n a_i \mathbf{w}_i = T(\mathbf{x}_i)\] \[\therefore U = T.\]<p>i), ii) により、$i = 1, 2, \dots, n$ に対して $T(\mathbf{v}_i) = \mathbf{w}_i$ となる線形変換は</p>\[T(\mathbf{x}) = T\left( \sum_{i=1}^n a_i \mathbf{v}_i \right) = \sum_{i=1}^n a_i \mathbf{w}_i\]<p>の形で一意である。$\blacksquare$</p><p><strong>系 7-1</strong><br /> 2 つのベクトル空間 $\mathbb{V}, \mathbb{W}$ に対し、$\mathbb{V}$ が有限集合の基底 $\{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_n \}$ をもつとする。2 つの線形変換 $U, T: \mathbb{V} \to \mathbf{W}$ が $i = 1, 2, \dots, n$ について $U(\mathbf{v}_i) = T(\mathbf{v}_i)$ を満たせば $U = T$ である。<br /> すなわち、<u>基底での値が等しければ同じ線形変換である。</u></p></blockquote>]]> </content> </entry> <entry><title xml:lang="ja">線形従属と線形独立、基底と次元</title><link href="https://www.yunseo.kim/ja/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/linear-dependence-and-independence-basis-and-dimension/" rel="alternate" type="text/html" hreflang="am" /><published>2025-09-16T00:00:00+09:00</published> <updated>2025-10-25T21:21:39+09:00</updated> <id>https://www.yunseo.kim/ja/posts/linear-dependence-and-independence-basis-and-dimension/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Linear Algebra" /> <summary xml:lang="ja">線形従属と線形独立、さらにベクトル空間の基底と次元の定義・性質をまとめて解説します。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>線形従属と線形独立、さらにベクトル空間の基底と次元の定義・性質をまとめて解説します。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/vectors-and-linear-combinations/">ベクトルと線形結合</a><li><a href="/ja/posts/vector-spaces-subspaces-and-matrices/">ベクトル空間、部分空間、そして行列</a></ul><h2 id="線形従属と線形独立">線形従属と線形独立</h2><p>ある<a href="/ja/posts/vector-spaces-subspaces-and-matrices/#ベクトル空間">ベクトル空間</a> $\mathbb{V}$ と<a href="/ja/posts/vector-spaces-subspaces-and-matrices/#部分空間">部分空間</a> $\mathbb{W}$ について、$\mathbb{W}$ を<a href="/ja/posts/vectors-and-linear-combinations/#線形結合-cmathbfv--dmathbfw">生成</a>する可能な限り小さい有限部分集合 $S$ を見つけたいとしよう。</p><p>集合 $S = \{\mathbf{u}_1, \mathbf{u}_2, \mathbf{u}_3, \mathbf{u}_4 \}$ に対し $\mathrm{span}(S) = \mathbb{W}$ であるとき、$\mathbb{W}$ を生成する $S$ の真部分集合が存在しないかどうかを判定するにはどうすればよいだろうか。これは、$S$ から取り出したあるベクトルが他のベクトルの<a href="/ja/posts/vectors-and-linear-combinations/#ベクトルの線形結合">線形結合</a>で表せるかどうかを判定する問題に等しい。たとえば、$\mathbf{u}_4$ を残り 3 本のベクトルの線形結合で表すための必要十分条件は、次の条件を満たすスカラー $a_1, a_2, a_3$ が存在することである。</p>\[\mathbf{u}_4 = a_1\mathbf{u}_1 + a_2\mathbf{u}_2 + a_3\mathbf{u}_3\]<p>しかし $\mathbf{u}_1$, $\mathbf{u}_2$, $\mathbf{u}_3$, $\mathbf{u}_4$ のそれぞれについて毎回このように連立一次方程式を立てて解の存在を確かめるのは煩雑なので、式を少し変形してみよう。</p>\[a_1\mathbf{u}_1 + a_2\mathbf{u}_2 + a_3\mathbf{u}_3 + a_4\mathbf{u}_4 = \mathbf{0}\]<p>もし $S$ のあるベクトルが他のベクトルの線形結合であれば、上のように零ベクトルを $S$ の線形結合で表すとき、係数 $a_1, a_2, a_3, a_4$ のうち少なくとも 1 つが $0$ ではない表し方が存在する。この命題の逆もまた成り立ち、係数 $a_1, a_2, a_3, a_4$ のうち少なくとも 1 つが $0$ でないまま零ベクトルを $S$ の元ベクトルの線形結合として表す方法が存在するなら、$S$ のあるベクトルは他のベクトルの線形結合である。</p><p>これを一般化して、次のように<strong>線形従属</strong>と<strong>線形独立</strong>を定義する。</p><blockquote class="prompt-info"><p><strong>定義</strong><br /> ベクトル空間 $\mathbb{V}$ の部分集合 $S$ について、$a_1\mathbf{u}_1 + a_2\mathbf{u}_2 + \cdots + a_n\mathbf{u}_n = \mathbf{0}$ を満たす有限個の互いに異なるベクトル $\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n \in S$ と、少なくとも 1 つが $0$ でないスカラー $a_1, a_2, \dots, a_n$ が存在すれば、集合 $S$ およびそのベクトルは<strong>線形従属（linearly dependent）</strong>であるという。そうでない場合は<strong>線形独立（linearly independent）</strong>という。</p></blockquote><p>任意のベクトル $\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n$ に対し $a_1 = a_2 = \cdots = a_n = 0$ なら $a_1\mathbf{u}_1 + a_2\mathbf{u}_2 + \cdots + a_n\mathbf{u}_n = \mathbf{0}$ であり、これを<strong>零ベクトルの自明な表現（trivial representation of $\mathbf{0}$）</strong>という。</p><p>線形独立な集合に関して、次の 3 つの命題はすべてのベクトル空間で常に真である。とくに<strong>命題 3</strong>は前述のとおり、ある有限集合が線形独立かどうかを判定する際に非常に有用である。</p><blockquote class="prompt-info"><ul><li><strong>命題 1</strong>: 空集合は線形独立である。ある集合が線形従属であるためには空集合であってはならない。<li><strong>命題 2</strong>: 0 でないベクトル 1 本からなる集合は線形独立である。<li><strong>命題 3</strong>: ある集合が線形独立であるための必要十分条件は、$\mathbf{0}$ をその集合に関する線形結合で表す方法が自明な表現しかないことである。</ul></blockquote><p>また、次の定理も重要である。</p><blockquote class="prompt-info"><p><strong>定理 1</strong><br /> $\mathbb{V}$ をベクトル空間とし、$S_1 \subseteq S_2 \subseteq \mathbb{V}$ とする。$S_1$ が線形従属なら $S_2$ も線形従属である。</p><p><strong>系 1-1</strong><br /> $\mathbb{V}$ をベクトル空間とし、$S_1 \subseteq S_2 \subseteq \mathbb{V}$ とする。$S_2$ が線形独立なら $S_1$ も線形独立である。</p></blockquote><blockquote class="prompt-info"><p><strong>定理 2</strong><br /> ベクトル空間 $\mathbb{V}$ と線形独立な部分集合 $S$ を考える。$S$ に含まれないベクトル $\mathbf{v} \in \mathbb{V}$ に対し、$S \cup \{\mathbf{v}\}$ が線形従属であるための必要十分条件は $\mathbf{v} \in \mathrm{span}(S)$ である。</p><p>言い換えると、<strong>$S$ のどの真部分集合も $S$ と同じ空間を生成できないなら $S$ は線形独立である。</strong></p></blockquote><h2 id="基底と次元">基底と次元</h2><h3 id="基底">基底</h3><p><a href="#線形従属と線形独立">線形独立</a>な $\mathbb{W}$ の生成集合 $S$ には特別な性質がある。すなわち、$\mathbb{W}$ に属するすべてのベクトルは必ず $S$ の線形結合で表せ、その表現は一意である（<strong>定理 3</strong>）。したがって、あるベクトル空間に対する線形独立な生成集合を特に次のように<strong>基底（basis）</strong>と定義する。</p><blockquote class="prompt-info"><p><strong>基底の定義</strong><br /> ベクトル空間 $\mathbb{V}$ と部分集合 $\beta$ に対し、$\beta$ が線形独立でかつ $\mathbb{V}$ を生成するなら、$\beta$ を $\mathbb{V}$ の<strong>基底（basis）</strong>という。このとき、$\beta$ のベクトルは $\mathbb{V}$ の基底を成すという。</p></blockquote><blockquote class="prompt-tip"><p>$\mathrm{span}(\emptyset) = \{\mathbf{0}\}$ であり、$\emptyset$ は線形独立である。したがって $\emptyset$ は点空間の基底である。</p></blockquote><p>とくに、$F^n$ に対する次の特別な基底を $F^n$ の<strong>標準基底（standard basis）</strong>という。</p><blockquote class="prompt-info"><p><strong>標準基底の定義</strong><br /> ベクトル空間 $F^n$ について次のベクトルを考える。</p>\[\mathbf{e}_1 = (1,0,0,\dots,0),\ \mathbf{e}_2 = (0,1,0,\dots,0),\ \dots, \mathbf{e}_n = (0,0,0,\dots,1)\]<p>このとき、集合 $\{\mathbf{e}_1, \mathbf{e}_2, \dots, \mathbf{e}_n \}$ は $F^n$ の基底であり、これを $F^n$ の<strong>標準基底（standard basis）</strong>という。</p></blockquote><blockquote class="prompt-info"><p><strong>定理 3</strong><br /> ベクトル空間 $\mathbb{V}$ と互いに異なる $n$ 個のベクトル $\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n \in \mathbb{V}$ に対し、集合 $\beta = \{\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n \}$ が $\mathbb{V}$ の基底であるための必要十分条件は「任意のベクトル $\mathbf{v} \in \mathbb{V}$ を $\beta$ に属するベクトルの線形結合で表せ、しかもその表現が一意であること」である。すなわち、一意なスカラーの $n$ 順序組 $(a_1, a_2, \dots, a_n)$ に対し、ベクトル $\mathbf{v}$ は次を満たす。</p>\[\mathbf{v} = a_1\mathbf{u}_1 + a_2\mathbf{u}_2 + \cdots + a_n\mathbf{u}_n\]</blockquote><p><strong>定理 3</strong>によれば、互いに異なる $n$ 個のベクトル $\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n$ がベクトル空間 $\mathbb{V}$ の基底を成す場合、そのベクトル空間の中ではベクトル $\mathbf{v}$ が与えられると、それに対応するスカラーの $n$ 順序組 $(a_1, a_2, \dots, a_n)$ が定まり、逆にスカラーの $n$ 順序組が与えられると、それに対応するベクトル $\mathbf{v}$ を得ることができる。後で<strong>可逆性</strong>と<strong>同型写像</strong>について学ぶ際に改めて整理するが、この場合ベクトル空間 $\mathbb{V}$ と $F^n$ は<u>本質的に同じ</u>である。</p><blockquote class="prompt-info"><p><strong>定理 4</strong><br /> 有限集合 $S$ について $\mathrm{span}(S) = \mathbb{V}$ なら、$S$ の部分集合の中に $\mathbb{V}$ の基底が存在する。すなわち、この場合 $\mathbb{V}$ の基底は有限集合である。</p></blockquote><blockquote><p>多くのベクトル空間が<strong>定理 4</strong>の適用対象に該当するが、必ずしもそうとは限らない。<u>基底は有限集合でない場合もある</u>。{: .prompt-tip }</p></blockquote><h3 id="次元">次元</h3><blockquote class="prompt-info"><p><strong>定理 5: 交換定理（replacement theorem）</strong><br /> $n$ 個のベクトルからなる集合 $G$ に対し $\mathrm{span}(G) = \mathbb{V}$ とする。$L$ が $m$ 個の線形独立なベクトルからなる $\mathbb{V}$ の部分集合であれば、$m \leq n$ である。さらに、$n-m$ 個のベクトルを要素とし $\mathrm{span}(L \cup H) = \mathbb{V}$ を満たす集合 $H \subseteq G$ が存在する。</p></blockquote><p>これより、きわめて重要な 2 つの系が得られる。</p><blockquote class="prompt-info"><p><strong>交換定理の系 5-1</strong><br /> ベクトル空間 $\mathbb{V}$ が有限集合の基底を含むと仮定すると、$\mathbb{V}$ のすべての基底は有限集合であり、同じ本数のベクトルから成る。</p></blockquote><p>これによれば、$\mathbb{V}$ の基底を成すベクトルの本数は $\mathbb{V}$ の不変な本質的性質であり、これを<strong>次元（dimension）</strong>という。</p><blockquote class="prompt-info"><p><strong>次元の定義</strong><br /> 基底が有限集合であるベクトル空間を<strong>有限次元（finite dimension）</strong>といい、このとき基底の要素数 $n$ を当該ベクトル空間の<strong>次元（dimension）</strong>とし、$\dim(\mathbb{V})$ と表す。有限次元でないベクトル空間は<strong>無限次元（infinite dimension）</strong>である。</p></blockquote><blockquote class="prompt-tip"><ul><li>$\dim(\{\mathbf{0}\}) = 0$<li>$\dim(F^n) = n$<li>$\dim(\mathcal{M}_{m \times n}(F)) = mn$</ul></blockquote><blockquote class="prompt-tip"><p>ベクトル空間の次元は、どの体の上にあるかによって変わり得る。</p><ul><li>複素数体 $\mathbb{C}$ 上では、複素数ベクトル空間の次元は 1、基底は $\{1\}$<li>実数体 $\mathbb{R}$ 上では、複素数ベクトル空間の次元は 2、基底は $\{1,i\}$</ul></blockquote><p>有限次元ベクトル空間 $\mathbb{V}$ では、$\dim(\mathbb{V})$ より多い本数のベクトルを持つ部分集合は決して線形独立ではあり得ない。</p><blockquote class="prompt-info"><p><strong>交換定理の系 5-2</strong><br /> $\mathbb{V}$ が次元 $n$ のベクトル空間とする。</p><ol><li>$\mathbb{V}$ の有限生成集合には必ず $n$ 本以上のベクトルが含まれ、$n$ 本のベクトルからなる $\mathbb{V}$ の生成集合は $\mathbb{V}$ の基底である。<li>線形独立で $n$ 本のベクトルからなる $\mathbb{V}$ の部分集合は $\mathbb{V}$ の基底である。<li>線形独立な $\mathbb{V}$ の部分集合は拡張して基底にできる。すなわち、$L \subseteq \mathbb{V}$ が線形独立なら、$\beta \supseteq L$ を満たす $\mathbb{V}$ の基底 $\beta$ が存在する。</ol></blockquote><h3 id="部分空間の次元">部分空間の次元</h3><blockquote class="prompt-info"><p><strong>定理 6</strong><br /> 有限次元ベクトル空間 $\mathbb{V}$ に対し、部分空間 $\mathbb{W}$ は有限次元であり、$\dim(\mathbb{W}) \leq \dim(\mathbb{V})$ である。とくに、$\dim(\mathbb{W}) = \dim(\mathbb{V}) \quad \Rightarrow \quad \mathbb{V} = \mathbb{W}.$</p><p><strong>系 6-1</strong><br /> 有限次元ベクトル空間 $\mathbb{V}$ の部分空間 $\mathbb{W}$ に対し、$\mathbb{W}$ の任意の基底を拡張して $\mathbb{V}$ の基底を得ることができる。</p></blockquote><p><strong>定理 6</strong>より、$\mathbb{R}^3$ の部分空間の次元は $0,1,2,3$ になり得る。</p><ul><li>0 次元: 原点（$\mathbf{0}$）のみを含む点空間 $\{\mathbf{0}\}$<li>1 次元: 原点（$\mathbf{0}$）を通る直線<li>2 次元: 原点（$\mathbf{0}$）を含む平面<li>3 次元: ユークリッド 3 次元空間全体</ul>]]> </content> </entry> <entry><title xml:lang="ja">ベクトル空間、部分空間、そして行列</title><link href="https://www.yunseo.kim/ja/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/vector-spaces-subspaces-and-matrices/" rel="alternate" type="text/html" hreflang="am" /><published>2025-09-13T00:00:00+09:00</published> <updated>2025-10-28T18:44:54+09:00</updated> <id>https://www.yunseo.kim/ja/posts/vector-spaces-subspaces-and-matrices/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Linear Algebra" /> <summary xml:lang="ja">ベクトル空間と部分空間の定義を押さえ、行列空間や関数空間などの代表例を解説。とくに行列空間に焦点を当て、任意サイズで重要な部分空間を成す対称・反対称行列、上三角・下三角・対角行列を整理します。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>ベクトル空間と部分空間の定義を押さえ、行列空間や関数空間などの代表例を解説。とくに行列空間に焦点を当て、任意サイズで重要な部分空間を成す対称・反対称行列、上三角・下三角・対角行列を整理します。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><ul><li><strong>行列（matrix）</strong><ul><li>行列 $A$ の $i$ 行 $j$ 列の成分を $A_{ij}$ または $a_{ij}$ と表す<li><strong>対角成分（diagonal entry）</strong>: $i=j$ の成分 $a_{ij}$<li>成分 $a_{i1}, a_{i2}, \dots, a_{in}$ をこの行列の $i$ 番目の<strong>行（row）</strong>という<ul><li>行列の各行は $F^n$ のベクトルで表せる<li>さらに、$F^n$ の行ベクトルは $1 \times n$ の別の行列として表せる</ul><li>成分 $a_{1j}, a_{2j}, \dots, a_{mj}$ をこの行列の $j$ 番目の<strong>列（column）</strong>という<ul><li>行列の各列は $F^m$ のベクトルで表せる<li>さらに、$F^m$ の列ベクトルは $m \times 1$ の別の行列として表せる</ul><li><strong>零行列（zero matrix）</strong>: すべての成分が $0$ の行列。$O$ と表す<li><strong>正方行列（square matrix）</strong>: 行数と列数が等しい行列<li>2 つの $m \times n$ 行列 $A, B$ について、すべての $1 \leq i \leq m$, $1 \leq j \leq n$ に対して $A_{ij} = B_{ij}$（すなわち対応する成分がすべて一致）なら、2 つの行列は<strong>等しい</strong>（$A=B$）と定義する<li><strong>転置行列（transpose matrix）</strong>: $m \times n$ 行列 $A$ に対し、$A$ の行と列を入れ替えた $n \times m$ 行列 $A^T$<li><strong>対称行列（symmetric matrix）</strong>: $A^T = A$ を満たす正方行列 $A$<li><strong>反対称行列（skew-symmetric matrix）</strong>: $B^T = -B$ を満たす正方行列 $B$<li><strong>三角行列（triangular matrix）</strong><ul><li><strong>上三角行列（upper triangular matrix）</strong>: 対角成分の下のすべての成分が $0$（すなわち $i&gt;j \Rightarrow A_{ij}=0$）の行列。通常 $U$ と表す<li><strong>下三角行列（lower triangular matrix）</strong>: 対角成分の上のすべての成分が $0$（すなわち $i&lt;j \Rightarrow A_{ij}=0$）の行列。通常 $L$ と表す</ul><li><strong>対角行列（diagonal matrix）</strong>: 対角成分以外のすべての成分が $0$ の正方行列（すなわち $i \neq j \Rightarrow M_{ij}=0$ の $n \times n$ 行列）。通常 $D$ と表す</ul><li>代表的なベクトル空間<ul><li><strong>$n$ 個の順序組 $F^n$</strong>:<ul><li>体 $F$ の成分からなるすべての $n$ 個の順序組の集合<li>$F^n$ と表し、$F$-ベクトル空間である</ul><li><strong>行列空間（matrix space）</strong>:<ul><li>成分が体 $F$ の元であるすべての $m \times n$ 行列の集合<li>$\mathcal{M}_{m \times n}(F)$ と表し、ベクトル空間である</ul><li><strong>関数空間（function space）</strong>:<ul><li>体 $F$ の空でない集合 $S$ に対し、$S$ から $F$ へのすべての関数の集合<li>$\mathcal{F}(S,F)$ と表し、ベクトル空間である</ul></ul><li><strong>部分空間（subspace）</strong><ul><li>$F$-ベクトル空間 $\mathbb{V}$ の部分集合 $\mathbb{W}$ が、$\mathbb{V}$ で定義した和とスカラー乗法を同一に備える $F$-ベクトル空間であるとき、$\mathbb{W}$ を $\mathbb{V}$ の<strong>部分空間（subspace）</strong>という<li>あらゆるベクトル空間 $\mathbb{V}$ に対し、$\mathbb{V}$ 自身と $\{0\}$ は部分空間であり、とくに $\{0\}$ は<strong>零部分空間（zero subspace）</strong>という<li>ベクトル空間のある部分集合が零ベクトルを元に持ち、<a href="/ja/posts/vectors-and-linear-combinations/#ベクトルの線形結合">線形結合</a>について閉じていれば（$\mathrm{span}(\mathbb{W})=\mathbb{W}$ なら）、その集合は部分空間である</ul></ul></blockquote><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/vectors-and-linear-combinations/">ベクトルと線形結合</a></ul><h2 id="ベクトル空間">ベクトル空間</h2><p><a href="/ja/posts/vectors-and-linear-combinations/#広い意味のベクトルベクトル空間の元">ベクトルと線形結合</a>でも少し見たように、代数的構造としてのベクトルとベクトル空間の定義は次のとおりである。</p><blockquote class="prompt-info"><p><strong>定義</strong><br /> 体 $F$ 上の<strong>ベクトル空間（vector space）</strong>または<strong>線形空間（linear space）</strong> $\mathbb{V}$ は、次の 8 条件を満たす 2 つの演算、<strong>和</strong>と<strong>スカラー乗法</strong>を持つ集合である。体 $F$ の元を<strong>スカラー（scalar）</strong>、ベクトル空間 $\mathbb{V}$ の元を<strong>ベクトル（vector）</strong>という。</p><ul><li><strong>和（sum）</strong>: $\mathbb{V}$ の 2 つの元 $\mathbf{x}, \mathbf{y}$ に対し、一意の元 $\mathbf{x} + \mathbf{y} \in \mathbb{V}$ を対応させる演算。このとき $\mathbf{x} + \mathbf{y}$ を $\mathbf{x}$ と $\mathbf{y}$ の<strong>和</strong>という。<li><strong>スカラー乗法（scalar multiplication）</strong>: 体 $F$ の元 $a$ とベクトル空間 $\mathbb{V}$ の元 $\mathbf{x}$ ごとに一意の元 $a\mathbf{x} \in \mathbb{V}$ を対応させる演算。このとき $a\mathbf{x}$ を $\mathbf{x}$ の<strong>スカラー倍（scalar multiple）</strong>という。</ul><ol><li>すべての $\mathbf{x},\mathbf{y} \in \mathbb{V}$ に対して $\mathbf{x} + \mathbf{y} = \mathbf{y} + \mathbf{x}$（加法の交換法則）<li>すべての $\mathbf{x},\mathbf{y},\mathbf{z} \in \mathbb{V}$ に対して $(\mathbf{x}+\mathbf{y})+\mathbf{z} = \mathbf{x}+(\mathbf{y}+\mathbf{z})$（加法の結合法則）<li>すべての $\mathbf{x} \in \mathbb{V}$ に対して $\mathbf{x} + \mathbf{0} = \mathbf{x}$ となる $\mathbf{0} \in \mathbb{V}$ が存在する（零ベクトル、加法に関する単位元）<li>各 $\mathbf{x} \in \mathbb{V}$ について、$\mathbf{x}+\mathbf{y}=\mathbf{0}$ を満たす $\mathbf{y} \in \mathbb{V}$ が存在する（加法に関する逆元）<li>各 $\mathbf{x} \in \mathbb{V}$ に対して $1\mathbf{x} = \mathbf{x}$（乗法に関する単位元）<li>すべての $a,b \in F$ とすべての $\mathbf{x} \in \mathbb{V}$ に対して $(ab)\mathbf{x} = a(b\mathbf{x})$（スカラー乗法の結合法則）<li>すべての $a \in F$ とすべての $\mathbf{x},\mathbf{y} \in \mathbb{V}$ に対して $a(\mathbf{x}+\mathbf{y}) = a\mathbf{x} + a\mathbf{y}$（加法に関するスカラー乗法の分配法則 1）<li>すべての $a,b \in F$ とすべての $\mathbf{x},\mathbf{y} \in \mathbb{V}$ に対して $(a+b)\mathbf{x} = a\mathbf{x} + b\mathbf{x}$（加法に関するスカラー乗法の分配法則 2）</ol></blockquote><p>ベクトル空間は本来「$F$-ベクトル空間 $\mathbb{V}$」と表記すべきだが、ベクトル空間を扱う際、体は大きな争点ではないので混乱の恐れがなければ体 $F$ は省略し「ベクトル空間 $\mathbb{V}$」と書く。</p><h3 id="行列空間">行列空間</h3><h4 id="行ベクトルと列ベクトル">行ベクトルと列ベクトル</h4><p>体 $F$ の成分からなるすべての $n$ 個の順序組の集合を $F^n$ と表す。$u = (a_1, a_2, \dots, a_n) \in F^n$, $v = (b_1, b_2, \dots, b_n) \in F^n$ のとき、和とスカラー積を次のように定義すれば $F^n$ は $F$-ベクトル空間である。</p>\[\begin{align*} u + v &amp;= (a_1+b_1, a_2+b_2, \dots, a_n+b_n), \\ cu &amp;= (ca_1, ca_2, \dots, ca_n) \end{align*}\]<p>$F^n$ のベクトルは、単独で書くときは通常<strong>行ベクトル（row vector）</strong> $(a_1, a_2, \dots, a_n)$ よりも <strong>列ベクトル（column vector）</strong></p>\[\begin{pmatrix} a_1 \\ a_2 \\ \vdots \\ a_n \end{pmatrix}\]<p>で表す。</p><blockquote class="prompt-tip"><p>ただし列ベクトル表記は紙幅を取りがちなので、<a href="#転置行列対称行列反対称行列">転置</a>を用いて $(a_1, a_2, \dots, a_n)^T$ と表すこともある。</p></blockquote><h4 id="行列と行列空間">行列と行列空間</h4><p>一方、$F$ の成分からなる $m \times n$ の<strong>行列（matrix）</strong>は次のような長方形の配列で、イタリック体の大文字（$A, B, C$ など）で表す。</p>\[\begin{pmatrix} a_{11} &amp; a_{12} &amp; \cdots &amp; a_{1n} \\ a_{21} &amp; a_{22} &amp; \cdots &amp; a_{2n} \\ \vdots &amp; \vdots &amp; &amp; \vdots \\ a_{m1} &amp; a_{m2} &amp; \cdots &amp; a_{mn} \end{pmatrix}\]<ul><li>行列 $A$ の $i$ 行 $j$ 列の成分を $A_{ij}$ または $a_{ij}$ と表す。<li>すべての $a_{ij}$（$1 \leq i \leq m$, $1 \leq j \leq n$）は $F$ の元である。<li>$i=j$ の成分 $a_{ij}$ をこの行列の<strong>対角成分（diagonal entry）</strong>という。<li>成分 $a_{i1}, a_{i2}, \dots, a_{in}$ をこの行列の $i$ 番目の<strong>行（row）</strong>という。行列の各行は $F^n$ のベクトルで表せ、さらに $F^n$ の行ベクトルは $1 \times n$ の別の行列で表せる。<li>成分 $a_{1j}, a_{2j}, \dots, a_{mj}$ をこの行列の $j$ 番目の<strong>列（column）</strong>という。行列の各列は $F^m$ のベクトルで表せ、さらに $F^m$ の列ベクトルは $m \times 1$ の別の行列で表せる。<li>すべての成分が $0$ の $m \times n$ 行列を<strong>零行列（zero matrix）</strong>といい、$O$ と表す。<li>行数と列数が等しい行列を<strong>正方行列（square matrix）</strong>という。<li>2 つの $m \times n$ 行列 $A, B$ について、すべての $1 \leq i \leq m$, $1 \leq j \leq n$ に対し $A_{ij} = B_{ij}$ なら（すなわち対応する成分がすべて一致するなら）、2 つの行列は<strong>等しい</strong>（$A=B$）と定義する。</ul><p>成分が体 $F$ の元であるすべての $m \times n$ 行列の集合を $\mathcal{M}_{m \times n}(F)$ と表す。$\mathbf{A},\mathbf{B} \in \mathcal{M}_{m \times n}(F),\ c \in F$ のとき、和とスカラー乗法を次のように定義すれば $\mathcal{M}_{m \times n}(F)$ はベクトル空間であり、これを<strong>行列空間（matrix space）</strong>という。</p>\[\begin{align*} (\mathbf{A}+\mathbf{B})_{ij} &amp;= \mathbf{A}_{ij} + \mathbf{B}_{ij}, \\ (c\mathbf{A})_{ij} &amp;= c\mathbf{A}_{ij} \\ \text{（ただし }1 \leq i \leq &amp;m, 1 \leq j \leq n \text{）} \end{align*}\]<p>これは $F^n$ と $F^m$ で定義した演算の自然な拡張である。</p><h3 id="関数空間">関数空間</h3><p>体 $F$ の空でない集合 $S$ に対し、$\mathcal{F}(S,F)$ を $S$ から $F$ へのすべての関数の集合という。$\mathcal{F}(S,F)$ において、すべての $s \in S$ について $f(s) = g(s)$ なら 2 つの関数 $f, g$ は<strong>等しい</strong>（$f=g$）という。</p><p>$f,g \in \mathcal{F}(S,F),\ c \in F,\ s \in S$ のとき、和とスカラー乗法を次のように定義すれば $\mathcal{F}(S,F)$ はベクトル空間であり、これを<strong>関数空間（function space）</strong>という。</p>\[\begin{align*} (f + g)(s) &amp;= f(s) + g(s), \\ (cf)(s) &amp;= c[f(s)] \end{align*}\]<h2 id="部分空間">部分空間</h2><blockquote class="prompt-info"><p><strong>定義</strong><br /> $F$-ベクトル空間 $\mathbb{V}$ の部分集合 $\mathbb{W}$ が、$\mathbb{V}$ で定義した和とスカラー乗法を同一に備える $F$-ベクトル空間であるとき、$\mathbb{W}$ を $\mathbb{V}$ の<strong>部分空間（subspace）</strong>という。</p></blockquote><p>任意のベクトル空間 $\mathbb{V}$ に対し、$\mathbb{V}$ 自身と $\{0\}$ は部分空間であり、とくに ${0}$ は<strong>零部分空間（zero subspace）</strong>という。</p><p>ある部分集合が部分空間であるかどうかは、次の定理で確認できる。</p><blockquote class="prompt-info"><p><strong>定理 1</strong><br /> ベクトル空間 $\mathbb{V}$ と部分集合 $\mathbb{W}$ について、$\mathbb{W}$ が $\mathbb{V}$ の部分空間であるための必要十分条件は、次の 3 条件を満たすことである。このとき演算は $\mathbb{V}$ で定義したものと同じである。</p><ol><li>$\mathbf{0} \in \mathbb{W}$<li>$\mathbf{x}+\mathbf{y} \in \mathbb{W} \quad \forall\ \mathbf{x} \in \mathbb{W},\ \mathbf{y} \in \mathbb{W}$<li>$c\mathbf{x} \in \mathbb{W} \quad \forall\ c \in F,\ \mathbf{x} \in \mathbb{W}$</ol><p>つまり、零ベクトルを元に持ち、<a href="/ja/posts/vectors-and-linear-combinations/#ベクトルの線形結合">線形結合</a>について閉じていれば（$\mathrm{span}(\mathbb{W})=\mathbb{W}$ であれば）部分空間である。</p></blockquote><p>また、次の定理が成り立つ。</p><blockquote class="prompt-info"><p><strong>定理 2</strong></p><ul><li><p>ベクトル空間 $\mathbb{V}$ の任意の部分集合 $S$ の生成空間 $\mathrm{span}(S)$ は、$S$ を含む $\mathbb{V}$ の部分空間である。</p>\[S \subset \mathrm{span}(S) \leq \mathbb{V} \quad \forall\ S \subset \mathbb{V}.\]<li><p>$S$ を含む $\mathbb{V}$ の部分空間は、必ず $S$ の生成空間を含む。</p>\[\mathbb{W}\supset \mathrm{span}(S) \quad \forall\ S \subset \mathbb{W} \leq \mathbb{V}.\]</ul></blockquote><blockquote class="prompt-info"><p><strong>定理 3</strong><br /> ベクトル空間 $\mathbb{V}$ の部分空間について、それらの任意の共通部分（交わり）は同様に $\mathbb{V}$ の部分空間である。</p></blockquote><h3 id="転置行列対称行列反対称行列">転置行列、対称行列、反対称行列</h3><p>$m \times n$ 行列 $A$ の<strong>転置行列（transpose matrix）</strong> $A^T$ は、$A$ の行と列を入れ替えた $n \times m$ 行列である。</p>\[(A^T)_{ij} = A_{ji}\] \[\begin{pmatrix} 1 &amp; 2 &amp; 3 \\ 4 &amp; 5 &amp; 6 \end{pmatrix}^T = \begin{pmatrix} 1 &amp; 4 \\ 2 &amp; 5 \\ 3 &amp; 6 \end{pmatrix}\]<p>$A^T = A$ を満たす行列 $A$ を<strong>対称行列（symmetric matrix）</strong>、$B^T = -B$ を満たす行列 $B$ を<strong>反対称行列（skew-symmetric matrix）</strong>という。対称行列と反対称行列はいずれも正方行列でなければならない。</p><p>それぞれ $\mathcal{M}_{n \times n}(F)$ のすべての対称行列、反対称行列を元とする 2 つの集合 $\mathbb{W}_1, \mathbb{W}_2$ は、$\mathcal{M}_{n \times n}(F)$ の部分空間である。すなわち、$\mathbb{W}_1, \mathbb{W}_2$ は和とスカラー積について閉じている。</p><h3 id="三角行列対角行列">三角行列、対角行列</h3><p>この 2 種類の行列もとくに重要である。</p><p>まず、次の 2 種類の行列をまとめて<strong>三角行列（triangular matrix）</strong>という。</p><ul><li><strong>上三角行列（upper triangular matrix）</strong>: 対角成分の下のすべての成分が $0$ の行列（すなわち $i&gt;j \Rightarrow A_{ij}=0$ の行列）。通常 $U$ と表す<li><strong>下三角行列（lower triangular matrix）</strong>: 対角成分の上のすべての成分が $0$ の行列（すなわち $i&lt;j \Rightarrow A_{ij}=0$ の行列）。通常 $L$ と表す</ul><p>対角成分以外のすべての成分が $0$ の正方行列、すなわち $i \neq j \Rightarrow M_{ij}=0$ の $n \times n$ 行列を<strong>対角行列（diagonal matrix）</strong>といい、通常 $D$ と表す。対角行列は上三角行列であると同時に下三角行列でもある。</p><p>上三角行列の集合、下三角行列の集合、対角行列の集合はいずれも $\mathcal{M}_{m \times n}(F)$ の部分空間である。</p>]]> </content> </entry> <entry><title xml:lang="ja">内積とノルム</title><link href="https://www.yunseo.kim/ja/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/inner-product-and-norm/" rel="alternate" type="text/html" hreflang="am" /><published>2025-09-10T00:00:00+09:00</published> <updated>2025-10-15T05:48:53+09:00</updated> <id>https://www.yunseo.kim/ja/posts/inner-product-and-norm/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Linear Algebra" /> <summary xml:lang="ja">ベクトルの内積（inner product）とドット積（dot product）の定義を整理し、そこからベクトルの長さ／ノルム、ベクトル間の角度の定義や基本性質（コーシー・シュワルツの不等式、三角不等式）まで解説します。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>ベクトルの内積（inner product）とドット積（dot product）の定義を整理し、そこからベクトルの長さ／ノルム、ベクトル間の角度の定義や基本性質（コーシー・シュワルツの不等式、三角不等式）まで解説します。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="前提知識">前提知識</h2><ul><li><a href="/ja/posts/vectors-and-linear-combinations/">ベクトルと線形結合</a></ul><h2 id="内積">内積</h2><p>一般の $F$-ベクトル空間における<strong>内積（inner product）</strong>の定義は次のとおりである。</p><blockquote class="prompt-info"><p><strong>内積（inner product）と内積空間（inner product space）の定義</strong><br /> $F$-ベクトル空間 $\mathbb{V}$ を考える。$\mathbb{V}$ における<strong>内積（inner product）</strong> $\langle \mathbf{x},\mathbf{y} \rangle$ は、$\mathbb{V}$ の任意のベクトル $\mathbf{x}$ と $\mathbf{y}$ の順序対を $F$ に属するスカラーに対応させる、次の条件を満たす関数として定義する。</p><p>任意の $\mathbf{x},\mathbf{y},\mathbf{z} \in \mathbb{V}$ と任意の $c \in F$ について</p><ol><li>$\langle \mathbf{x}+\mathbf{z}, \mathbf{y} \rangle = \langle \mathbf{x}, \mathbf{y} \rangle + \langle \mathbf{z}, \mathbf{y} \rangle$<li>$\langle c\mathbf{x}, \mathbf{y} \rangle = c \langle \mathbf{x}, \mathbf{y} \rangle$<li>$\overline{\langle \mathbf{x}, \mathbf{y} \rangle} = \langle \mathbf{y}, \mathbf{x} \rangle$（$\overline{\mathbf{z}}$ は $\mathbf{z}$ の複素共役）<li>$\mathbf{x} \neq \mathbf{0}$ のとき、$\langle \mathbf{x}, \mathbf{x} \rangle$ は正である。</ol><p>内積が与えられた $F$-ベクトル空間 $\mathbb{V}$ を<strong>内積空間（inner product space）</strong>という。特に $F=\mathbb{C}$ の場合を<strong>複素内積空間（complex inner product space）</strong>、$F=\mathbb{R}$ の場合を<strong>実内積空間（real inner product space）</strong>という。</p></blockquote><p>特に次の内積を<strong>標準内積（standard inner product）</strong>という。標準内積が前述の4条件をすべて満たすことが確かめられる。</p><blockquote class="prompt-info"><p><strong>標準内積（standard inner product）の定義</strong><br /> $F^n$ の二つのベクトル $\mathbf{x}=(a_1, a_2, \dots, a_n)$、$\mathbf{y}=(b_1, b_2, \dots, b_n)$ に対して、$F^n$ の<strong>標準内積（standard inner product）</strong>を次のように定義する。</p>\[\langle \mathbf{x}, \mathbf{y} \rangle = \sum_{i=1}^n a_i \overline{b_i}\]</blockquote><p>ここで $F=\mathbb{R}$ なら、実数の複素共役は自分自身なので、このときの標準内積は $\sum_{i=1}^n a_i b_i$ となる。特にこの場合の標準内積は $\langle \mathbf{x}, \mathbf{y} \rangle$ の代わりに $\mathbf{x} \cdot \mathbf{y}$ と表記し、<strong>ドット積（dot product）</strong>または<strong>スカラー積（scalar product）</strong>という。</p><blockquote class="prompt-info"><p><strong>ドット積（dot product）／スカラー積（scalar product）の定義</strong><br /> $\mathbb{R}^n$ の $\mathbf{v}=(v_1, v_2, \dots, v_n)$、$\mathbf{w}=(w_1, w_2, \dots, w_n)$ に対して、$\mathbb{R}^n$ の<strong>ドット積（dot product）</strong>または<strong>スカラー積（scalar product）</strong>を次のように定義する。</p>\[\mathbf{v} \cdot \mathbf{w} = \sum_{i=1}^n v_i w_i = v_1 w_1 + v_2 w_2 + \cdots + v_n w_n\]</blockquote><blockquote class="prompt-warning"><p>ここでいう「スカラー積（scalar product）」はベクトルどうしの演算であり、<a href="/ja/posts/vectors-and-linear-combinations/">ベクトルと線形結合</a>で扱ったスカラーとベクトルの間の演算である「スカラー倍（scalar multiplication）」とは別の演算である。英語表現も似ているうえに、<a href="https://www.kms.or.kr/mathdict/list.html?key=kname&amp;keyword=%EC%8A%A4%EC%B9%BC%EB%9D%BC%EA%B3%B1">大韓数学会の韓国語訳語基準では表記がまったく同一であるため</a>混同しないよう注意しよう。</p><p>混同を避けるため、以後は可能なかぎり<strong>ドット積（dot product）</strong>と呼ぶことにする。</p></blockquote><blockquote class="prompt-tip"><p>ユークリッド空間での内積（inner product）はすなわちドット積（dot product）であるため、文脈上混同の余地がなければドット積を単に内積と呼ぶことも多い。ただし厳密には、内積はドット積を包含するより一般的な概念である。</p></blockquote><pre><code class="language-mermaid">flowchart TD
    A["内積（Inner Product）"] --&gt;|含む| B["標準内積（Standard Inner Product）"]
    B --&gt;|"F = R（実数体）の場合"| C["ドット積／スカラー積（Dot/Scalar Product）"]

    %% 含有（包含関係）の表記
    C -. 含まれる .-&gt; B
    B -. 含まれる .-&gt; A
</code></pre><h2 id="ベクトルの長さノルム">ベクトルの長さ／ノルム</h2><p>$\mathbb{R}^n$ におけるベクトル $\mathbf{v}=(v_1, v_2, \dots, v_n)$ に対して、$\mathbf{v}$ のユークリッドの長さは次のようにドット積を通じて定義する。</p>\[\| \mathbf{v} \| = \sqrt{\mathbf{v} \cdot \mathbf{v}} = \left[ \sum_{i=1}^n |v_i|^2 \right]^{1/2} = \sqrt{v_1^2 + v_2^2 + \cdots + v_n^2}\]<p>より一般には、任意の内積空間におけるベクトルの<strong>長さ（length）</strong>または<strong>ノルム（norm）</strong>を次のように定義する。</p>\[\| \mathbf{x} \| = \sqrt{\langle \mathbf{x}, \mathbf{x} \rangle}\]<p>一般の内積空間では、ベクトルのノルムについて次の重要な性質が成り立つ。</p><blockquote class="prompt-info"><p><strong>定理</strong><br /> $F$-内積空間 $\mathbb{V}$ と任意のベクトル $\mathbf{x}, \mathbf{y} \in \mathbb{V}$、スカラー $c \in F$ に対して次が成り立つ。</p><ol><li>$\|c\mathbf{x}\| = |c| \cdot \|\mathbf{x}\|$<li>次の二つが成り立つ。<ul><li>$\|\mathbf{x}\| = 0 \iff \mathbf{x}=\mathbf{0}$<li>$\|\mathbf{x}\| \geq 0 \ \forall \mathbf{x}$</ul><li><strong>コーシー・シュワルツの不等式（Cauchy-Schwarz inequality）</strong>: $| \langle \mathbf{x}, \mathbf{y} \rangle | \leq \|\mathbf{x}\| \cdot \|\mathbf{y}\|$（等号は $\mathbf{x}$ と $\mathbf{y}$ のどちらかが他方のスカラー倍のときに成り立つ）<li><strong>三角不等式（triangle inequality）</strong>: $\| \mathbf{x} + \mathbf{y} \| \leq \|\mathbf{x}\| + \|\mathbf{y}\|$（等号は $\mathbf{x}$ と $\mathbf{y}$ のどちらかが他方のスカラー倍で、かつ両者の向きが同じときに成り立つ）</ol></blockquote><h2 id="ベクトル間の角度と単位ベクトル">ベクトル間の角度と単位ベクトル</h2><p>長さが 1 のベクトルを<strong>単位ベクトル（unit vector）</strong>という。また、$\mathbb{R}^n$ における二つのベクトル $\mathbf{v}=(v_1, v_2, \dots, v_n)$、$\mathbf{w}=(w_1, w_2, \dots, w_n)$ に対して $\mathbf{v} \cdot \mathbf{w} = \|\mathbf{v}\| \cdot \|\mathbf{w}\| \cos\theta$ が成り立ち、これから $\mathbf{v}$ と $\mathbf{w}$ の間の角 $\theta$（$0 \leq \theta \leq \pi$）を求めることができる。</p>\[\theta = \arccos{\frac{\mathbf{v} \cdot \mathbf{w}}{\|\mathbf{v}\| \cdot \|\mathbf{w}\|}}\]<p>$\mathbf{v} \cdot \mathbf{w} = 0$ の場合、二つのベクトルは<strong>垂直（perpendicular）</strong>または<strong>直交（orthogonal）</strong>であるという。</p><blockquote class="prompt-tip"><p>二つのベクトル $\mathbf{v}$ と $\mathbf{w}$ が垂直のとき、</p>\[\begin{align*} \| \mathbf{v} + \mathbf{w} \|^2 &amp;= (\mathbf{v} + \mathbf{w}) \cdot (\mathbf{v} + \mathbf{w}) \\ &amp;= \mathbf{v} \cdot \mathbf{v} + \mathbf{v} \cdot \mathbf{w} + \mathbf{w} \cdot \mathbf{v} + \mathbf{w} \cdot \mathbf{w} \\ &amp;= \mathbf{v} \cdot \mathbf{v} + \mathbf{w} \cdot \mathbf{w} \\ &amp;= \|\mathbf{v}\|^2 + \|\mathbf{w}\|^2. \end{align*}\]</blockquote><p>これを任意の内積空間へ一般化すると次のようになる。</p><blockquote class="prompt-info"><p><strong>定義</strong><br /> 内積空間 $\mathbb{V}$ を考える。$\mathbb{V}$ のベクトル $\mathbf{x}, \mathbf{y}$ に対して $\langle \mathbf{x}, \mathbf{y} \rangle = 0$ であれば、二つのベクトルは<strong>直交（orthogonal）</strong>または<strong>垂直（perpendicular）</strong>であると定義する。さらに、</p><ol><li>$\mathbb{V}$ の部分集合 $S$ に対して、$S$ に属する相異なる任意の二つのベクトルが直交するとき、集合 $S$ を<strong>直交集合（orthogonal set）</strong>という。<li>$\|\mathbf{x}\|=1$ であるベクトル $\mathbf{x} \in \mathbb{V}$ を<strong>単位ベクトル（unit vector）</strong>という。<li>$\mathbb{V}$ の部分集合 $S$ が直交集合で、かつ単位ベクトルのみから成るとき、集合 $S$ を<strong>正規直交集合（orthonormal set）</strong>という。</ol></blockquote><p>集合 $S = { \mathbf{v}_1, \mathbf{v}_2, \dots }$ が正規直交集合であるための必要十分条件は $\langle \mathbf{v}_i, \mathbf{v}_j \rangle = \delta_{ij}$ である。ベクトルに零でないスカラーを掛けても直交性には影響しない。</p><p>零でない任意のベクトル $\mathbf{x}$ に対して $\cfrac{\mathbf{x}}{\|\mathbf{x}\|}$ は単位ベクトルであり、このように零でないベクトルに長さの逆数を掛けて単位ベクトルを得る操作を<strong>正規化（normalizing）</strong>という。</p>]]> </content> </entry> <entry><title xml:lang="ja">ベクトルと線形結合</title><link href="https://www.yunseo.kim/ja/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/vectors-and-linear-combinations/" rel="alternate" type="text/html" hreflang="am" /><published>2025-09-07T00:00:00+09:00</published> <updated>2025-10-28T20:47:49+09:00</updated> <id>https://www.yunseo.kim/ja/posts/vectors-and-linear-combinations/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Linear Algebra" /> <summary xml:lang="ja">ベクトルの定義と表現（矢印・成分表示）、基本演算（和・スカラー乗法）を整理し、線形結合と生成空間の概念をベクトル空間の観点から解説します.</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>ベクトルの定義と表現（矢印・成分表示）、基本演算（和・スカラー乗法）を整理し、線形結合と生成空間の概念をベクトル空間の観点から解説します.</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><ul><li><strong>ベクトルの定義</strong><ul><li><strong>狭い意味のベクトル（ユークリッド・ベクトル）</strong>: 大きさと方向を併せ持つ物理量<li><strong>広い意味、線形代数におけるベクトル</strong>: ベクトル空間の元</ul><li><strong>ベクトルの表現法</strong><ul><li><strong>矢印による表現法</strong>: ベクトルの大きさは矢印の長さで、方向は矢印の向きで表す。可視化しやすく直観的だが、4 次元以上の高次元ベクトルや非ユークリッド・ベクトルは表現が困難。<li><strong>成分表示</strong>: ベクトルの始点を座標空間の原点に置き、終点の座標でベクトルを表す方法。</ul><li><strong>ベクトルの基本演算</strong><ul><li><strong>和</strong>: $(a_1, a_2, \cdots, a_n) + (b_1, b_2, \cdots, b_n) := (a_1+b_1, a_2+b_2, \cdots, a_n+b_n)$<li><strong>スカラー乗法</strong>: $c(a_1, a_2, \cdots, a_n) := (ca_1, ca_2, \cdots, ca_n)$</ul><li><strong>ベクトルの線形結合</strong><ul><li>有限個のベクトル $\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n$ とスカラー $a_1, a_2, \dots, a_n$ に対して、$\mathbf{v} = a_1\mathbf{u}_1 + a_2\mathbf{u}_2 + \cdots + a_n\mathbf{u}_n$ となるベクトル $\mathbf{v}$ を $\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n$ の<strong>線形結合（linear combination）</strong>という<li>このとき $a_1, a_2, \dots, a_n$ をこの線形結合の<strong>係数（coefficient）</strong>という</ul></ul></blockquote><blockquote><ul><li><strong>生成空間（span）</strong><ul><li>ベクトル空間 $\mathbb{V}$ の空でない部分集合 $S$ に対して、$S$ のベクトルを用いて作られるすべての線形結合の集合 $\mathrm{span}(S)$<li>$\mathrm{span}(\emptyset) = {0}$ と定義<li>ベクトル空間 $\mathbb{V}$ の部分集合 $S$ に対して $\mathrm{span}(S) = \mathbb{V}$ なら、$S$ が $\mathbb{V}$ を生成する（generate または span）という</ul></ul></blockquote><h2 id="prerequisites">Prerequisites</h2><ul><li>座標平面／座標空間<li>体（field）</ul><h2 id="ベクトルとは何か">ベクトルとは何か？</h2><h3 id="狭い意味のベクトルユークリッドベクトル">狭い意味のベクトル：ユークリッド・ベクトル</h3><blockquote class="prompt-info"><p>力、速度、加速度など多くの物理量は大きさだけでなく方向の情報も持つ。このように大きさと方向を併せ持つ物理量を<strong>ベクトル（vector）</strong>という。</p></blockquote><p>上の定義が物理学の力学や高校数学で扱うベクトルの定義である。このように「有向線分の大きさと方向」という幾何学的意味を持ち、物理的直観に基づく狭義のベクトルは、厳密には<strong>ユークリッド・ベクトル（Euclidean vector）</strong>と呼ばれる。</p><h3 id="広い意味のベクトルベクトル空間の元">広い意味のベクトル：ベクトル空間の元</h3><p>線形代数では、上のユークリッド・ベクトルの定義より広い意味を持つ、より抽象的な代数的構造として次のようにベクトルを定義する。</p><blockquote class="prompt-info"><p><strong>定義</strong><br /> 体 $F$ 上の<strong>ベクトル空間（vector space）</strong>または<strong>線形空間（linear space）</strong> $\mathbb{V}$ とは、次の 8 条件を満たす 2 つの演算、<strong>和</strong>と<strong>スカラー乗法</strong>を持つ集合である。体 $F$ の元を<strong>スカラー（scalar）</strong>、ベクトル空間 $\mathbb{V}$ の元を<strong>ベクトル（vector）</strong>という。</p><ul><li><strong>和（sum）</strong>: $\mathbb{V}$ の 2 つの元 $\mathbf{x}, \mathbf{y}$ に対し、一意の元 $\mathbf{x} + \mathbf{y} \in \mathbb{V}$ を対応させる演算。このとき $\mathbf{x} + \mathbf{y}$ を $\mathbf{x}$ と $\mathbf{y}$ の<strong>和</strong>という。<li><strong>スカラー乗法（scalar multiplication）</strong>: 体 $F$ の元 $a$ とベクトル空間 $\mathbb{V}$ の元 $\mathbf{x}$ ごとに一意の元 $a\mathbf{x} \in \mathbb{V}$ を対応させる演算。このとき $a\mathbf{x}$ を $\mathbf{x}$ の<strong>スカラー倍（scalar multiple）</strong>という。</ul><ol><li>すべての $\mathbf{x},\mathbf{y} \in \mathbb{V}$ に対して $\mathbf{x} + \mathbf{y} = \mathbf{y} + \mathbf{x}$（加法の交換法則）<li>すべての $\mathbf{x},\mathbf{y},\mathbf{z} \in \mathbb{V}$ に対して $(\mathbf{x}+\mathbf{y})+\mathbf{z} = \mathbf{x}+(\mathbf{y}+\mathbf{z})$（加法の結合法則）<li>すべての $\mathbf{x} \in \mathbb{V}$ に対して $\mathbf{x} + \mathbf{0} = \mathbf{x}$ となる $\mathbf{0} \in \mathbb{V}$ が存在する（零ベクトル、加法に関する単位元）<li>各 $\mathbf{x} \in \mathbb{V}$ について、$\mathbf{x}+\mathbf{y}=\mathbf{0}$ を満たす $\mathbf{y} \in \mathbb{V}$ が存在する（加法に関する逆元）<li>各 $\mathbf{x} \in \mathbb{V}$ に対して $1\mathbf{x} = \mathbf{x}$（乗法に関する単位元）<li>すべての $a,b \in F$ とすべての $\mathbf{x} \in \mathbb{V}$ に対して $(ab)\mathbf{x} = a(b\mathbf{x})$（スカラー乗法の結合法則）<li>すべての $a \in F$ とすべての $\mathbf{x},\mathbf{y} \in \mathbb{V}$ に対して $a(\mathbf{x}+\mathbf{y}) = a\mathbf{x} + a\mathbf{y}$（加法に関するスカラー乗法の分配法則 1）<li>すべての $a,b \in F$ とすべての $\mathbf{x},\mathbf{y} \in \mathbb{V}$ に対して $(a+b)\mathbf{x} = a\mathbf{x} + b\mathbf{x}$（加法に関するスカラー乗法の分配法則 2）</ol></blockquote><p>この線形代数におけるベクトルの定義は、前述の<a href="#狭い-意味-の-ベクトル-ユークリッド-ベクトル">ユークリッド・ベクトル</a>まで包含する、より広い範囲の定義である。<a href="#狭い-意味-の-ベクトル-ユークリッド-ベクトル">ユークリッド・ベクトル</a>も上の 8 つの性質を満たすことを確認できる。</p><p>ベクトルの起源と発展は、力や物体の運動・回転、場といった概念を定量的に記述しようとする物理学の実用的課題と密接に結びついている。自然現象を数学的に表現する物理学的要請により、当初は<a href="#狭い-意味-の-ベクトル-ユークリッド-ベクトル">ユークリッド・ベクトル</a>としてベクトルの概念が提示され、その後、数学がこれらの物理的概念を一般化・理論化する過程で、ベクトル空間・内積・外積などの形式的構造を整備し、現在のベクトルの定義に至った。すなわち、ベクトルは物理学が求め、数学が確立した概念であり、純粋数学だけの産物というより、数学界と物理学界が緊密に交流しながら発展させてきた学際的な産物といえる。</p><p>古典力学で扱われてきた<a href="#狭い-意味-の-ベクトル-ユークリッド-ベクトル">ユークリッド・ベクトル</a>は、数学的には<a href="#広い-意味-の-ベクトル-ベクトル-空間の-元">より一般化された枠組み</a>で表すことができ、今日の物理学では<a href="#狭い-意味-の-ベクトル-ユークリッド-ベクトル">ユークリッド・ベクトル</a>だけでなく、ベクトル空間・関数空間といった数学で定義されたより抽象的な概念も積極的に活用して物理的意味を与える。ゆえにベクトルに関する二つの定義を単に「物理学的定義」「数学的定義」と捉えるのは適切でない。</p><p>ベクトル空間については後で詳しく見ることにし、まずは座標空間上で幾何学的に表現可能な狭義のベクトル、ユークリッド・ベクトルに焦点を当てる。直観的なユークリッド・ベクトルの例を先に押さえておくことは、のちに他のベクトルへ一般化する際にも理解の助けとなる。</p><h2 id="ベクトルの表現法">ベクトルの表現法</h2><h3 id="矢印による表現法">矢印による表現法</h3><p>幾何学的直観を最もよく生かした、よく見かける表現法である。ベクトルの大きさは矢印の長さで、ベクトルの方向は矢印の向きで表す。</p><p><img src="https://upload.wikimedia.org/wikipedia/commons/9/95/Vector_from_A_to_B.svg" alt="A から B へのベクトル" width="972" /></p><blockquote><p><em>画像の出典</em></p><ul><li>作者: ウィキペディアユーザー <a href="https://en.wikipedia.org/wiki/User:Nguyenthephuc">Nguyenthephuc</a><li>ライセンス: <a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">CC BY-SA 3.0</a></ul></blockquote><p>この表現法は直観的ではあるが、4 次元以上の高次元ベクトルに対しては矢印での表現には明確な限界がある。さらに将来的には、そもそも幾何学的に表現しにくい非ユークリッド・ベクトルも扱う必要があるため、後述する成分表示に慣れておくことが望ましい。</p><h3 id="成分表示">成分表示</h3><p>ベクトルがどこに位置するかに関わらず、大きさと方向が同じであれば同一のベクトルとみなす。したがって、ある座標空間が与えられたとき、ベクトルの始点をその座標空間の原点に固定すると、<u>$n$ 次元ベクトルは $n$ 次元空間上の任意の点に対応</u>し、この場合、終点の座標でベクトルを表すことができる。このような表現法をベクトルの<strong>成分表示</strong>という。</p>\[(a_1, a_2, \cdots, a_n) \in \mathbb{R}^n \text{ or } \mathbb{C}^n\]<p><img src="https://upload.wikimedia.org/wikipedia/commons/5/5d/Position_vector.svg" alt="位置ベクトル" /></p><blockquote><p><em>画像の出典</em></p><ul><li>作者: ウィキメディアユーザー <a href="https://commons.wikimedia.org/wiki/User:Acdx">Acdx</a><li>ライセンス: <a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">CC BY-SA 3.0</a></ul></blockquote><h2 id="ベクトルの基本演算">ベクトルの基本演算</h2><p>ベクトルの基本演算は<strong>和</strong>と<strong>スカラー乗法</strong>の二つである。すべてのベクトル演算はこの二つの基本演算の組み合わせで表現できる。</p><h3 id="ベクトルの和">ベクトルの和</h3><p>二つのベクトルの和はやはりベクトルであり、このとき合成ベクトルの成分は、二つのベクトルの対応する成分同士をそれぞれ足したものに等しい。</p>\[(a_1, a_2, \cdots, a_n) + (b_1, b_2, \cdots, b_n) := (a_1+b_1, a_2+b_2, \cdots, a_n+b_n)\]<h3 id="ベクトルのスカラー乗法">ベクトルのスカラー乗法</h3><p>ベクトルは大きさを拡大・縮小でき、これをベクトルに定数（スカラー）を掛けるスカラー乗法という演算で表す。あるベクトルを定数倍した結果は、各成分を定数倍したものに等しい。</p>\[c(a_1, a_2, \cdots, a_n) := (ca_1, ca_2, \cdots, ca_n)\]<p><img src="https://upload.wikimedia.org/wikipedia/commons/1/1b/Scalar_multiplication_of_vectors2.svg" alt="ベクトルのスカラー乗法" /></p><blockquote><p><em>画像の出典</em></p><ul><li>作者: ウィキペディアユーザー <a href="https://en.wikipedia.org/wiki/User:Silly_rabbit">Silly rabbit</a><li>ライセンス: <a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">CC BY-SA 3.0</a></ul></blockquote><h2 id="ベクトルの線形結合">ベクトルの線形結合</h2><p>微積分学が数 $x$ と関数 $f(x)$ から出発するように、線形代数はベクトル $\mathbf{v}, \mathbf{w}, \dots$ と線形結合 $c\mathbf{v} + d\mathbf{w} + \cdots$ から出発する。そしてベクトルのあらゆる線形結合は、上の二つの基本演算、<a href="#ベクトルの-和">和</a>と<a href="#ベクトルの-スカラー乗法">スカラー乗法</a>の組み合わせで構成される。</p><blockquote class="prompt-info"><p>有限個のベクトル $\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n$ とスカラー $a_1, a_2, \dots, a_n$ に対して、次式を満たすベクトル $\mathbf{v}$ を $\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_n$ の<strong>線形結合（linear combination）</strong>という。</p>\[\mathbf{v} = a_1\mathbf{u}_1 + a_2\mathbf{u}_2 + \cdots + a_n\mathbf{u}_n\]<p>このとき、$a_1, a_2, \dots, a_n$ をこの線形結合の<strong>係数（coefficient）</strong>という。</p></blockquote><p>では、なぜ線形結合が重要なのか。次のような、<strong>$m$ 次元空間上の $n$ 個のベクトルが $m \times n$ 行列の $n$ 本の列を成す状況</strong>を考えよう。</p>\[\begin{gather*} \mathbf{v}_1 = (a_{11}, a_{21}, \dots, a_{m1}), \\ \mathbf{v}_2 = (a_{12}, a_{22}, \dots, a_{m2}), \\ \vdots \\ \mathbf{v}_n = (a_{1n}, a_{2n}, \dots, a_{mn}) \\ \\ A = \Bigg[ \mathbf{v}_1 \quad \mathbf{v}_2 \quad \cdots \quad \mathbf{v}_n \Bigg] \end{gather*}\]<p>ここでの要点は次の二つである。</p><ol><li><strong>あらゆる可能な線形結合 $Ax = x_1\mathbf{v}_1 + x_2\mathbf{v}_2 + \cdots x_n\mathbf{v}_n$ を表してみよ。</strong> それは何を成すか？<li>望む出力ベクトル $Ax = b$ を作り出す<strong>数 $x_1, x_2, \dots, x_n$ を求めよ。</strong></ol><p>二つ目の問いへの答えは後で改めて扱うとして、いったん今は一つ目の問いに集中しよう。議論を簡単にするため、$\mathbf{0}$ でない 2 次元（$m=2$）のベクトル 2 本（$n=2$）の場合を例に見てみる。</p><h3 id="線形結合-cmathbfv--dmathbfw">線形結合 $c\mathbf{v} + d\mathbf{w}$</h3><p>2 次元空間上のベクトル $\mathbf{v}$ は 2 つの成分を持つ。任意のスカラー $c$ に対して、<u>ベクトル $c\mathbf{v}$ は元のベクトル $\mathbf{v}$ と平行で、原点を通る $xy$ 平面上の無限に長い直線を成す。</u></p><p>ここで与えられた二つ目のベクトル $\mathbf{w}$ がこの直線上にない（ベクトル $\mathbf{v}$ と $\mathbf{w}$ が平行でない）なら、ベクトル $d\mathbf{w}$ はもう一方の二本目の直線を成す。さてこの二本の直線を組み合わせると、<strong>線形結合 $c\mathbf{v} + d\mathbf{w}$ は原点を含む一つの平面を成す</strong>ことがわかる。</p><p><img src="https://upload.wikimedia.org/wikipedia/commons/6/6f/Linjcomb.png" alt="2 本のベクトルの線形結合" /></p><blockquote><p><em>画像の出典</em></p><ul><li>作者: ウィキメディアユーザー <a href="https://commons.wikimedia.org/wiki/User:Svjo">Svjo</a><li>ライセンス: <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">CC BY-SA 4.0</a></ul></blockquote><h3 id="生成">生成</h3><p>このようにベクトルの線形結合はすなわちベクトル空間を成し、これを空間の<strong>生成（span）</strong>という。</p><blockquote class="prompt-info"><p><strong>定義</strong><br /> ベクトル空間 $\mathbb{V}$ の空でない部分集合 $S$ に対して、$S$ のベクトルを用いて作られるすべての線形結合の集合を $S$ の<strong>生成空間（span）</strong>といい、$\mathrm{span}(S)$ と表記する。ただし、$\mathrm{span}(\emptyset) = {0}$ と定義する。</p></blockquote><blockquote class="prompt-info"><p><strong>定義</strong><br /> ベクトル空間 $\mathbb{V}$ の部分集合 $S$ に対して $\mathrm{span}(S) = \mathbb{V}$ なら、$S$ が $\mathbb{V}$ を生成する（generate または span）という。</p></blockquote><p>まだ部分空間や基底といった概念は見ていないが、今のこの例を思い出せばベクトル空間の概念を理解する助けになる。</p>]]> </content> </entry> <entry><title xml:lang="ja">Kaggle「Pandas」講座の内容整理（2）- Lesson 4-6</title><link href="https://www.yunseo.kim/ja/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/summary-of-kaggle-pandas-course-2/" rel="alternate" type="text/html" hreflang="am" /><published>2025-08-24T00:00:00+09:00</published> <updated>2025-08-24T00:00:00+09:00</updated> <id>https://www.yunseo.kim/ja/posts/summary-of-kaggle-pandas-course-2/</id> <author> <name>Yunseo Kim</name> </author> <category term="AI & Data" /> <category term="Machine Learning" /> <summary xml:lang="ja">データ整形・加工に役立つPandasの使い方を体系的に整理。Kaggle公開コース「Pandas」を要約し、必要に応じて補足。後編（Lesson 4–6：グループ化とソート、データ型と欠損値、リネームと結合）を解説する。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>データ整形・加工に役立つPandasの使い方を体系的に整理。Kaggle公開コース「Pandas」を要約し、必要に応じて補足。後編（Lesson 4–6：グループ化とソート、データ型と欠損値、リネームと結合）を解説する。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><p>Kaggleの<a href="https://www.kaggle.com/learn/pandas">Pandas</a>講座で学んだ内容をここに整理する。<br /> 分量が多いため 2 回に分けた。</p><ul><li><a href="/ja/posts/summary-of-kaggle-pandas-course-1/">第1編: Lesson 1-3</a><li>第2編: Lesson 4-6（本文）</ul><p><img src="/assets/img/kaggle-pandas/certificate.png" alt="修了証明書" /></p><h2 id="lesson-4-grouping-and-sorting">Lesson 4. Grouping and Sorting</h2><p>しばしばデータを分類し、グループごとに集計や操作を行ったり、特定の基準で並べ替える必要がある。</p><h3 id="グループ別の分析">グループ別の分析</h3><p><a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.groupby.html"><code class="language-plaintext highlighter-rouge">groupby()</code></a>メソッドを使うと、特定の列の値が同じデータ同士をまとめ、その後に各グループ単位での概要確認や操作を行える。</p><p>先に<a href="/ja/posts/summary-of-kaggle-pandas-course-1/#データ概要の確認"><code class="language-plaintext highlighter-rouge">value_counts()</code> メソッド</a>を見たが、同等の動作は <code class="language-plaintext highlighter-rouge">groupby()</code> でも次のように実装できる。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="nf">groupby</span><span class="p">(</span><span class="sh">'</span><span class="s">taster_name</span><span class="sh">'</span><span class="p">).</span><span class="nf">size</span><span class="p">()</span>
</pre></div></div><ol><li>データフレーム <code class="language-plaintext highlighter-rouge">reviews</code> を、<code class="language-plaintext highlighter-rouge">taster_name</code> 列の値が同じもの同士でグループ化<li>まとめた各グループの大きさ（所属レコード数）をシリーズで返す</ol><p>または</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="nf">groupby</span><span class="p">(</span><span class="sh">'</span><span class="s">taster_name</span><span class="sh">'</span><span class="p">).</span><span class="n">taster_name</span><span class="p">.</span><span class="nf">count</span><span class="p">()</span>
</pre></div></div><ol><li>データフレーム <code class="language-plaintext highlighter-rouge">reviews</code> を、<code class="language-plaintext highlighter-rouge">taster_name</code> 列の値が同じもの同士でグループ化<li>まとめた各グループについて <code class="language-plaintext highlighter-rouge">taster_name</code> 列を選択<li>該当列の欠損を除いた有効件数をシリーズで返す</ol><p>つまり <code class="language-plaintext highlighter-rouge">value_counts()</code> は、実のところ上のような一連の操作のショートカットである。<a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.count.html"><code class="language-plaintext highlighter-rouge">count()</code></a> 以外にも任意の概要関数をこの要領で活用できる。たとえばワインデータから評価点ごとの最安値を確認するなら次のとおり。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="nf">groupby</span><span class="p">(</span><span class="sh">'</span><span class="s">points</span><span class="sh">'</span><span class="p">).</span><span class="n">price</span><span class="p">.</span><span class="nf">min</span><span class="p">()</span>
</pre></div></div><div class="language-plaintext highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
</pre><td class="rouge-code"><pre>points
80      5.0
81      5.0
       ... 
99     44.0
100    80.0
Name: price, Length: 21, dtype: float64
</pre></div></div><ol><li>データフレーム <code class="language-plaintext highlighter-rouge">reviews</code> を、<code class="language-plaintext highlighter-rouge">points</code> 列の値が同じもの同士でグループ化<li>まとめた各グループについて <code class="language-plaintext highlighter-rouge">price</code> 列を選択<li>該当データの最小値をシリーズで返す</ol><p>2 列以上をキーにして分類することも可能。国別・州別に評価が最も高いワインの情報だけ選ぶなら次のとおり。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="nf">groupby</span><span class="p">([</span><span class="sh">'</span><span class="s">country</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">province</span><span class="sh">'</span><span class="p">]).</span><span class="nf">apply</span><span class="p">(</span><span class="k">lambda</span> <span class="n">df</span><span class="p">:</span> <span class="n">df</span><span class="p">.</span><span class="n">loc</span><span class="p">[</span><span class="n">df</span><span class="p">.</span><span class="n">points</span><span class="p">.</span><span class="nf">idxmax</span><span class="p">()])</span>
</pre></div></div><p>DataFrameGroupBy オブジェクトで覚えておくと便利なメソッドに <a href="https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.agg.html"><code class="language-plaintext highlighter-rouge">agg()</code></a> がある。これを使うとグループ化後に各グループへ複数の関数を同時に適用できる。</p><blockquote class="prompt-tip"><p>このとき引数には次を渡せる。</p><ul><li>関数<li>関数名の文字列<li>関数または関数名文字列のリスト<li>軸ラベルをキー、その軸に適用する関数または関数リストを値とする辞書</ul><p>ここで関数は</p><ul><li>データフレームを入力として受け取れるか、<li><a href="/ja/posts/summary-of-kaggle-pandas-course-1/#写像maps">前述の</a> <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.apply.html"><code class="language-plaintext highlighter-rouge">DataFrame.apply()</code></a> に引数として渡せる</ul><p>ものである必要がある。原講座にはない補足で、Pandas 公式ドキュメントに基づき加筆した。</p></blockquote><p>たとえば次のように国別の価格統計量を算出できる。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="nf">groupby</span><span class="p">([</span><span class="sh">'</span><span class="s">country</span><span class="sh">'</span><span class="p">]).</span><span class="n">price</span><span class="p">.</span><span class="nf">agg</span><span class="p">([</span><span class="nb">len</span><span class="p">,</span> <span class="nb">min</span><span class="p">,</span> <span class="nb">max</span><span class="p">])</span>
</pre></div></div><blockquote class="prompt-tip"><p>ここでの <code class="language-plaintext highlighter-rouge">len</code> は Python 組み込み関数 <a href="https://docs.python.org/3/library/functions.html#len"><code class="language-plaintext highlighter-rouge">len()</code></a> を指す。本例では、<u>欠損を含む</u>グループ（<code class="language-plaintext highlighter-rouge">country</code>）ごとの価格（<code class="language-plaintext highlighter-rouge">price</code>）データ件数を出力するために用いている。データフレームやシリーズを入力に動作できる関数なので、このように使える。</p><p>Pandas の <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.count.html"><code class="language-plaintext highlighter-rouge">count()</code></a> は<u>欠損を除いた有効値のみ</u>を数える点で動作が異なる。</p><p>いずれも原講座にはない補足で、Python と Pandas の公式ドキュメントに基づき加筆した。</p></blockquote><h3 id="マルチインデックス">マルチインデックス</h3><p><code class="language-plaintext highlighter-rouge">groupby()</code> による加工・分析では、単一ラベルではなく 2 段以上の階層からなるマルチインデックスを持つデータフレームが返ることがある。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
</pre><td class="rouge-code"><pre><span class="n">countries_reviewed</span> <span class="o">=</span> <span class="n">reviews</span><span class="p">.</span><span class="nf">groupby</span><span class="p">([</span><span class="sh">'</span><span class="s">country</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">province</span><span class="sh">'</span><span class="p">]).</span><span class="n">description</span><span class="p">.</span><span class="nf">agg</span><span class="p">([</span><span class="nb">len</span><span class="p">])</span>
<span class="n">countries_reviewed</span>
</pre></div></div><table><tr><th><th><th>len<tr><th>Country<th>province<th><tr><td rowspan="2">Argentina<td>Mendoza Province<td>3264<tr><td>Other<td>536<tr><td>...<td>...<td>...<tr><td rowspan="2">Uruguay<td>San Jose<td>3<tr><td>Uruguay<td>24</table><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
</pre><td class="rouge-code"><pre><span class="n">mi</span> <span class="o">=</span> <span class="n">countries_reviewed</span><span class="p">.</span><span class="n">index</span>
<span class="nf">type</span><span class="p">(</span><span class="n">mi</span><span class="p">)</span>
</pre></div></div><div class="language-plaintext highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre>pandas.core.indexes.multi.MultiIndex
</pre></div></div><p>マルチインデックスは階層構造を扱うための、単一インデックスにはないメソッドをいくつか備える。詳細な用例や指針は <a href="https://pandas.pydata.org/pandas-docs/stable/user_guide/advanced.html">pandas User Guide の MultiIndex / advanced indexing セクション</a>に詳しい。</p><p>とはいえ、もっとも頻用するのは、通常のインデックスに戻すための <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.reset_index.html"><code class="language-plaintext highlighter-rouge">reset_index()</code></a> だろう。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">countries_reviewed</span><span class="p">.</span><span class="nf">reset_index</span><span class="p">()</span>
</pre></div></div><table><thead><tr><th> <th>country<th>province<th>len<tbody><tr><td>0<td>Argentina<td>Mendoza Province<td>3264<tr><td>1<td>Argentina<td>Other<td>536<tr><td>…<td>…<td>…<td>…<tr><td>423<td>Uruguay<td>San Jose<td>3<tr><td>424<td>Uruguay<td>Uruguay<td>24</table><h3 id="並べ替えソート">並べ替え（ソート）</h3><p>これまで例にしてきた <code class="language-plaintext highlighter-rouge">countries_reviewed</code> を見ると、グループ化の結果はインデックス順で返っていることがわかる。すなわち <code class="language-plaintext highlighter-rouge">groupby</code> 結果の行順は内容ではなくインデックス値で決まる。</p><p>必要に応じて別の基準で明示的に並べ替えられる。その際は <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sort_values.html"><code class="language-plaintext highlighter-rouge">sort_values()</code></a> が便利だ。たとえば次のように、含まれる件数（’len’）を基準に国と州の情報を昇順でソートできる。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
</pre><td class="rouge-code"><pre><span class="n">countries_reviewed</span> <span class="o">=</span> <span class="n">countries_reviewed</span><span class="p">.</span><span class="nf">reset_index</span><span class="p">()</span>
<span class="n">countries_reviewed</span><span class="p">.</span><span class="nf">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="sh">'</span><span class="s">len</span><span class="sh">'</span><span class="p">)</span>
</pre></div></div><table><thead><tr><th> <th>country<th>province<th>len<tbody><tr><td>179<td>Greece<td>Muscat of Kefallonian<td>1<tr><td>192<td>Greece<td>Sterea Ellada<td>1<tr><td>…<td>…<td>…<td>…<tr><td>415<td>US<td>Washington<td>8639<tr><td>392<td>US<td>California<td>36247</table><p><code class="language-plaintext highlighter-rouge">sort_values()</code> は既定で昇順（小→大）だが、次のようにオプションを指定すれば降順（大→小）も可能。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">countries_reviewed</span><span class="p">.</span><span class="nf">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="sh">'</span><span class="s">len</span><span class="sh">'</span><span class="p">,</span> <span class="n">ascending</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
</pre></div></div><table><thead><tr><th> <th>country<th>province<th>len<tbody><tr><td>392<td>US<td>California<td>36247<tr><td>415<td>US<td>Washington<td>8639<tr><td>…<td>…<td>…<td>…<tr><td>63<td>Chile<td>Coelemu<td>1<tr><td>149<td>Greece<td>Beotia<td>1</table><p>インデックスでソートするなら <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sort_index.html"><code class="language-plaintext highlighter-rouge">sort_index()</code></a>。<code class="language-plaintext highlighter-rouge">sort_values()</code> と同様の引数と既定順序（昇順）を持つ。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">countries_reviewed</span><span class="p">.</span><span class="nf">sort_index</span><span class="p">()</span>
</pre></div></div><table><thead><tr><th> <th>country<th>province<th>len<tbody><tr><td>0<td>Argentina<td>Mendoza Province<td>3264<tr><td>1<td>Argentina<td>Other<td>536<tr><td>…<td>…<td>…<td>…<tr><td>423<td>Uruguay<td>San Jose<td>3<tr><td>424<td>Uruguay<td>Uruguay<td>24</table><p>最後に、次のように複数列を同時に基準にしてソートすることも可能。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">countries_reviewed</span><span class="p">.</span><span class="nf">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="p">[</span><span class="sh">'</span><span class="s">country</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">len</span><span class="sh">'</span><span class="p">])</span>
</pre></div></div><h2 id="lesson-5-data-types-and-missing-values">Lesson 5. Data Types and Missing Values</h2><p>実務で扱うデータが常にきれいに整っている保証はない。多くの場合、型を変換したり、所々にある欠損値を適切に処理する必要がある。データの加工・分析で最大の難所になりがちなのがこの段階だ。</p><h3 id="データ型">データ型</h3><p>データフレームの特定の列、またはシリーズのデータ型を <strong>dtype</strong> という。<code class="language-plaintext highlighter-rouge">dtype</code> 属性で、与えられたデータフレームの特定列の型を確認できる。次は <code class="language-plaintext highlighter-rouge">reviews</code> の <code class="language-plaintext highlighter-rouge">price</code> 列の <code class="language-plaintext highlighter-rouge">dtype</code> を確認する例。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="n">price</span><span class="p">.</span><span class="n">dtype</span>
</pre></div></div><div class="language-plaintext highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre>dtype('float64')
</pre></div></div><p>あるいは <code class="language-plaintext highlighter-rouge">dtypes</code> 属性で、データフレーム内の全列の <code class="language-plaintext highlighter-rouge">dtype</code> を一度に確認できる。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="n">dtypes</span>
</pre></div></div><div class="language-plaintext highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
</pre><td class="rouge-code"><pre>country        object
description    object
                ...  
variety        object
winery         object
Length: 13, dtype: object
</pre></div></div><p>データ型は Pandas が内部的にどのようにデータを保持しているかを示す。たとえば <code class="language-plaintext highlighter-rouge">float64</code> は 64 ビット浮動小数、<code class="language-plaintext highlighter-rouge">int64</code> は 64 ビット整数を意味する。</p><p>もう一つの特徴として、文字列だけで構成される列は独自の型を持たず、単にオブジェクト（<code class="language-plaintext highlighter-rouge">object</code>）として扱われる。</p><p><a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.astype.html"><code class="language-plaintext highlighter-rouge">astype()</code></a> を使うと、ある型の列を別の型へ変換できる。たとえば、先の例で <code class="language-plaintext highlighter-rouge">int64</code> 型だった <code class="language-plaintext highlighter-rouge">points</code> 列を <code class="language-plaintext highlighter-rouge">float64</code> に変換できる。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="n">points</span><span class="p">.</span><span class="nf">astype</span><span class="p">(</span><span class="sh">'</span><span class="s">float64</span><span class="sh">'</span><span class="p">)</span>
</pre></div></div><div class="language-plaintext highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
</pre><td class="rouge-code"><pre>0         87.0
1         87.0
          ... 
129969    90.0
129970    90.0
Name: points, Length: 129971, dtype: float64
</pre></div></div><p>データフレームやシリーズのインデックスも同様にデータ型を持つ。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="n">index</span><span class="p">.</span><span class="n">dtype</span>
</pre></div></div><div class="language-plaintext highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre>dtype('int64')
</pre></div></div><p>Pandas はこのほか、カテゴリ型や時系列型といった拡張データ型もサポートする。</p><h3 id="欠損値">欠損値</h3><p>値がなく空のエントリには <code class="language-plaintext highlighter-rouge">NaN</code>（“Not a Number” の略）が与えられる。技術的理由により <code class="language-plaintext highlighter-rouge">NaN</code> は常に <code class="language-plaintext highlighter-rouge">float64</code> 型である。</p><p>Pandas は欠損に特化した関数をいくつか提供する。<a href="/ja/posts/summary-of-kaggle-pandas-course-1/#条件付き選択">以前にも軽く触れたが</a>、メソッドではない独立関数として <a href="https://pandas.pydata.org/docs/reference/api/pandas.isna.html"><code class="language-plaintext highlighter-rouge">pd.isna</code></a> と <a href="https://pandas.pydata.org/docs/reference/api/pandas.notna.html"><code class="language-plaintext highlighter-rouge">pd.notna</code></a> がある。与えられたエントリが欠損か否かを単一のブール値またはブール配列で返し、次のように応用できる。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">[</span><span class="n">pd</span><span class="p">.</span><span class="nf">isna</span><span class="p">(</span><span class="n">reviews</span><span class="p">.</span><span class="n">country</span><span class="p">)]</span>
</pre></div></div><p>通常は、与えられたデータに欠損があるかを確認し、あれば適切に埋める必要がある。戦略はいくつかあるが、まず <a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.fillna.html"><code class="language-plaintext highlighter-rouge">fillna()</code></a> を使えば欠損を所定の値に置き換えて埋められる。次は <code class="language-plaintext highlighter-rouge">reviews</code> の <code class="language-plaintext highlighter-rouge">region_2</code> 列のすべての <code class="language-plaintext highlighter-rouge">NaN</code> を <code class="language-plaintext highlighter-rouge">"Unknown"</code> に置き換える例。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="n">region_2</span><span class="p">.</span><span class="nf">fillna</span><span class="p">(</span><span class="sh">"</span><span class="s">Unknown</span><span class="sh">"</span><span class="p">)</span>
</pre></div></div><p>あるいは、欠損の前方または後方で最も近い有効値を持ってきて埋める forward fill / backward fill 戦略を使える。これはそれぞれ <a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.ffill.html"><code class="language-plaintext highlighter-rouge">ffill()</code></a>、<a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.bfill.html"><code class="language-plaintext highlighter-rouge">bfill()</code></a> で実装できる。</p><blockquote class="prompt-danger"><p>かつては <code class="language-plaintext highlighter-rouge">fillna()</code> の <code class="language-plaintext highlighter-rouge">method</code> 引数に <code class="language-plaintext highlighter-rouge">'ffill'</code>、<code class="language-plaintext highlighter-rouge">'bfill'</code> を渡す方法もあったが、Pandas 2.1.0 以降は非推奨（deprecated）となったため、代わりに状況に応じて <code class="language-plaintext highlighter-rouge">ffill()</code> または <code class="language-plaintext highlighter-rouge">bfill()</code> を用いるべきである。</p></blockquote><p>場合によっては、欠損でなくとも特定の値を一括で別の値に置換したいことがある。原講座では特定のレビュアーの Twitter ハンドルが変更された例を挙げているが、日本の読者にも身近な別例を考えてみよう。</p><p>たとえば大韓民国で京畿道北部を分割して<strong>京畿北道</strong>という新しい行政区を設置し、その名称を反映したデータセットがあるとする。ところが誰かが<strong>京畿北道</strong>というまっとうな名前を<strong>平和ヌリ特別自治道</strong>に変えようというトンデモ案を出して、それが強行採択されてしまった仮想の状況を想像してみてほしい。<del>仮想の話だが、似たような事態が現実に起こりかけたのが怖いところだ。</del> そうなると既存データセットの <code class="language-plaintext highlighter-rouge">"Gyeonggibuk-do"</code> を <code class="language-plaintext highlighter-rouge">"Pyeonghwanuri State"</code> もしくは <code class="language-plaintext highlighter-rouge">"Pyeonghwanuri Special Self-Governing Province"</code> のような新しい値に置き換える必要がある。Pandas でこの作業を行う方法の一つが <a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.replace.html"><code class="language-plaintext highlighter-rouge">replace()</code></a> だ。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">rok_2030_census</span><span class="p">.</span><span class="n">province</span><span class="p">.</span><span class="nf">replace</span><span class="p">(</span><span class="sh">"</span><span class="s">Gyeonggibuk-do</span><span class="sh">"</span><span class="p">,</span> <span class="sh">"</span><span class="s">Pyeonghwanuri Special Self-Governing Province</span><span class="sh">"</span><span class="p">)</span>
</pre></div></div><p>この例を使えば、<code class="language-plaintext highlighter-rouge">rok_2030_census</code> の <code class="language-plaintext highlighter-rouge">province</code> 列にある <code class="language-plaintext highlighter-rouge">"Gyeonggibuk-do"</code> を、その“長いほう”へ一括置換できる。<del>こんなコードを本当に回さねばならない現実にならなかったことに、改めて安堵する。</del></p><p>この種の文字列置換は、欠損処理やデータクリーニングでも有効だ。というのも、欠損が <code class="language-plaintext highlighter-rouge">NaN</code> ではなく <code class="language-plaintext highlighter-rouge">"Unknown"</code>、<code class="language-plaintext highlighter-rouge">"Undisclosed"</code>、<code class="language-plaintext highlighter-rouge">"Invalid"</code> のような文字列で与えられることも多いからである。現実には、昔の公文書を OCR スキャンしてデータ化するといった作業では、むしろこの種のケースが大半を占めることもある。</p><h2 id="lesson-6-renaming-and-combining">Lesson 6. Renaming and Combining</h2><p>ときにはデータセット内の特定列やインデックス名を変更する必要がある。また、複数のデータフレームやシリーズを結合する場面も多い。</p><h3 id="名前の変更">名前の変更</h3><p><a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.rename.html"><code class="language-plaintext highlighter-rouge">rename()</code></a> を使うと、データセット内の特定列やインデックス名を変更できる。入力形式はいくつかあるが、通常は Python の辞書を使うのが簡便だ。次は <code class="language-plaintext highlighter-rouge">reviews</code> データフレームで <code class="language-plaintext highlighter-rouge">points</code> 列名を <code class="language-plaintext highlighter-rouge">score</code> に変え、インデックスの <code class="language-plaintext highlighter-rouge">0</code>、<code class="language-plaintext highlighter-rouge">1</code> を <code class="language-plaintext highlighter-rouge">firstEntry</code>、<code class="language-plaintext highlighter-rouge">secondEntry</code> に変える例。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="nf">rename</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="p">{</span><span class="sh">'</span><span class="s">points</span><span class="sh">'</span><span class="p">:</span> <span class="sh">'</span><span class="s">score</span><span class="sh">'</span><span class="p">})</span>
</pre></div></div><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="nf">rename</span><span class="p">(</span><span class="n">index</span><span class="o">=</span><span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="sh">'</span><span class="s">firstEntry</span><span class="sh">'</span><span class="p">,</span> <span class="mi">1</span><span class="p">:</span> <span class="sh">'</span><span class="s">secondEntry</span><span class="sh">'</span><span class="p">})</span>
</pre></div></div><p>実際のところ列名の変更は頻繁に行うが、インデックス値のリネームはほとんどない。その用途には、<a href="/ja/posts/summary-of-kaggle-pandas-course-1/#インデックスの操作">以前見たように</a> <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.set_index.html"><code class="language-plaintext highlighter-rouge">set_index()</code></a> を使うほうが楽なことが多い。</p><p>行インデックスと列インデックス自体にも <code class="language-plaintext highlighter-rouge">name</code> 属性があり、<code class="language-plaintext highlighter-rouge">rename_axis()</code> を使うとこの軸名も変更できる。たとえば行インデックス軸に <code class="language-plaintext highlighter-rouge">wines</code>、列軸に <code class="language-plaintext highlighter-rouge">fields</code> と名前を付けられる。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre><td class="rouge-code"><pre><span class="n">reviews</span><span class="p">.</span><span class="nf">rename_axis</span><span class="p">(</span><span class="sh">"</span><span class="s">wines</span><span class="sh">"</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="sh">'</span><span class="s">index</span><span class="sh">'</span><span class="p">).</span><span class="nf">rename_axis</span><span class="p">(</span><span class="sh">"</span><span class="s">fields</span><span class="sh">"</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="sh">'</span><span class="s">columns</span><span class="sh">'</span><span class="p">)</span>
</pre></div></div><h3 id="データセットの結合">データセットの結合</h3><p>データフレーム同士、あるいはシリーズ同士を結合しなければならないことがある。Pandas はこのために、単純なものから複雑なものへと並べると、<a href="https://pandas.pydata.org/docs/reference/api/pandas.concat.html"><code class="language-plaintext highlighter-rouge">concat()</code></a>、<a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.join.html"><code class="language-plaintext highlighter-rouge">join()</code></a>、<a href="https://pandas.pydata.org/docs/reference/api/pandas.merge.html"><code class="language-plaintext highlighter-rouge">merge()</code></a> の 3 つの中核関数を提供する。Kaggle 講座では、<code class="language-plaintext highlighter-rouge">merge()</code> でできることの大半は <code class="language-plaintext highlighter-rouge">join()</code> のほうが簡潔に書けるため、前者 2 つに焦点を当てている。</p><p><code class="language-plaintext highlighter-rouge">concat()</code> は最も単純で、複数のデータフレームまたはシリーズを、指定した軸に沿ってそのまま連結する。同じフィールド（列）構成のデータを結合する際に有用。既定では行（インデックス）方向に連結し、<code class="language-plaintext highlighter-rouge">axis=1</code> または <code class="language-plaintext highlighter-rouge">axis='columns'</code> を指定すれば列方向に連結できる。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
</pre><td class="rouge-code"><pre><span class="o">&gt;&gt;&gt;</span> <span class="n">s1</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="nc">Series</span><span class="p">([</span><span class="sh">'</span><span class="s">a</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">b</span><span class="sh">'</span><span class="p">])</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">s2</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="nc">Series</span><span class="p">([</span><span class="sh">'</span><span class="s">c</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">d</span><span class="sh">'</span><span class="p">])</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">pd</span><span class="p">.</span><span class="nf">concat</span><span class="p">([</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">])</span>
<span class="mi">0</span>    <span class="n">a</span>
<span class="mi">1</span>    <span class="n">b</span>
<span class="mi">0</span>    <span class="n">c</span>
<span class="mi">1</span>    <span class="n">d</span>
<span class="n">dtype</span><span class="p">:</span> <span class="nb">object</span>
</pre></div></div><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre><td class="rouge-code"><pre><span class="o">&gt;&gt;&gt;</span> <span class="n">df1</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="nc">DataFrame</span><span class="p">([[</span><span class="sh">'</span><span class="s">a</span><span class="sh">'</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="sh">'</span><span class="s">b</span><span class="sh">'</span><span class="p">,</span> <span class="mi">2</span><span class="p">]],</span>
<span class="p">...</span>                    <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="sh">'</span><span class="s">letter</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">number</span><span class="sh">'</span><span class="p">])</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">df1</span>
  <span class="n">letter</span>  <span class="n">number</span>
<span class="mi">0</span>      <span class="n">a</span>       <span class="mi">1</span>
<span class="mi">1</span>      <span class="n">b</span>       <span class="mi">2</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">df2</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="nc">DataFrame</span><span class="p">([[</span><span class="sh">'</span><span class="s">c</span><span class="sh">'</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="p">[</span><span class="sh">'</span><span class="s">d</span><span class="sh">'</span><span class="p">,</span> <span class="mi">4</span><span class="p">]],</span>
<span class="p">...</span>                    <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="sh">'</span><span class="s">letter</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">number</span><span class="sh">'</span><span class="p">])</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">df2</span>
  <span class="n">letter</span>  <span class="n">number</span>
<span class="mi">0</span>      <span class="n">c</span>       <span class="mi">3</span>
<span class="mi">1</span>      <span class="n">d</span>       <span class="mi">4</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">pd</span><span class="p">.</span><span class="nf">concat</span><span class="p">([</span><span class="n">df1</span><span class="p">,</span> <span class="n">df2</span><span class="p">])</span>
  <span class="n">letter</span>  <span class="n">number</span>
<span class="mi">0</span>      <span class="n">a</span>       <span class="mi">1</span>
<span class="mi">1</span>      <span class="n">b</span>       <span class="mi">2</span>
<span class="mi">0</span>      <span class="n">c</span>       <span class="mi">3</span>
<span class="mi">1</span>      <span class="n">d</span>       <span class="mi">4</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">df4</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="nc">DataFrame</span><span class="p">([[</span><span class="sh">'</span><span class="s">bird</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">polly</span><span class="sh">'</span><span class="p">],</span> <span class="p">[</span><span class="sh">'</span><span class="s">monkey</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">george</span><span class="sh">'</span><span class="p">]],</span>
<span class="p">...</span>                    <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="sh">'</span><span class="s">animal</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">name</span><span class="sh">'</span><span class="p">])</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">df4</span>
   <span class="n">animal</span>    <span class="n">name</span>
<span class="mi">0</span>    <span class="n">bird</span>   <span class="n">polly</span>
<span class="mi">1</span>  <span class="n">monkey</span>  <span class="n">george</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">pd</span><span class="p">.</span><span class="nf">concat</span><span class="p">([</span><span class="n">df1</span><span class="p">,</span> <span class="n">df4</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
  <span class="n">letter</span>  <span class="n">number</span>  <span class="n">animal</span>    <span class="n">name</span>
<span class="mi">0</span>      <span class="n">a</span>       <span class="mi">1</span>    <span class="n">bird</span>   <span class="n">polly</span>
<span class="mi">1</span>      <span class="n">b</span>       <span class="mi">2</span>  <span class="n">monkey</span>  <span class="n">george</span>
</pre></div></div><blockquote class="prompt-tip"><p><a href="(https://pandas.pydata.org/docs/reference/api/pandas.concat.html)">Pandas 公式ドキュメント</a>によれば、複数行を 1 つのデータフレームにまとめたいとき、ループの内側で 1 行ずつ追加するのは非推奨であり、結合対象の行をリストに集めて単一の <code class="language-plaintext highlighter-rouge">concat()</code> で一度に結合すべきである。</p></blockquote><p><code class="language-plaintext highlighter-rouge">join()</code> はやや複雑で、インデックスを基準に一方のデータフレームへ他方を連結する。このとき同名列が衝突する場合は、<code class="language-plaintext highlighter-rouge">lsuffix</code> と <code class="language-plaintext highlighter-rouge">rsuffix</code> 引数で両データフレームの重複列名に付ける接尾辞をそれぞれ指定する必要がある。</p><div class="language-python highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre><td class="rouge-code"><pre><span class="o">&gt;&gt;&gt;</span> <span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="nc">DataFrame</span><span class="p">({</span><span class="sh">'</span><span class="s">key</span><span class="sh">'</span><span class="p">:</span> <span class="p">[</span><span class="sh">'</span><span class="s">K0</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">K1</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">K2</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">K3</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">K4</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">K5</span><span class="sh">'</span><span class="p">],</span>
<span class="p">...</span>                    <span class="sh">'</span><span class="s">A</span><span class="sh">'</span><span class="p">:</span> <span class="p">[</span><span class="sh">'</span><span class="s">A0</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">A1</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">A2</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">A3</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">A4</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">A5</span><span class="sh">'</span><span class="p">]})</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">df</span>
  <span class="n">key</span>   <span class="n">A</span>
<span class="mi">0</span>  <span class="n">K0</span>  <span class="n">A0</span>
<span class="mi">1</span>  <span class="n">K1</span>  <span class="n">A1</span>
<span class="mi">2</span>  <span class="n">K2</span>  <span class="n">A2</span>
<span class="mi">3</span>  <span class="n">K3</span>  <span class="n">A3</span>
<span class="mi">4</span>  <span class="n">K4</span>  <span class="n">A4</span>
<span class="mi">5</span>  <span class="n">K5</span>  <span class="n">A5</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">other</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="nc">DataFrame</span><span class="p">({</span><span class="sh">'</span><span class="s">key</span><span class="sh">'</span><span class="p">:</span> <span class="p">[</span><span class="sh">'</span><span class="s">K0</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">K1</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">K2</span><span class="sh">'</span><span class="p">],</span>
<span class="p">...</span>                       <span class="sh">'</span><span class="s">B</span><span class="sh">'</span><span class="p">:</span> <span class="p">[</span><span class="sh">'</span><span class="s">B0</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">B1</span><span class="sh">'</span><span class="p">,</span> <span class="sh">'</span><span class="s">B2</span><span class="sh">'</span><span class="p">]})</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">other</span>
  <span class="n">key</span>   <span class="n">B</span>
<span class="mi">0</span>  <span class="n">K0</span>  <span class="n">B0</span>
<span class="mi">1</span>  <span class="n">K1</span>  <span class="n">B1</span>
<span class="mi">2</span>  <span class="n">K2</span>  <span class="n">B2</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">df</span><span class="p">.</span><span class="nf">join</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">lsuffix</span><span class="o">=</span><span class="sh">'</span><span class="s">_caller</span><span class="sh">'</span><span class="p">,</span> <span class="n">rsuffix</span><span class="o">=</span><span class="sh">'</span><span class="s">_other</span><span class="sh">'</span><span class="p">)</span>
  <span class="n">key_caller</span>   <span class="n">A</span> <span class="n">key_other</span>    <span class="n">B</span>
<span class="mi">0</span>         <span class="n">K0</span>  <span class="n">A0</span>        <span class="n">K0</span>   <span class="n">B0</span>
<span class="mi">1</span>         <span class="n">K1</span>  <span class="n">A1</span>        <span class="n">K1</span>   <span class="n">B1</span>
<span class="mi">2</span>         <span class="n">K2</span>  <span class="n">A2</span>        <span class="n">K2</span>   <span class="n">B2</span>
<span class="mi">3</span>         <span class="n">K3</span>  <span class="n">A3</span>       <span class="n">NaN</span>  <span class="n">NaN</span>
<span class="mi">4</span>         <span class="n">K4</span>  <span class="n">A4</span>       <span class="n">NaN</span>  <span class="n">NaN</span>
<span class="mi">5</span>         <span class="n">K5</span>  <span class="n">A5</span>       <span class="n">NaN</span>  <span class="n">NaN</span>
</pre></div></div>]]> </content> </entry> <entry><title xml:lang="ja">ウェブ パフォーマンス指標（Web Vitals）</title><link href="https://www.yunseo.kim/ja/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/about-web-vitals/" rel="alternate" type="text/html" hreflang="am" /><published>2025-08-05T00:00:00+09:00</published> <updated>2025-08-28T18:22:07+09:00</updated> <id>https://www.yunseo.kim/ja/posts/about-web-vitals/</id> <author> <name>Yunseo Kim</name> </author> <category term="Dev" /> <category term="Web Dev" /> <summary xml:lang="ja">Web VitalsとLighthouseの計測・評価基準を整理し、LCP・INP・CLS・TBT・FCP・SIの意味と改善ポイントを解説。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>Web VitalsとLighthouseの計測・評価基準を整理し、LCP・INP・CLS・TBT・FCP・SIの意味と改善ポイントを解説。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="ウェブ性能を決定する要素">ウェブ性能を決定する要素</h2><p>ウェブ性能最適化で考慮すべき主な要素は、大きくロード性能とレンダリング性能の2つに分類できる。</p><h3 id="html-のロード性能">HTML のロード性能</h3><ul><li>ネットワーク経由でサーバーに最初にページを要求してから、HTML 文書を受信しブラウザがレンダリングを開始するまでの時間<li>ページがどれだけ早く表示され始めるかを左右する<li>リダイレクトの最小化、HTML 応答のキャッシュ、リソース圧縮、適切なCDN活用などで最適化</ul><h3 id="レンダリング性能">レンダリング性能</h3><ul><li>ブラウザがユーザーに見える画面を描画し、かつインタラクティブにするまでに要する時間<li>どれだけ滑らかかつ素早く画面が描画されるかを左右する<li>不要なCSSやJSの削除、フォントやサムネイルの遅延読み込みを避ける、重い計算は別のWeb Worker（Web Worker）に分離してメインスレッド占有を最小化、アニメーションの最適化などで最適化</ul><h2 id="ウェブ-パフォーマンス指標web-vitals">ウェブ パフォーマンス指標（Web Vitals）</h2><p>Google の <a href="https://web.dev/performance?hl=ja">web.dev</a> と <a href="https://developer.chrome.com/docs/lighthouse/performance/performance-scoring?hl=ja">Chrome 開発者向けドキュメント</a>を基準に記述する。特段の理由がない限り、どれか1つの指標だけに注力するのではなく全体的な改善を目標にするのがよく、最適化対象ページでどこがボトルネックになっているかを把握することが重要である。また実ユーザーデータの統計がある場合は、上位や平均ではなく第1四分位（Q1）程度の下位値にも注目し、そのケースでも目標基準を満たすか確認・改善するのがよい。</p><h3 id="主要なウェブ-バイタルcore-web-vitals">主要なウェブ バイタル（Core Web Vitals）</h3><p>後述するようにウェブ パフォーマンス指標（Web Vitals）には複数あるが、このうち特にユーザー体験に密接に関連し、ラボ環境ではなく実環境で測定可能な次の3指標をGoogleは特に重要視し、これを<a href="https://web.dev/articles/vitals?hl=ja#core-web-vitals">主要なウェブ バイタル（Core Web Vitals）</a>と呼ぶ。Google は自社検索エンジンの順位にも対象サイトの主要ウェブ バイタルを反映しているため、サイト運営者にとってもこれらの指標はSEOの観点から注意深く見るべきである。</p><ul><li><a href="#lcp-largest-contentful-paint">最大コンテンツの描画（Largest Contentful Paint, LCP）</a>: <em>ロード性能</em>を反映、2.5秒以内であること<li><a href="https://web.dev/articles/inp?hl=ja">次のペイントまでのインタラクション（Interaction to Next Paint, INP）</a>: <em>応答性</em>を反映、200ms以下であること<li><a href="#cls-cumulative-layout-shift">累積レイアウトシフト（Cumulative Layout Shift, CLS）</a>: <em>視覚的安定性</em>を反映、0.1以下に保つこと</ul><p>主要ウェブ バイタルは基本的に実環境での測定を想定しているが、INP を除く2つは Chrome DevTools や Lighthouse といったラボ環境でも測定できる。INP は実際のユーザー入力があって初めて測定可能なためラボ環境では測れないが、その場合は <a href="#tbt-total-blocking-time">TBT</a> が INP と非常に相関が高く近い指標なので参考にでき、<a href="https://web.dev/articles/vitals?hl=ja#lab_tools_to_measure_core_web_vitals">通常はTBTを改善すればINPも改善される</a>。</p><h3 id="lighthouse-10-の性能スコアの重み">Lighthouse 10 の性能スコアの重み</h3><p><a href="https://developer.chrome.com/docs/lighthouse/performance/performance-scoring?hl=ja">Lighthouse の性能スコアは各測定項目のスコアの加重平均で算出され、その際の重みは以下の表に従う</a>。</p><table><thead><tr><th>測定項目<th>重み<tbody><tr><td><a href="#fcp-first-contentful-paint">最初のコンテンツの描画（First Contentful Paint, FCP）</a><td>10%<tr><td><a href="#si-speed-index">スピードインデックス（Speed Index, SI）</a><td>10%<tr><td><a href="#lcp-largest-contentful-paint">最大コンテンツの描画（Largest Contentful Paint, LCP）</a><td>25%<tr><td><a href="#tbt-total-blocking-time">合計ブロッキング時間（Total Blocking Time, TBT）</a><td>30%<tr><td><a href="#cls-cumulative-layout-shift">累積レイアウトシフト（Cumulative Layout Shift, CLS）</a><td>25%</table><h3 id="fcp-first-contentful-paint">FCP (First Contentful Paint)</h3><ul><li>ページ要求後、最初のDOMコンテンツをレンダリングするまでの所要時間を測定<li>ページ内の画像、白以外を描画する <code class="language-plaintext highlighter-rouge">&lt;canvas&gt;</code> 要素、SVG などをDOMコンテンツとみなし、<code class="language-plaintext highlighter-rouge">iframe</code> 内のコンテンツは考慮しない</ul><blockquote class="prompt-tip"><p>FCP に特に大きく影響する要素の1つはフォントのロード時間であり、その最適化については<a href="https://developer.chrome.com/docs/lighthouse/performance/font-display?hl=ja">関連ポスト</a>を参照するよう<a href="https://developer.chrome.com/docs/lighthouse/performance/first-contentful-paint/?hl=ja">Chrome 開発者向けドキュメント</a>は推奨している。</p></blockquote><h4 id="lighthouse-の評価基準">Lighthouse の評価基準</h4><p><a href="https://developer.chrome.com/docs/lighthouse/performance/first-contentful-paint/?hl=ja">Chrome 開発者向けドキュメント</a>によれば、Lighthouse の評価基準は次の表のとおり。</p><table><thead><tr><th>色区分<th>モバイル FCP（秒）<th>デスクトップ FCP（秒）<tbody><tr><td>緑（速い）<td>0-1.8<td>0-0.9<tr><td>橙（中間）<td>1.8-3<td>0.9-1.6<tr><td>赤（遅い）<td>3 超<td>1.6 超</table><h3 id="lcp-largest-contentful-paint">LCP (Largest Contentful Paint)</h3><ul><li>ページを初めて開いたときに最初に見える表示領域（viewport）を基準に、その領域内で最も大きく表示される要素（画像、テキストブロック、動画など）をレンダリング完了するまでの所要時間を測定<li>画面上で占める面積が大きいほど、ユーザーに主要コンテンツとして認識される可能性が高い<li>LCP が画像の場合、所要時間は4つの下位区間に分けられ、どこでボトルネックが起きているかを把握することが重要<ol><li>最初のバイトまでの時間（Time to First Byte, TTFB）: ページロード開始から HTML 応答の最初のバイトを受信するまで<li>ロード遅延（Load delay）: ブラウザが LCP リソースのロードを開始した時点と TTFB の差<li>ロード時間（Load time）: LCP リソース自体のロードに要した時間<li>レンダリング遅延（Render delay）: LCP リソースのロード完了から LCP 要素の完全なレンダリング完了まで</ol></ul><h4 id="lighthouse-の評価基準-1">Lighthouse の評価基準</h4><p><a href="https://developer.chrome.com/docs/lighthouse/performance/lighthouse-largest-contentful-paint/?hl=ja">Chrome 開発者向けドキュメント</a>によれば、Lighthouse の評価基準は次の表のとおり。</p><table><thead><tr><th>色区分<th>モバイル LCP（秒）<th>デスクトップ LCP（秒）<tbody><tr><td>緑（速い）<td>0-2.5<td>0-1.2<tr><td>橙（中間）<td>2.5-4<td>1.2-2.4<tr><td>赤（遅い）<td>4 超<td>2.4 超</table><h3 id="tbt-total-blocking-time">TBT (Total Blocking Time)</h3><ul><li>ページがマウスクリック、画面タップ、キーボード入力などのユーザー入力に反応できない合計時間を測定<li>FCP と <a href="https://developer.chrome.com/docs/lighthouse/performance/interactive?hl=ja">TTI（インタラクティブになるまでの時間, Time to Interactive）</a> の間に実行されたタスクのうち 50ms 以上かかったものを<a href="https://web.dev/articles/long-tasks-devtools?hl=ja">長いタスク</a>とみなし、各長いタスクの実行時間から 50ms を差し引いた超過分を<em>ブロッキング部分（blocking portion）</em>とし、これらの合計を TBT と定義する</ul><blockquote class="prompt-info"><p>※ TTI 自体はネットワーク応答の外れ値や長いタスクに過度に敏感で一貫性が低く変動が大きいため、<a href="https://developer.chrome.com/blog/lighthouse-10-0#scoring-changes">Lighthouse 10 以降は評価項目から除外された</a>。</p></blockquote><blockquote class="prompt-tip"><p>一般に長いタスクを引き起こす最も一般的な原因は、不要または非効率な JavaScript のロード・パース・実行である。<a href="https://web.dev/articles/reduce-javascript-payloads-with-code-splitting?hl=ja">コード分割（Code Splitting）</a>によって各タスクが 50ms 以内に実行できるよう JS ペイロードを削減し、必要に応じてメインスレッドではなく別の Service Worker（Service Worker）に分離してマルチスレッドで実行することを検討するよう、<a href="https://developer.chrome.com/docs/lighthouse/performance/lighthouse-total-blocking-time/?hl=ja">Chrome 開発者向けドキュメント</a>と<a href="https://web.dev/articles/long-tasks-devtools#what_is_causing_my_long_tasks?hl=ja">Google の web.dev</a>は推奨している。</p></blockquote><h4 id="lighthouse-の評価基準-2">Lighthouse の評価基準</h4><p><a href="https://developer.chrome.com/docs/lighthouse/performance/lighthouse-total-blocking-time/?hl=ja">Chrome 開発者向けドキュメント</a>によれば、Lighthouse の評価基準は次の表のとおり。</p><table><thead><tr><th>色区分<th>モバイル TBT（ミリ秒）<th>デスクトップ TBT（ミリ秒）<tbody><tr><td>緑（速い）<td>0-200<td>0-150<tr><td>橙（中間）<td>200-600<td>150-350<tr><td>赤（遅い）<td>600 超<td>350 超</table><h3 id="cls-cumulative-layout-shift">CLS (Cumulative Layout Shift)</h3><p> <video class="embed-video file" controls="" autoplay="" loop=""> <source src="https://web.dev/static/articles/cls/video/web-dev-assets/layout-instability-api/layout-instability2.webm" type="video/webm" /> Your browser does not support the video tag. Here is a <a href="https://web.dev/static/articles/cls/video/web-dev-assets/layout-instability-api/layout-instability2.webm">link to the video file</a> instead. </video> <em>予期しないレイアウト変更の例</em></p><blockquote><p>動画出典: <a href="https://web.dev/articles/cls?hl=ja">Cumulative Layout Shift (CLS) | Articles | web.dev</a></p></blockquote><p><del>カーソルの動きから深い怒りを感じる</del></p><ul><li>予期しないレイアウト変更は、テキストが突然移動して読んでいた箇所を見失ったり、リンクやボタンを誤ってクリックしてしまうなど、様々な形でユーザー体験を損なう<li>CLS スコアの算出方法の詳細は<a href="https://web.dev/articles/cls">Google の web.dev</a>に記載されている<li>下図のとおり、0.1 以下を目標にする</ul><p><img src="https://web.dev/static/articles/cls/image/good-cls-values.svg" alt="良いCLSスコアとは？" width="640" height="480" /></p><blockquote><p>画像出典: <a href="https://web.dev/articles/cls#what-is-a-good-cls-score?hl=ja">Cumulative Layout Shift (CLS) | Articles | web.dev</a></p></blockquote><h3 id="si-speed-index">SI (Speed Index)</h3><ul><li>ページのロード中にコンテンツがどれだけ早く視覚的に表示されるかを測定<li>Lighthouse はブラウザでのページロード過程を動画として記録し、その動画を分析してフレーム間の進捗を算出し、<a href="https://github.com/paulirish/speedline">Speedline Node.js モジュール</a>を用いて SI スコアを算出する</ul><blockquote class="prompt-tip"><p>先にまとめた <a href="#fcp-first-contentful-paint">FCP</a>、<a href="#lcp-largest-contentful-paint">LCP</a>、<a href="#tbt-total-blocking-time">TBT</a> など、ページロードを速くする施策は概ね SI スコアにも好影響を与える。ページロードのどれか一過程のみを代表するというより、全体のロード過程を一定程度反映する指標といえる。</p></blockquote><h4 id="lighthouse-の評価基準-3">Lighthouse の評価基準</h4><p><a href="https://developer.chrome.com/docs/lighthouse/performance/speed-index/?hl=ja">Chrome 開発者向けドキュメント</a>によれば、Lighthouse の評価基準は次の表のとおり。</p><table><thead><tr><th>色区分<th>モバイル SI（秒）<th>デスクトップ SI（秒）<tbody><tr><td>緑（速い）<td>0-3.4<td>0-1.3<tr><td>橙（中間）<td>3.4-5.8<td>1.3-2.3<tr><td>赤（遅い）<td>5.8 超<td>2.3 超</table>]]> </content> </entry> <entry><title xml:lang="ja">重力場と重力ポテンシャル</title><link href="https://www.yunseo.kim/ja/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/gravitational-field-and-potential/" rel="alternate" type="text/html" hreflang="am" /><published>2025-05-17T00:00:00+09:00</published> <updated>2025-11-03T20:50:45+09:00</updated> <id>https://www.yunseo.kim/ja/posts/gravitational-field-and-potential/</id> <author> <name>Yunseo Kim</name> </author> <category term="Physics" /> <category term="Classical Dynamics" /> <summary xml:lang="ja">ニュートンの万有引力の法則による重力場ベクトルと重力ポテンシャルの定義を学び、これに関連する重要な二つの例題として殻定理と銀河回転曲線を扱う。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>ニュートンの万有引力の法則による重力場ベクトルと重力ポテンシャルの定義を学び、これに関連する重要な二つの例題として殻定理と銀河回転曲線を扱う。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><ul><li>ニュートンの万有引力の法則: $\mathbf{F} = -G\cfrac{mM}{r^2}\mathbf{e}_r$<li>連続的な質量分布と大きさを持つ物体の場合: $\mathbf{F} = -Gm\int_V \cfrac{dM}{r^2}\mathbf{e}_r = -Gm\int_V \cfrac{\rho(\mathbf{r^\prime})\mathbf{e}_r}{r^2} dv^{\prime}$<ul><li>$\rho(\mathbf{r^{\prime}})$: 任意の原点からの位置ベクトル $\mathbf{r^{\prime}}$に位置する点での質量密度<li>$dv^{\prime}$: 任意の原点からの位置ベクトル $\mathbf{r^{\prime}}$に位置する点での体積要素</ul><li><strong>重力場ベクトル（gravitational field vector）</strong>:<ul><li>質量 $M$の物体によって生じた場の中で、ある一つの粒子が単位質量当たり受ける力を表すベクトル<li>$\mathbf{g} = \cfrac{\mathbf{F}}{m} = - G \cfrac{M}{r^2}\mathbf{e}_r = - G \int_V \cfrac{\rho(\mathbf{r^\prime})\mathbf{e}_r}{r^2}dv^\prime$<li><em>単位質量当たりの力</em> または <em>加速度</em>の次元を持つ</ul><li><strong>重力ポテンシャル（gravitational potential）</strong>:<ul><li>$\mathbf{g} \equiv -\nabla \Phi$<li>$($<em>単位質量当たりの力</em> $) \times ($<em>距離</em> $)$ または <em>単位質量当たりのエネルギー</em>の次元を持つ<li>$\Phi = -G\cfrac{M}{r}$<li>重力ポテンシャルはその相対的な差のみが意味を持ち、特定の値自体は意味がない<li>通常 $r \to \infty$のとき $\Phi \to 0$の条件を任意に設定して不確実性（ambiguity）を除去する<li>$U = m\Phi, \quad \mathbf{F} = -\nabla U$</ul><li><strong>球殻内部と外部の重力ポテンシャル（殻定理）</strong><ul><li>$R&gt;a$のとき:<ul><li>$\Phi(R&gt;a) = -\cfrac{GM}{R}$<li>物質の球対称分布（spherical symmetric distribution）による外部のある点での重力ポテンシャルを求める際、該当物体を質点（point mass）として扱って計算できる</ul><li>$R&lt;b$のとき:<ul><li>$\Phi(R&lt;b) = -2\pi\rho G(a^2 - b^2)$<li>球対称な質量殻の内部で重力ポテンシャルは位置に関係なく一定であり、作用する重力は $0$</ul><li>$b&lt;R&lt;a$のとき: $\Phi(b&lt;R&lt;a) = -4\pi\rho G \left( \cfrac{a^2}{2} - \cfrac{b^3}{3R} - \cfrac{R^2}{6} \right)$</ul></ul></blockquote><h2 id="重力場">重力場</h2><h3 id="ニュートンの万有引力の法則">ニュートンの万有引力の法則</h3><p>ニュートンは11666 HE以前にすでに万有引力の法則を体系化し、数値的にも検証していた。それにもかかわらず11687 HEに著書 <em>Principia</em>で自身の結果を出版するまでには20年もかかったが、その理由は地球と月を大きさを持たない質点（point mass）として仮定して行った計算法を正当化できなかったからである。幸いにも<a href="#raのとき">ニュートン自身がその後に発明した微積分学を使えば、11600年代当時のニュートンには容易でなかったその問題を我々ははるかに簡単に証明できる</a>。</p><p>ニュートンの万有引力の法則（Newton’s law of universal gravitation）によれば、<em>各質量粒子は宇宙内の他のすべての粒子を引き付けるが、その力は二つの質量の積に比例し、その間の距離の二乗に反比例する。</em> 数学的に表すと次のようになる。</p>\[\mathbf{F} = -G\frac{mM}{r^2}\mathbf{e}_r \label{eqn:law_of_gravitation}\tag{1}\]<p><img src="https://upload.wikimedia.org/wikipedia/commons/0/0e/NewtonsLawOfUniversalGravitation.svg" alt="Newton's law of universal gravitation" /></p><blockquote><p><em>画像出典</em></p><ul><li>作者: ウィキメディアユーザー <a href="https://commons.wikimedia.org/wiki/User:Dna-webmaster">Dennis Nilsson</a><li>ライセンス: <a href="https://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a></ul></blockquote><p>単位ベクトル $\mathbf{e}_r$は $M$から $m$ 方向を向き、負号は力が引力であることを示す。つまり、$m$は $M$ の方に引かれる。</p><h3 id="キャベンディッシュの実験">キャベンディッシュの実験</h3><p>この法則の実験的検証と $G$ 値の決定は11798 HEにイギリスの物理学者ヘンリー・キャベンディッシュ（Henry Cavendish）によって行われた。キャベンディッシュの実験は軽い棒の両端に固定された二つの小さな球からなるねじり天秤を使用する。その二つの球はそれぞれその近くに位置する他の二つの大きな球の方に引かれる。これまでに求められた公式的な $G$ 値は $6.673 \pm 0.010 \times 10^{-11} \mathrm{N\cdot m^2/kg^2}$である。</p><blockquote class="prompt-tip"><p>$G$は最も古くから知られている基本定数であるにもかかわらず、$e$、$c$、$\hbar$のような他の多くの基本定数よりも低い精度（precision）でしか知られていない。今日でも $G$ 値をより高い精度で求めようとする多くの研究が行われている。</p></blockquote><h3 id="大きさを持つ物体の場合">大きさを持つ物体の場合</h3><p>式 ($\ref{eqn:law_of_gravitation}$)の法則は厳密には <em>点粒子（point particle）</em>に対してのみ適用できる。もしどちらか一方または両方がある大きさを持つ物体である場合には、力を計算するために重力場（gravitational force field）が <em>線形場（linear field）</em>であるという仮定を追加する必要がある。つまり、質量が $m$である一つの粒子が他の複数の粒子から受ける総重力は各力のベクトルを合計することで求められると仮定する。物質が連続的に分布する物体の場合には、和を次のように積分に置き換える。</p>\[\mathbf{F} = -Gm\int_V \frac{dM}{r^2}\mathbf{e}_r = -Gm\int_V \frac{\rho(\mathbf{r^\prime})\mathbf{e}_r}{r^2} dv^{\prime} \label{eqn:integral_form}\tag{2}\]<ul><li>$\rho(\mathbf{r^{\prime}})$: 任意の原点からの位置ベクトル $\mathbf{r^{\prime}}$に位置する点での質量密度<li>$dv^{\prime}$: 任意の原点からの位置ベクトル $\mathbf{r^{\prime}}$に位置する点での体積要素</ul><p>もし質量 $M$の物体と質量 $m$の物体がともに大きさを持つ場合に全重力を求めようとする場合、$m$に対する二番目の体積積分も必要である。</p><h3 id="重力場ベクトル">重力場ベクトル</h3><p><strong>重力場ベクトル（gravitational field vector）</strong> $\mathbf{g}$は質量 $M$の物体によって生じた場の中で、ある一つの粒子が単位質量当たり受ける力を表すベクトルと定義して</p>\[\mathbf{g} = \frac{\mathbf{F}}{m} = - G \frac{M}{r^2}\mathbf{e}_r \label{eqn:g_vector}\tag{3}\]<p>または</p>\[\boxed{\mathbf{g} = - G \int_V \frac{\rho(\mathbf{r^\prime})\mathbf{e}_r}{r^2}dv^\prime} \tag{4}\]<p>と表す。ここで $\mathbf{e}_r$の方向は $\mathbf{r^\prime}$によって変わる。</p><p>この量 $\mathbf{g}$は <em>単位質量当たりの力</em> または <em>加速度</em>の次元を持つ。地球表面近くでの重力場ベクトル $\mathbf{g}$の大きさは、我々が<strong>重力加速度定数（gravitational acceleration constant）</strong>と呼ぶ量と等しく、$|\mathbf{g}| \approx 9.80\mathrm{m/s^2}$である。</p><h2 id="重力ポテンシャル">重力ポテンシャル</h2><h3 id="定義">定義</h3><p>重力場ベクトル $\mathbf{g}$は $1/r^2$で変化し、したがってあるスカラー関数（ポテンシャル）の勾配（gradient）として表現するための条件（$\nabla \times \mathbf{g} \equiv 0$）を満たす。そのため次のように書ける。</p>\[\mathbf{g} \equiv -\nabla \Phi \label{eqn:gradient_phi}\tag{5}\]<p>ここで $\Phi$を<strong>重力ポテンシャル（gravitational potential）</strong>といい、$($<em>単位質量当たりの力</em> $) \times ($<em>距離</em> $)$ または <em>単位質量当たりのエネルギー</em>の次元を持つ。</p><p>$\mathbf{g}$は半径のみに依存するので、$\Phi$ も $r$によって変化する。式 ($\ref{eqn:g_vector}$)と ($\ref{eqn:gradient_phi}$)から</p>\[\nabla\Phi = \frac{d\Phi}{dr}\mathbf{e}_r = G\frac{M}{r^2}\mathbf{e}_r\]<p>となり、これを積分すると</p>\[\boxed{\Phi = -G\frac{M}{r}} \label{eqn:g_potential}\tag{6}\]<p>を得る。重力ポテンシャルはその相対的な差のみが意味を持ち、絶対的な値の大きさは意味がないため、積分定数は省略できる。通常 $r \to \infty$のとき $\Phi \to 0$の条件を任意に設定して不確実性（ambiguity）を除去し、式 ($\ref{eqn:g_potential}$) もこの条件を満たす。</p><p>物質が連続的に分布する場合の重力ポテンシャルは次のようになる。</p>\[\Phi = -G\int_V \frac{\rho(\mathbf{r\prime})}{r}dv^\prime \label{eqn:g_potential_v}\tag{7}\]<p>質量が薄い殻に表面分布する場合には</p>\[\Phi = -G\int_S \frac{\rho_s}{r}da^\prime. \label{eqn:g_potential_s}\tag{8}\]<p>そして線密度 $\rho_l$の線形質量源の場合には次のように書ける。</p>\[\Phi = -G\int_\Gamma \frac{\rho_l}{r}ds^\prime. \label{eqn:g_potential_l}\tag{9}\]<h3 id="物理的意味">物理的意味</h3><p>物体が重力場の中で $d\mathbf{r}$だけ移動するとき、その物体が行う単位質量当たりの仕事 $dW^\prime$を考えてみよう。</p>\[\begin{align*} dW^\prime &amp;= -\mathbf{g}\cdot d\mathbf{r} = (\nabla \Phi)\cdot d\mathbf{r} \\ &amp;= \sum_i \frac{\partial \Phi}{\partial x_i}dx_i = d\Phi \label{eqn:work}\tag{10} \end{align*}\]<p>この式で $\Phi$は位置座標のみの関数で、$\Phi=\Phi(x_1, x_2, x_3) = \Phi(x_i)$と表される。したがって重力場の中で物体をある一点から他の一点まで移動させるとき、その物体が行う単位質量当たりの仕事の量はその二点のポテンシャル差と等しいことがわかる。</p><p>無限に遠い所での重力ポテンシャルを $0$と定義すると、任意の点での $\Phi$はその物体を無限に遠い所からその点まで移動させるのに必要な単位質量当たりの仕事として解釈できる。物体のポテンシャルエネルギーはその物体の質量と重力ポテンシャル $\Phi$の積と等しいので、$U$をポテンシャルエネルギーとすると</p>\[U = m\Phi. \label{eqn:potential_e}\tag{11}\]<p>したがって物体が受ける重力はその物体のポテンシャルエネルギーの勾配に負号を付けて得る。</p>\[\mathbf{F} = -\nabla U \label{eqn:force_and_potential}\tag{12}\]<p>物体がある質量によって生じた重力場の中に置かれているときは常にあるポテンシャルエネルギーが生じる。このポテンシャルエネルギーは厳密には場自体にあるものだが、慣例的にこれをその物体のポテンシャルエネルギーと表現することがある。</p><h2 id="例題-球殻内部と外部の重力ポテンシャル殻定理">例題: 球殻内部と外部の重力ポテンシャル（殻定理）</h2><h3 id="座標設定--積分式で重力ポテンシャルを表現する">座標設定 &amp; 積分式で重力ポテンシャルを表現する</h3><p>内側半径が $b$、外側半径が $a$の均一な球殻（spherical shell）の内部と外部の重力ポテンシャルを求めてみよう。球殻による重力は場の中の単位質量に作用する力成分を直接計算して得ることもできるが、ポテンシャル法を使う方がより簡単である。</p><p><img src="/assets/img/gravitational-field-and-potential/spherical-shell.png" alt="Spherical shell" /></p><p>上の図で中心からの距離 $R$の $P$ 点でのポテンシャルを計算しよう。殻の均一質量分布を仮定すると $\rho(r^\prime)=\rho$であり、球の中心と点 $P$を結ぶ線を基準として方位角 $\phi$については対称なので</p>\[\begin{align*} \Phi &amp;= -G\int_V \frac{\rho(r^\prime)}{r}dv^\prime \\ &amp;= -\rho G \int_0^{2\pi} \int_0^\pi \int_b^a \frac{1}{r}(dr^\prime)(r^\prime d\theta)(r^\prime \sin\theta\, d\phi) \\ &amp;= -\rho G \int_0^{2\pi} d\phi \int_b^a {r^\prime}^2 dr^\prime \int_0^\pi \frac{\sin\theta}{r}d\theta \\ &amp;= -2\pi\rho G \int_b^a {r^\prime}^2 dr^\prime \int_0^\pi \frac{\sin\theta}{r}d\theta. \label{eqn:spherical_shell_1}\tag{13} \end{align*}\]<p>余弦法則によれば</p>\[r^2 = {r^\prime}^2 + R^2 - 2r^\prime R \cos\theta \label{eqn:law_of_cosines}\tag{14}\]<p>であり $R$は一定なので、$r^\prime$についてこの式を微分すると</p>\[2rdr = 2r^\prime R \sin\theta d\theta\] \[\frac{\sin\theta}{r}d\theta = \frac{dr}{r^\prime R} \tag{15}\]<p>を得る。これを式 ($\ref{eqn:spherical_shell_1}$)に代入すると</p>\[\Phi = -\frac{2\pi\rho G}{R} \int_b^a r^\prime dr^\prime \int_{r_\mathrm{min}}^{r_\mathrm{max}} dr. \label{eqn:spherical_shell_2}\tag{16}\]<p>ここで $r_\mathrm{max}$と $r_\mathrm{min}$は点 $P$の位置によって決まる。</p><h3 id="raのとき">$R&gt;a$のとき</h3>\[\begin{align*} \Phi(R&gt;a) &amp;= -\frac{2\pi\rho G}{R} \int_b^a r^\prime dr^\prime \int_{R-r^\prime}^{R+r^\prime} dr \\ &amp;= - \frac{4\pi\rho G}{R} \int_b^a {r^\prime}^2 dr^\prime \\ &amp;= - \frac{4}{3}\frac{\pi\rho G}{R}(a^3 - b^3). \label{eqn:spherical_shell_outside_1}\tag{17} \end{align*}\]<p>球殻の質量 $M$は</p>\[M = \frac{4}{3}\pi\rho(a^3 - b^3) \label{eqn:mass_of_shell}\tag{18}\]<p>で与えられるので、ポテンシャルは次のようになる。</p>\[\boxed{\Phi(R&gt;a) = -\frac{GM}{R}} \label{eqn:spherical_shell_outside_2}\tag{19}\]<blockquote class="prompt-info"><p>質量が $M$の質点による重力ポテンシャル式 ($\ref{eqn:g_potential}$)と今得た結果 ($\ref{eqn:spherical_shell_outside_2}$)を比較すると同一であることがわかる。これは、物質の球対称分布（spherical symmetric distribution）による外部のある点での重力ポテンシャルを求める際、すべての質量が中心に集中していると考えても差し支えないという意味である。地球や月のような一定の大きさ以上の球形天体の大部分がこれに該当するが、これらは<a href="https://en.wikipedia.org/wiki/Matryoshka_doll">マトリョーシカ</a>のように中心が同じで互いに異なる直径を持つ無数の球殻が重なっているものと見なすことができる。これはこの記事の最初の部分で言及した<a href="#ニュートンの万有引力の法則">地球や月のような天体を大きさを持たない質点として仮定して計算しても妥当な根拠</a>となる。</p></blockquote><h3 id="rbのとき">$R&lt;b$のとき</h3>\[\begin{align*} \Phi(R&lt;b) &amp;= -\frac{2\pi\rho G}{R} \int_b^a r^\prime dr^\prime \int_{r^\prime - R}^{r^\prime + R}dr \\ &amp;= -4\pi\rho G \int_b^a r^\prime dr^\prime \\ &amp;= -2\pi\rho G(a^2 - b^2). \label{eqn:spherical_shell_inside}\tag{20} \end{align*}\]<blockquote class="prompt-info"><p>球対称な質量殻の内部で重力ポテンシャルは位置に関係なく一定であり、作用する重力は $0$である。</p></blockquote><blockquote class="prompt-tip"><p>そしてこれは代表的な疑似科学の一つである「地球空洞説」がでたらめである主要な根拠でもある。地球空洞説で主張するように地球が球殻形態で内部が空いているなら、該当空洞内部にあるすべての物体に対して地球重力が作用しない。地球の質量と体積を考えると地球空洞があるはずもないが、仮にあったとしてもそこの生命体は球殻の内側を地面として生活するのではなく、宇宙ステーションのように無重量状態で浮遊するだろう。<br /> <a href="https://youtu.be/VD6xJq8NguY?si=szgtuLkuk6rPJag3">地下数kmほどの地層の奥深くに微生物が住んでいることはあり得るが</a>、少なくとも地球空洞説で主張するような形では不可能である。ジュール・ヴェルヌの小説『地底旅行（Voyage au centre de la Terre）』と映画『地底探険（Journey to the Center of the Earth）』は私もとても好きだが、創作物は創作物として楽しむべきで、それを真剣に信じてはいけない。</p></blockquote><h3 id="braのとき">$b&lt;R&lt;a$のとき</h3>\[\begin{align*} \Phi(b&lt;R&lt;a) &amp;= -\frac{4\pi\rho G}{3R}(R^3 - b^3) - 2\pi\rho G(a^2 - R^2) \\ &amp;= -4\pi\rho G \left( \frac{a^2}{2} - \frac{b^3}{3R} - \frac{R^2}{6} \right) \label{eqn:within_spherical_shell}\tag{21} \end{align*}\]<h3 id="結果">結果</h3><p>先ほど求めた三つの領域での重力ポテンシャル $\Phi$、そしてそれに伴う重力場ベクトルの大きさ $|\mathbf{g}|$を距離 $R$の関数としてグラフで表すと次のようになる。</p><p><img src="/physics-visualizations/figs/shell-theorem-gravitational-potential.png" alt="Gravitational Potential as a Function of R" /><br /> <img src="/physics-visualizations/figs/shell-theorem-field-vector.png" alt="Magnitude of the Field Vector as a Function of R" /></p><blockquote><ul><li>Python可視化コード: <a href="https://github.com/yunseo-kim/physics-visualizations/blob/main/src/shell_theorem.py">yunseo-kim/physics-visualizations リポジトリ</a><li>ライセンス: <a href="https://github.com/yunseo-kim/physics-visualizations?tab=readme-ov-file#license">See here</a></ul></blockquote><p>重力ポテンシャルと重力場ベクトルの大きさは連続的であることがわかる。もし重力ポテンシャルがある点で不連続なら、その点でポテンシャルの勾配、つまり重力の大きさが無限大になるが、これは物理的に妥当でないのでポテンシャル関数はすべての点で連続でなければならない。しかし重力場ベクトルの<em>微分係数</em>は殻の内側面と外側面で不連続である。</p><h2 id="例題-銀河回転曲線">例題: 銀河回転曲線</h2><p>天文学的観測によれば、我々の銀河やアンドロメダ銀河のように中心に対して回転する多くの渦巻銀河の中の観測可能な質量は大部分が中心部近くに集中的に分布している。しかしこのような渦巻銀河の中の質量の軌道速度は、次のグラフで確認できるように観測可能な質量分布から理論的に予測した値と大きく一致せず、一定距離以上ではほぼ一定である。</p><p><img src="https://upload.wikimedia.org/wikipedia/commons/b/b9/GalacticRotation2.svg" alt="Galactic Rotation" width="972" /></p><blockquote><p><em>画像出典</em></p><ul><li>作者: ウィキペディアユーザー <a href="https://en.wikipedia.org/wiki/User:PhilHibbs">PhilHibbs</a><li>ライセンス: Public Domain</ul></blockquote><p> <video class="embed-video file" controls="" autoplay="" loop=""> <source src="https://cdn.jsdelivr.net/gh/yunseo-kim/yunseo-kim.github.io/assets/video/gravitational-field-and-potential/Galaxy_rotation_under_the_influence_of_dark_matter.webm" type="video/webm" /> <source src="https://cdn.jsdelivr.net/gh/yunseo-kim/yunseo-kim.github.io/assets/video/gravitational-field-and-potential/Galaxy_rotation_under_the_influence_of_dark_matter.ogg" type="video/ogg" /> Your browser does not support the video tag. Here is a <a href="https://cdn.jsdelivr.net/gh/yunseo-kim/yunseo-kim.github.io/assets/video/gravitational-field-and-potential/Galaxy_rotation_under_the_influence_of_dark_matter.webm">link to the video file</a> instead. </video> <em>左: 観測可能な質量から予測した銀河の回転 | 右: 実際に観測された銀河の回転。</em></p><blockquote><p><em>動画出典</em></p><ul><li>元ファイル（Ogg Theora video）へのリンク: <a href="https://commons.wikimedia.org/wiki/File:Galaxy_rotation_under_the_influence_of_dark_matter.ogv">https://commons.wikimedia.org/wiki/File:Galaxy_rotation_under_the_influence_of_dark_matter.ogv</a><li>作者: <a href="https://beltoforion.de/en/index.php">Ingo Berg</a><li>ライセンス: <a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">CC BY-SA 3.0</a><li>使用されたシミュレーション手法およびコード: <a href="https://beltoforion.de/en/spiral_galaxy_renderer/">https://beltoforion.de/en/spiral_galaxy_renderer/</a></ul></blockquote><blockquote class="prompt-danger"><p>以前このページに挿入していた <code class="language-plaintext highlighter-rouge">Rotation curve of spiral galaxy Messier 33 (Triangulum).png</code> 画像ファイルは、<a href="https://markwhittle.uvacreate.virginia.edu/">バージニア大学の Mark Whittle 教授</a>の非フリー著作物をウィキメディアユーザー <a href="https://commons.wikimedia.org/wiki/User:Accrama">Mario De Leo</a>が<a href="https://commons.wikimedia.org/wiki/Commons:Deletion_requests/File:Rotation_curve_of_spiral_galaxy_Messier_33_(Triangulum).png">適切な出典表記なく盗用した派生著作物であることが判明したためウィキメディア・コモンズから削除されており</a>、本ページからも削除したことをここに記す。</p></blockquote><p>銀河の質量が中心部に集中している場合の距離による軌道速度を予測して、該当予測値はこのような観測結果と一致しないことを確認し、銀河中心からの距離 $R$ 以内に分布する質量 $M(R)$が $R$に比例しなければ観測結果を説明できないことを示そう。</p><p>まず銀河質量 $M$が中心部に集中している場合、距離 $R$での軌道速度を求めると次のようになる。</p>\[\frac{GMm}{R^2} = \frac{mv^2}{R}\] \[v = \sqrt{\frac{GM}{R}} \propto \frac{1}{\sqrt{R}}.\]<p>この場合、上の二つのグラフに表示された点線のように $1/\sqrt{R}$で減少する軌道速度が予測されるが、観測結果によれば軌道速度 $v$は距離 $R$に関係なくほぼ一定なので、予測と観測結果が一致しない。このような観測結果は $M(R)\propto R$でなければ説明できない。</p><p>比例定数 $k$を使って $M(R) = kR$とおくと、</p>\[v = \sqrt{\frac{GM(R)}{R}} = \sqrt{Gk}\ \text{（定数）}.\]<p>これから天体物理学者たちは、多くの銀河には発見されていない「暗黒物質（dark matter）」が必ずあり、このような暗黒物質が宇宙質量の90%以上を占めなければならないという結論を下す。ただし暗黒物質の正体はまだ明確に明らかになっておらず、主流理論ではないが暗黒物質の存在を仮定せずに観測結果を説明しようとする修正ニュートン力学（Modified Newtonian Dynamics, MOND）のような試みも存在する。今日このような研究分野は天体物理学の最前線に接している。</p>]]> </content> </entry> <entry><title xml:lang="ja">未定係数法</title><link href="https://www.yunseo.kim/ja/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/method-of-undetermined-coefficients/" rel="alternate" type="text/html" hreflang="am" /><published>2025-04-20T00:00:00+09:00</published> <updated>2025-07-11T20:37:36+09:00</updated> <id>https://www.yunseo.kim/ja/posts/method-of-undetermined-coefficients/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Differential Equation" /> <summary xml:lang="ja">特定の形の定数係数非同次線形常微分方程式に対する初期値問題を簡単に解くことができ、工学において振動系、RLC電気回路モデルなどに対して有用によく使われる解法である未定係数法について学びましょう。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>特定の形の定数係数非同次線形常微分方程式に対する初期値問題を簡単に解くことができ、工学において振動系、RLC電気回路モデルなどに対して有用によく使われる解法である未定係数法について学びましょう。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><ul><li><strong>未定係数法</strong>の適用対象:<ul><li><strong>定数係数$a$と$b$</strong>を持ち<li>入力$r(x)$が指数関数、$x$の累乗、$\cos$または$\sin$、あるいはこれらの関数の和と積からなる<li>線形常微分方程式$y^{\prime\prime} + ay^{\prime} + by = r(x)$</ul><li><strong>未定係数法における選択規則</strong><ul><li><strong>(a) 基本規則(basic rule)</strong>: 式($\ref{eqn:linear_ode_with_constant_coefficients}$)において$r(x)$が表の最初の列にある関数のうちの一つであれば、同じ行の$y_p$を選び、$y_p$とその導関数を式($\ref{eqn:linear_ode_with_constant_coefficients}$)に代入することによって未定係数を決定する。<li><strong>(b) 変形規則(modification rule)</strong>: $y_p$として選んだ項が式($\ref{eqn:linear_ode_with_constant_coefficients}$)に対応する同次常微分方程式$y^{\prime\prime} + ay^{\prime} + by = 0$の解になる場合、この項に$x$(またはこの解が同次常微分方程式の特性方程式の重根に対応する場合は$x^2$)を掛ける。<li><strong>(c) 和規則(sum rule)</strong>: $r(x)$が表の最初の列にある関数の和である場合、2列目の対応する行にある関数の和を$y_p$として選ぶ。</ul></ul><table><thead><tr><th style="text-align: left">$r(x)$の項<th style="text-align: left">$y_p(x)$に対する選択<tbody><tr><td style="text-align: left">$ke^{\gamma x}$<td style="text-align: left">$Ce^{\gamma x}$<tr><td style="text-align: left">$kx^n\ (n=0,1,\cdots)$<td style="text-align: left">$K_nx^n + K_{n-1}x^{n-1} + \cdots + K_1x + K_0$<tr><td style="text-align: left">$k\cos{\omega x}$<br />$k\sin{\omega x}$<td style="text-align: left">$K\cos{\omega x} + M\sin{\omega x}$<tr><td style="text-align: left">$ke^{\alpha x}\cos{\omega x}$<br />$ke^{\alpha x}\sin{\omega x}$<td style="text-align: left">$e^{\alpha x}(K\cos{\omega x} + M\sin{\omega x})$</table></blockquote><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/homogeneous-linear-odes-of-second-order/">2階同次線形常微分方程式 (Homogeneous Linear ODEs of Second Order)</a><li><a href="/ja/posts/homogeneous-linear-odes-with-constant-coefficients/">定数係数を持つ2階同次線形常微分方程式</a><li><a href="/ja/posts/euler-cauchy-equation/">オイラー・コーシー方程式</a><li><a href="/ja/posts/wronskian-existence-and-uniqueness-of-solutions/">ロンスキアン(Wronskian)、解の存在と一意性</a><li><a href="/ja/posts/nonhomogeneous-linear-odes-of-second-order/">2階非同次線形常微分方程式 (Nonhomogeneous Linear ODEs of Second Order)</a><li>ベクトル空間、線形生成（線形代数学）</ul><h2 id="未定係数法">未定係数法</h2><p>$r(x) \not\equiv 0$である2階非同次線形常微分方程式</p>\[y^{\prime\prime} + p(x)y^{\prime} + q(x)y = r(x) \label{eqn:nonhomogeneous_linear_ode}\tag{1}\]<p>とこの非同次常微分方程式に対応する同次常微分方程式</p>\[y^{\prime\prime} + p(x)y^{\prime} + q(x)y = 0 \label{eqn:homogeneous_linear_ode}\tag{2}\]<p>を考えよう。</p><p>先に<a href="/ja/posts/nonhomogeneous-linear-odes-of-second-order/">2階非同次線形常微分方程式 (Nonhomogeneous Linear ODEs of Second Order)</a>で見たように、非同次線形常微分方程式($\ref{eqn:nonhomogeneous_linear_ode}$)の初期値問題を解くためには、同次常微分方程式($\ref{eqn:homogeneous_linear_ode}$)を解いて$y_h$を求めた後、方程式($\ref{eqn:nonhomogeneous_linear_ode}$)の一つの解$y_p$を見つけて一般解</p>\[y(x) = y_h(x) + y_p(x) \label{eqn:general_sol}\tag{3}\]<p>を得る必要がある。では$y_p$はどのように見つけることができるだろうか？$y_p$を見つける一般的な方法は<strong>パラメータ変換法(method of variation of parameters)</strong>だが、場合によってはそれよりもはるかに簡単な<strong>未定係数法(method of undetermined coefficients)</strong>を適用することができる。特に、振動系とRLC電気回路モデルに適用できるため、工学でよく使われる方法である。</p><p>未定係数法は<strong>定数係数$a$と$b$</strong>を持ち、入力$r(x)$が指数関数、$x$の累乗、$\cos$または$\sin$、あるいはこれらの関数の和と積からなる線形常微分方程式</p>\[y^{\prime\prime} + ay^{\prime} + by = r(x) \label{eqn:linear_ode_with_constant_coefficients}\tag{4}\]<p>に適している。このような形の$r(x)$は自分自身と類似した形の導関数を持つという点が未定係数法の核心である。未定係数法を適用するためには、$r(x)$と類似した形でありながら、自分自身とその導関数を与えられた常微分方程式に代入することによって決定される未知の係数を持つ$y_p$を選ぶ。工学で実用的に重要な形の$r(x)$に対して適切な$y_p$を選ぶための規則は次のとおりである。</p><blockquote class="prompt-info"><p><strong>未定係数法における選択規則</strong><br /> <strong>(a) 基本規則(basic rule)</strong>: 式($\ref{eqn:linear_ode_with_constant_coefficients}$)において$r(x)$が表の最初の列にある関数のうちの一つであれば、同じ行の$y_p$を選び、$y_p$とその導関数を式($\ref{eqn:linear_ode_with_constant_coefficients}$)に代入することによって未定係数を決定する。<br /> <strong>(b) 変形規則(modification rule)</strong>: $y_p$として選んだ項が式($\ref{eqn:linear_ode_with_constant_coefficients}$)に対応する同次常微分方程式$y^{\prime\prime} + ay^{\prime} + by = 0$の解になる場合、この項に$x$(またはこの解が同次常微分方程式の特性方程式の重根に対応する場合は$x^2$)を掛ける。<br /> <strong>(c) 和規則(sum rule)</strong>: $r(x)$が表の最初の列にある関数の和である場合、2列目の対応する行にある関数の和を$y_p$として選ぶ。</p><table><thead><tr><th style="text-align: left">$r(x)$の項<th style="text-align: left">$y_p(x)$に対する選択<tbody><tr><td style="text-align: left">$ke^{\gamma x}$<td style="text-align: left">$Ce^{\gamma x}$<tr><td style="text-align: left">$kx^n\ (n=0,1,\cdots)$<td style="text-align: left">$K_nx^n + K_{n-1}x^{n-1} + \cdots + K_1x + K_0$<tr><td style="text-align: left">$k\cos{\omega x}$<br />$k\sin{\omega x}$<td style="text-align: left">$K\cos{\omega x} + M\sin{\omega x}$<tr><td style="text-align: left">$ke^{\alpha x}\cos{\omega x}$<br />$ke^{\alpha x}\sin{\omega x}$<td style="text-align: left">$e^{\alpha x}(K\cos{\omega x} + M\sin{\omega x})$</table></blockquote><p>この方法は簡便であるだけでなく、自己修正性を持つという利点がある。$y_p$を誤って選択したり、少なすぎる項を選択したりすると矛盾に至り、多すぎる項を選択した場合は不要な項の係数が$0$になって正しい結果が得られる。未定係数法を適用して何かがうまくいかなくても、解法の過程で自然に気づくことができるので、上記の選択規則に従ってある程度適切な$y_p$を選択したなら、気軽に試してみることができる。</p><h3 id="和規則の証明">和規則の証明</h3><p>$r(x) = r_1(x) + r_2(x)$の形の非同次線形常微分方程式</p>\[y^{\prime\prime} + ay^{\prime} + by = r_1(x) + r_2(x)\]<p>を考えよう。ここで同じ左辺に入力として$r_1$、$r_2$を持つ次の二つの方程式</p>\[\begin{gather*} y^{\prime\prime} + ay^{\prime} + by = r_1(x) \\ y^{\prime\prime} + ay^{\prime} + by = r_2(x) \end{gather*}\]<p>がそれぞれ${y_p}_1$、${y_p}_2$を解として持つとする。与えられた方程式の左辺を$L[y]$と表記すると、$L[y]$の線形性により$y_p = {y_p}_1 + {y_p}_2$に対して次を満たすので和規則が成立する。</p>\[L[y_p] = L[{y_p}_1 + {y_p}_2] = L[{y_p}_1] + L[{y_p}_2] = r_1 + r_2 = r. \ \blacksquare\]<h2 id="例題-yprimeprime--ayprime--by--kegamma-x">例題: $y^{\prime\prime} + ay^{\prime} + by = ke^{\gamma x}$</h2><p>基本規則(a)に従って$y_p = Ce^{\gamma x}$とおき、与えられた方程式$y^{\prime\prime} + ay^{\prime} + by = ke^{\gamma x}$に代入すると</p>\[\gamma^2 Ce^{\gamma x} + \gamma aCe^{\gamma x} + bCe^{\gamma x} = ke^{\gamma x}\] \[C(\gamma^2 + a\gamma + b)e^{\gamma x} = ke^{\gamma x}\] \[C(\gamma^2 + a\gamma + b) = k.\]<h3 id="gamma2--agamma--b-neq-0の場合">$\gamma^2 + a\gamma + b \neq 0$の場合</h3><p>次のように未定係数$C$を決定し、$y_p$を求めることができる。</p>\[C = \frac{k}{\gamma^2 + a\gamma + b}\] \[y_p = Ce^{\gamma x} = \frac{k}{\gamma^2 + a\gamma + b} e^{\gamma x}.\]<h3 id="gamma2--agamma--b--0の場合">$\gamma^2 + a\gamma + b = 0$の場合</h3><p>この場合、変形規則(b)を適用する必要がある。まず$b = -\gamma^2 - a\gamma = -\gamma(a + \gamma)$を利用して同次常微分方程式$y^{\prime\prime} + ay^{\prime} + by = 0$の特性方程式の根を求めよう。</p>\[y^{\prime\prime} + ay^{\prime} - \gamma(a + \gamma)y = 0\] \[\lambda^2 + a\lambda - \gamma(a + \gamma) = 0\] \[(\lambda + (a + \gamma))(\lambda - \gamma) = 0\] \[\lambda = \gamma, -a -\gamma.\]<p>これより同次常微分方程式の基底</p>\[y_1 = e^{\gamma x}, \quad y_2 = e^{(-a - \gamma)x}\]<p>を得る。</p><h4 id="gamma-neq--a-gammaの場合">$\gamma \neq -a-\gamma$の場合</h4><p>$y_p$として選んだ$Ce^{\gamma x}$が与えられた方程式に対応する同次常微分方程式の重根ではない解であるため、変形規則(b)に従ってこの項に$x$を掛けて$y_p = Cxe^{\gamma x}$とおく。</p><p>この変形した$y_p$を再び与えられた方程式$y^{\prime\prime} + ay^{\prime} - \gamma(a + \gamma)y = ke^{\gamma x}$に代入すると</p>\[C(2\gamma + \gamma^2 x)e^{\gamma x} + aC(1 + \gamma x)e^{\gamma x} - \gamma(a + \gamma)Cxe^{\gamma x} = ke^{\gamma x}\] \[C \left[\left\{\gamma^2 + a\gamma -\gamma(a + \gamma)\right\}x + 2\gamma + a \right]e^{\gamma x} = ke^{\gamma x}\] \[C(2\gamma + a)e^{\gamma x} = ke^{\gamma x}\] \[C(2\gamma + a) = k\] \[\therefore C = \frac{k}{2\gamma + a}, \quad y_p = Cxe^{\gamma x} = \frac{k}{2\gamma + a}xe^{\gamma x}.\]<h4 id="gamma---a-gammaの場合">$\gamma = -a-\gamma$の場合</h4><p>この場合、$y_p$として選んだ$Ce^{\gamma x}$が与えられた方程式に対応する同次常微分方程式の重根であるため、変形規則(b)に従ってこの項に$x^2$を掛けて$y_p = Cx^2 e^{\gamma x}$とおく。</p><p>この変形した$y_p$を再び与えられた方程式$y^{\prime\prime} - 2\gamma y^{\prime} + \gamma^2 y = ke^{\gamma x}$に代入すると</p>\[C(2 + 4\gamma x + \gamma^2 x^2)e^{\gamma x} + C(-4\gamma x - 2\gamma^2 x^2)e^{\gamma x} + C(\gamma^2 x^2)e^{\gamma x} = ke^{\gamma x}\] \[2Ce^{\gamma x} = ke^{\gamma x}\] \[2C = k\] \[\therefore C = \frac{k}{2}, \quad y_p = Cx^2 e^{\gamma x} = \frac{k}{2}x^2 e^{\gamma x}.\]<h2 id="未定係数法の拡張-関数の積形式のrx">未定係数法の拡張: 関数の積形式の$r(x)$</h2><p>$r(x) = k x^n e^{\alpha x}\cos(\omega x)$の形の非同次線形常微分方程式</p>\[y^{\prime\prime} + ay^{\prime} + by = C x^n e^{\alpha x}\cos(\omega x)\]<p>を考えよう。$r(x)$をこのように指数関数$e^{\alpha x}$、$x$の累乗$x^m$、$\cos{\omega x}$または$\sin{\omega x}$(ここでは$\cos$と仮定し、これでも一般性を失わない)、あるいはこれらの関数の和と積とすると(つまり、先の表の最初の列にある関数の和と積で表現できるとすると)、同じ表の2列目にある関数の和と積である方程式の解$y_p$が存在することを示す。</p><blockquote class="prompt-tip"><p>厳密な証明のために線形代数学を使用して記述した部分があり、そのような部分は*で示している。該当部分をスキップして残りの部分だけ読んでも概略的な理解には問題ない。</p></blockquote><h3 id="ベクトル空間vの定義">ベクトル空間$V$の定義*</h3><p>\(\begin{align*} r(x) &amp;= C_1x^{n_1}e^{\alpha_1 x} \times C_2x^{n_2}e^{\alpha_2 x}\cos(\omega x) \times \cdots \\ &amp;= C x^n e^{\alpha x}\cos(\omega x) \end{align*}\)</p><p>である$r(x)$に対して、$r(x) \in V$であるベクトル空間$V$を次のように取ることができる。</p>\[V = \mathrm{span}\left\{x^k e^{\alpha x}\cos(\omega x), \; x^k e^{\alpha x}\sin(\omega x) \bigm| k=0,1,\dots,n \right\}\]<h3 id="指数関数多項式関数三角関数の導関数の形">指数関数、多項式関数、三角関数の導関数の形</h3><p>先の表の最初の列に示された基本関数の導関数の形は次のとおりである。</p><ul><li>指数関数: $\cfrac{d}{dx}e^{\alpha x} = \alpha e^{\alpha x}$<li>多項式関数: $\cfrac{d}{dx}x^m = mx^{m-1}$<li>三角関数: $\cfrac{d}{dx}\cos\omega x = -\omega\sin\omega x, \quad \cfrac{d}{dx}\sin\omega x = \omega\cos\omega x$</ul><p>これらの関数を微分して得られる導関数もまた<u>同じ種類の関数の和</u>として表現される。</p><p>したがって、関数$f$と$g$が上記の関数またはそれらの和であるとき、$r(x) = f(x)g(x)$に対して積の微分法を適用すると</p>\[\begin{align*} (fg)^{\prime} &amp;= f^{\prime}g + fg^{\prime}, \\ (fg)^{\prime\prime} &amp;= f^{\prime\prime}g + 2f^{\prime}g^{\prime} + fg^{\prime\prime} \end{align*}\]<p>となり、ここで$f$、$f^{\prime}$、$f^{\prime\prime}$と$g$、$g^{\prime}$、$g^{\prime\prime}$はすべて指数関数、多項式関数、三角関数の和または定数倍の形で書くことができる。したがって$r^{\prime}(x) = (fg)^{\prime}$、$r^{\prime\prime}(x) = (fg)^{\prime\prime}$も$r(x)$と同様にこれらの関数の和と積として表現できる。</p><h3 id="vの微分演算d線形変換lに対する不変">$V$の微分演算$D$、線形変換$L$に対する不変*</h3><p>つまり、$r(x)$自体だけでなく$r^{\prime}(x)$、$r^{\prime\prime}(x)$も$x^k e^{\alpha x}\cos(\omega x)$形の項と$x^k e^{\alpha x}\sin(\omega x)$形の項の線形結合であるため</p>\[r(x) \in V \implies r^{\prime}(x) \in V,\ r^{\prime\prime}(x) \in V.\]<p>$r(x)$に限定せず、先に定義したベクトル空間$V$のすべての要素に対して微分演算子$D$を導入してより一般的に表現すると、<em>ベクトル空間$V$は微分演算$D$に対して閉じている</em>。したがって与えられた方程式の左辺$y^{\prime\prime} + ay^{\prime} + by$を$L[y]$と表記すると、<em>$V$は$L$に対して不変(invariant)である</em>。</p>\[D^2(V)\subseteq V,\quad aD(V)\subseteq V,\quad b\,V\subseteq V \implies L(V)\subseteq V.\]<p>$r(x) \in V$であり$V$が$L$に対して不変であるため、$L[y_p] = r$を満たす$V$の別の要素$y_p$が存在する。</p>\[\exists y_p \in V: L[y_p] = r\]<h3 id="ansatz">Ansatz</h3><p>したがって、すべての可能な積形式の項の和になるように適切な$y_p$を未定係数$A_0, A_1, \dots, A_n$と$K$、$M$を用いて次のように選べば、基本規則(a)と変形規則(b)に従って$y_p$(または$xy_p$、$x^2y_p$)とその導関数を与えられた方程式に代入することによって未定係数を決定できる。このとき$n$は$r(x)$の$x$に関する次数に応じて決定すればよい。</p>\[y_p = e^{\alpha x}(A_nx^n + A_{n-1}x^{n-1} + \cdots + A_1x + A_0)(K\cos{\omega x} + M \sin{\omega x}).\]<p>$\blacksquare$</p><blockquote class="prompt-warning"><p>もし与えられた入力$r(x)$が異なる複数の$\alpha_i$、$\omega_j$値を含む場合、各$\alpha_i$と$\omega_j$値に対しても可能なすべての$x^{k}e^{\alpha_i x}\cos(\omega_j x)$、$x^{k}e^{\alpha_i x}\sin(\omega_j x)$形の項を漏れなく含めるように$y_p$を選ぶ必要がある。<br /> 未定係数法の利点は簡便であることなので、仮説解(ansatz)が複雑になりすぎてこの利点が薄れる場合は、むしろ後で扱うパラメータ変換法を適用する方が良いかもしれない。</p></blockquote><h2 id="未定係数法の拡張-オイラーコーシー方程式">未定係数法の拡張: オイラー・コーシー方程式</h2><p><a href="/ja/posts/homogeneous-linear-odes-with-constant-coefficients/">定数係数を持つ2階同次線形常微分方程式</a>だけでなく、<a href="/ja/posts/euler-cauchy-equation/">オイラー・コーシー方程式</a></p>\[x^2y^{\prime\prime} + axy^{\prime} + by = r(x) \label{eqn:euler_cauchy}\tag{5}\]<p>に対しても未定係数法を活用できる。</p><h3 id="変数変換">変数変換</h3><p><a href="/ja/posts/euler-cauchy-equation/#定数係数を持つ2階同次線形常微分方程式への変換">$x = e^t$と変換して定数係数を持つ2階同次線形常微分方程式に変換</a>すると</p>\[\frac{d}{dx} = \frac{1}{x}\frac{d}{dt}, \quad \frac{d^2}{dx^2} = \frac{1}{x^2}\left(\frac{d^2}{dt^2} - \frac{d}{dt} \right)\]<p>となり、オイラー・コーシー方程式を次のように$t$に関する定数係数同次線形常微分方程式に変えることができることを先に学んだ。</p>\[y^{\prime\prime} + (a-1)y^{\prime} + by = r(e^t). \label{eqn:substituted}\tag{6}\]<p>ここで式($\ref{eqn:substituted}$)に対して<a href="#未定係数法">先ほど見た未定係数法</a>を同様に適用して$t$について解き、最後に$t = \ln x$であることを利用して$x$に関する解を求めればよい。</p><h3 id="rxがxの累乗自然対数またはこれらの関数の和と積である場合">$r(x)$が$x$の累乗、自然対数、またはこれらの関数の和と積である場合</h3><p>特に入力$r(x)$が$x$の累乗、自然対数、またはこれらの関数の和と積からなる場合、次のオイラー・コーシー方程式用選択規則に従って適切な$y_p$を直接選ぶことができる。</p><blockquote class="prompt-info"><p><strong>未定係数法における選択規則: オイラー・コーシー方程式用</strong><br /> <strong>(a) 基本規則(basic rule)</strong>: 式($\ref{eqn:euler_cauchy}$)において$r(x)$が表の最初の列にある関数のうちの一つであれば、同じ行の$y_p$を選び、$y_p$とその導関数を式($\ref{eqn:euler_cauchy}$)に代入することによって未定係数を決定する。<br /> <strong>(b) 変形規則(modification rule)</strong>: $y_p$として選んだ項が式($\ref{eqn:euler_cauchy}$)に対応する同次常微分方程式$x^2y^{\prime\prime} + axy^{\prime} + by = 0$の解になる場合、この項に$\ln{x}$(またはこの解が同次常微分方程式の特性方程式の重根に対応する場合は$(\ln{x})^2$)を掛ける。<br /> <strong>(c) 和規則(sum rule)</strong>: $r(x)$が表の最初の列にある関数の和である場合、2列目の対応する行にある関数の和を$y_p$として選ぶ。</p><table><thead><tr><th style="text-align: left">$r(x)$の項<th style="text-align: left">$y_p(x)$に対する選択<tbody><tr><td style="text-align: left">$kx^m\ (m=0,1,\cdots)$<td style="text-align: left">$Ax^m$<tr><td style="text-align: left">$kx^m \ln{x}\ (m=0,1,\cdots)$<td style="text-align: left">$x^m(B\ln x + C)$<tr><td style="text-align: left">$k(\ln{x})^s\ (s=0,1,\cdots)$<td style="text-align: left">$D_0 + D_1\ln{x} + \cdots + D_{s-1}(\ln{x})^{s-1} + D_s(\ln{x})^s$<tr><td style="text-align: left">$kx^m (\ln{x})^s$<br />$(m=0,1,\cdots ;\; s=0,1,\cdots)$<td style="text-align: left">$x^m \left( D_0 + D_1\ln{x} + \cdots + D_{s-1}(\ln{x})^{s-1} + D_s(\ln{x})^s \right)$</table></blockquote><p>このようにすれば、実用的に重要な形の入力$r(x)$に対して<a href="#変数変換">変数変換</a>で得るのと同じ$y_p$をより速く簡単に見つけることができる。先に見た<a href="#未定係数法">元の選択規則</a>で$x$の代わりに$\ln{x}$を入れると、このオイラー・コーシー方程式用選択規則を導くことができる。</p>]]> </content> </entry> <entry><title xml:lang="ja">2階非同次線形常微分方程式（Nonhomogeneous Linear ODEs of Second Order）</title><link href="https://www.yunseo.kim/ja/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/nonhomogeneous-linear-odes-of-second-order/" rel="alternate" type="text/html" hreflang="am" /><published>2025-04-16T00:00:00+09:00</published> <updated>2025-07-11T20:37:36+09:00</updated> <id>https://www.yunseo.kim/ja/posts/nonhomogeneous-linear-odes-of-second-order/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Differential Equation" /> <summary xml:lang="ja">2階非同次線形常微分方程式の一般解の構造と特性について学び、対応する同次方程式との関係を理解する。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>2階非同次線形常微分方程式の一般解の構造と特性について学び、対応する同次方程式との関係を理解する。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><ul><li>2階非同次線形常微分方程式 $y^{\prime\prime} + p(x)y^{\prime} + q(x)y = r(x)$の<strong>一般解</strong>:<ul><li>$y(x) = y_h(x) + y_p(x)$<li>$y_h$: 同次常微分方程式 $y^{\prime\prime} + p(x)y^{\prime} + q(x)y = 0$の一般解 $y_h = c_1y_1 + c_2y_2$<li>$y_p$: 該当非同次常微分方程式の特殊解</ul><li>応答項 $y_p$は入力 $r(x)$によってのみ決定され、同じ非同次常微分方程式に対しては初期条件が異なっても $y_p$は変わらない。非同次常微分方程式の二つの特殊解の差は対応する同次常微分方程式の解となる。<li><strong>一般解の存在</strong>: 非同次常微分方程式の係数 $p(x)$、$q(x)$と入力関数 $r(x)$が連続であれば一般解は常に存在する<li><strong>特異解の非存在</strong>: 一般解は方程式のすべての解を含む（つまり、特異解は存在しない）</ul></blockquote><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/homogeneous-linear-odes-of-second-order/">2階同次線形常微分方程式 (Homogeneous Linear ODEs of Second Order)</a><li><a href="/ja/posts/wronskian-existence-and-uniqueness-of-solutions/">ロンスキアン（Wronskian）、解の存在と一意性</a></ul><h2 id="2階非同次線形常微分方程式の一般解と特殊解">2階非同次線形常微分方程式の一般解と特殊解</h2><p>2階非同次線形常微分方程式</p>\[y^{\prime\prime} + p(x)y^{\prime} + q(x)y = r(x) \label{eqn:nonhomogeneous_linear_ode}\tag{1}\]<p>を考えよう。ここで $r(x) \not\equiv 0$である。開区間 $I$で方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の<strong>一般解</strong>はこの非同次常微分方程式に対応する同次常微分方程式</p>\[y^{\prime\prime} + p(x)y^{\prime} + q(x)y = 0 \label{eqn:homogeneous_linear_ode}\tag{2}\]<p>の一般解 $y_h = c_1y_1 + c_2y_2$と式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の特殊解 $y_p$の和</p>\[y(x) = y_h(x) + y_p(x) \label{eqn:general_sol}\tag{3}\]<p>の形である。また区間 $I$で方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の<strong>特殊解</strong>は $y_h$の任意定数 $c_1$と $c_2$に特定の値を指定して式 ($\ref{eqn:general_sol}$)から得られる解である。</p><p>つまり、同次常微分方程式 ($\ref{eqn:homogeneous_linear_ode}$)に独立変数 $x$のみに依存する入力 $r(x)$を追加すると、それに対応する項 $y_p$が応答に追加され、この追加された応答項 $y_p$は初期条件に関係なく入力 $r(x)$のみによって決定される。後で見るように、式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の任意の二つの解 $y_1$と $y_2$の差を求めると（つまり、異なる二つの初期条件に対するそれぞれの特殊解の差を求めると）初期条件に無関係な $y_p$部分は消え、${y_h}_1$と ${y_h}_2$の差だけが残り、これは<a href="/ja/posts/homogeneous-linear-odes-of-second-order/#重ね合わせの原理">重ね合わせの原理</a>により式 ($\ref{eqn:homogeneous_linear_ode}$)の解となる。</p><h2 id="非同次常微分方程式の解とそれに対応する同次常微分方程式の解の関係">非同次常微分方程式の解と、それに対応する同次常微分方程式の解の関係</h2><blockquote class="prompt-info"><p><strong>定理1: 非同次常微分方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の解と同次常微分方程式 ($\ref{eqn:homogeneous_linear_ode}$)の解の関係</strong><br /> <strong>(a)</strong> ある開区間 $I$で非同次常微分方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の解 $y$と同次常微分方程式 ($\ref{eqn:homogeneous_linear_ode}$)の解 $\tilde{y}$の和は区間 $I$で方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の解である。特に式 ($\ref{eqn:general_sol}$)は区間 $I$で方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の解である。<br /> <strong>(b)</strong> 区間 $I$で非同次常微分方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の二つの解の差は区間 $I$で同次常微分方程式 ($\ref{eqn:homogeneous_linear_ode}$)の解である。</p></blockquote><h3 id="証明">証明</h3><h4 id="a">(a)</h4><p>方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)と ($\ref{eqn:homogeneous_linear_ode}$)の左辺を $L[y]$と表記しよう。すると区間 $I$で式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の任意の解 $y$と式 ($\ref{eqn:homogeneous_linear_ode}$)の任意の解 $\tilde{y}$に対しても次を満たす。</p>\[L[y + \tilde{y}] = L[y] + L[\tilde{y}] = r + 0 = r.\]<h4 id="b">(b)</h4><p>区間 $I$で式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の任意の二つの解 $y$と $y^*$に対して次を満たす。</p>\[L[y - y^*] = L[y] - L[y^*] = r - r = 0.\ \blacksquare\]<h2 id="非同次常微分方程式の一般解はすべての解を含む">非同次常微分方程式の一般解はすべての解を含む</h2><p>同次常微分方程式 ($\ref{eqn:homogeneous_linear_ode}$)について<a href="/ja/posts/wronskian-existence-and-uniqueness-of-solutions/#一般解はすべての解を含む">一般解がすべての解を含むことを知っている</a>。非同次常微分方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)についても同じことが成り立つことを示そう。</p><blockquote class="prompt-info"><p><strong>定理2: 非同次常微分方程式の一般解はすべての解を含む</strong><br /> 方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の係数 $p(x)$、$q(x)$と入力関数 $r(x)$がある開区間 $I$で連続ならば、区間 $I$で式 ($\ref{eqn:nonhomogeneous_linear_ode}$)のすべての解は区間 $I$で式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の一般解 ($\ref{eqn:general_sol}$)の $y_h$の任意定数 $c_1$と $c_2$に適当な値を指定することによって得ることができる。</p></blockquote><h3 id="証明-1">証明</h3><p>$y^*$を $I$で方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)のある解とし、$x_0$を区間 $I$内のある $x$とする。<a href="/ja/posts/wronskian-existence-and-uniqueness-of-solutions/#一般解の存在">連続な変数係数を持つ同次常微分方程式の一般解の存在定理</a>により $y_h = c_1y_1 + c_2y_2$が存在し、後で学ぶ<strong>パラメータ変化法（method of variation of parameters）</strong>により $y_p$も存在するため、区間 $I$で方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の一般解 ($\ref{eqn:general_sol}$)は存在する。ここで先に証明した定理<a href="#非同次常微分方程式の解とそれに対応する同次常微分方程式の解の関係">1(b)</a>により $Y = y^* - y_p$は区間 $I$で同次常微分方程式 ($\ref{eqn:homogeneous_linear_ode}$)の解であり、$x_0$で</p>\[\begin{gather*} Y(x_0) = y^*(x_0) - y_p(x_0) \\ Y^{\prime}(x_0) = {y^*}^{\prime}(x_0) - y_p^{\prime}(x_0) \end{gather*}\]<p>である。<a href="/ja/posts/wronskian-existence-and-uniqueness-of-solutions/#初期値問題の解の存在性と一意性の定理">初期値問題の解の存在性と一意性の定理</a>によれば、区間 $I$で上記の初期条件に対して $y_h$の $c_1$、$c_2$に適当な値を指定して得られる同次常微分方程式 ($\ref{eqn:homogeneous_linear_ode}$)の特殊解 $Y$が唯一存在する。$y^* = Y + y_p$であるため、非同次常微分方程式 ($\ref{eqn:nonhomogeneous_linear_ode}$)の任意の特殊解 $y^*$を一般解 ($\ref{eqn:general_sol}$)から得られることを示した。$\blacksquare$</p>]]> </content> </entry> <entry><title xml:lang="ja">ロンスキアン（Wronskian）、解の存在と一意性</title><link href="https://www.yunseo.kim/ja/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/wronskian-existence-and-uniqueness-of-solutions/" rel="alternate" type="text/html" hreflang="am" /><published>2025-04-06T00:00:00+09:00</published> <updated>2025-07-11T21:22:11+09:00</updated> <id>https://www.yunseo.kim/ja/posts/wronskian-existence-and-uniqueness-of-solutions/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Differential Equation" /> <summary xml:lang="ja">連続な任意の変数係数を持つ2階同次線形常微分方程式について、初期値問題の解の存在性と一意性の定理、ロンスキアン（Wronskian）を用いた解の線形従属/線形独立の判別法を学ぶ。また、これを用いてこの形の方程式は常に一般解を持ち、この一般解は方程式のすべての解を含むことを示す。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>連続な任意の変数係数を持つ2階同次線形常微分方程式について、初期値問題の解の存在性と一意性の定理、ロンスキアン（Wronskian）を用いた解の線形従属/線形独立の判別法を学ぶ。また、これを用いてこの形の方程式は常に一般解を持ち、この一般解は方程式のすべての解を含むことを示す。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><p>区間 $I$で連続な任意の変数係数 $p$と $q$を持つ2階同次線形常微分方程式</p>\[y^{\prime\prime} + p(x)y^{\prime} + q(x)y = 0\]<p>と初期条件</p>\[y(x_0)=K_0, \qquad y^{\prime}(x_0)=K_1\]<p>について、次の4つの定理が成立する。</p><ol><li><strong>初期値問題の解の存在性と一意性の定理</strong>: 与えられた方程式および初期条件で構成される初期値問題は区間 $I$で唯一の解 $y(x)$を持つ。<li><strong>ロンスキアン（Wronskian）を用いた解の線形従属/線形独立の判別</strong>: 方程式の二つの解 $y_1$と $y_2$について、区間 $I$内に<strong>ロンスキアン（Wronskian）</strong> $W(y_1, y_2) = y_1y_2^{\prime} - y_2y_1^{\prime}$の値が $0$となる $x_0$が存在するならば、二つの解は線形従属である。また、区間 $I$内に $W\neq 0$となる $x_1$が存在するならば、二つの解は線形独立である。<li><strong>一般解の存在</strong>: 与えられた方程式は区間 $I$で一般解を持つ。<li><strong>特異解の非存在</strong>: この一般解は方程式のすべての解を含む（つまり、特異解が存在しない）。</ol></blockquote><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/Solution-of-First-Order-Linear-ODE/">1階線形常微分方程式の解法</a><li><a href="/ja/posts/homogeneous-linear-odes-of-second-order/">2階同次線形常微分方程式 (Homogeneous Linear ODEs of Second Order)</a><li><a href="/ja/posts/homogeneous-linear-odes-with-constant-coefficients/">定数係数を持つ2階同次線形常微分方程式</a><li><a href="/ja/posts/euler-cauchy-equation/">オイラー・コーシー方程式</a><li>逆行列と特異行列、行列式</ul><h2 id="連続な任意の変数係数を持つ同次線形常微分方程式">連続な任意の変数係数を持つ同次線形常微分方程式</h2><p>前回<a href="/ja/posts/homogeneous-linear-odes-with-constant-coefficients/">定数係数を持つ2階同次線形常微分方程式</a>と<a href="/ja/posts/euler-cauchy-equation/">オイラー・コーシー方程式</a>の一般解を学びました。 この記事では議論をより一般的な場合に拡張し、連続な任意の<strong>変数係数（variable coefficient）</strong> $p$と $q$を持つ2階同次線形常微分方程式</p>\[y^{\prime\prime} + p(x)y^{\prime} + q(x)y = 0 \label{eqn:homogeneous_linear_ode_with_var_coefficients}\tag{1}\]<p>の一般解の存在性と形態を調べます。さらに、常微分方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)と次の二つの初期条件</p>\[y(x_0)=K_0, \qquad y^{\prime}(x_0)=K_1 \label{eqn:initial_conditions}\tag{2}\]<p>で構成される<a href="/ja/posts/homogeneous-linear-odes-of-second-order/#初期値問題と初期条件">初期値問題</a>の一意性も検討します。</p><p>結論から先に言えば、連続な係数を持つ<u>線形</u>常微分方程式は<em>特異解（singular solution）</em>（一般解から得られない解）を持たないということがここで扱う内容の核心です。</p><h2 id="初期値問題の解の存在性と一意性の定理">初期値問題の解の存在性と一意性の定理</h2><blockquote class="prompt-info"><p><strong>初期値問題の解の存在性と一意性の定理（Existence and Uniqueness Theorem for Initial Value Problems）</strong><br /> もし $p(x)$と $q(x)$がある開区間 $I$で連続関数であり、$x_0$が区間 $I$内にあるならば、式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)と ($\ref{eqn:initial_conditions}$)で構成される初期値問題は区間 $I$で唯一の解 $y(x)$を持つ。</p></blockquote><p>存在性に関する証明はここでは扱わず、一意性の証明のみを見ていきます。通常、一意性を証明する方が存在性を証明するよりも簡単です。<br /> 証明に興味がなければ、この部分をスキップして<a href="#解の線形従属と線形独立">解の線形従属と線形独立</a>に進んでも構いません。</p><h3 id="一意性の証明">一意性の証明</h3><p>常微分方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)と初期条件 ($\ref{eqn:initial_conditions}$)で構成される初期値問題が区間 $I$で二つの解 $y_1(x)$と $y_2(x)$を持つと仮定します。これら二つの解の差</p>\[y(x) = y_1(x) - y_2(x)\]<p>が区間 $I$で恒等的に $0$となることを示せれば、区間 $I$で $y_1 \equiv y_2$ということになり、解の一意性を意味します。</p><p>方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)が同次線形常微分方程式であるため、$y_1$と $y_2$の線形結合である $y$は $I$で方程式の解となります。$y_1$と $y_2$が同じ初期条件 ($\ref{eqn:initial_conditions}$)を満たすので、$y$は条件</p>\[\begin{align*} &amp; y(x_0) = y_1(x_0) - y_2(x_0) = 0, \\ &amp; y^{\prime}(x_0) = y_1^{\prime}(x_0) - y_2^{\prime}(x_0) = 0 \end{align*} \label{eqn:initial_conditions_*}\tag{3}\]<p>を満たします。ここで関数</p>\[z(x) = y(x)^2 + y^{\prime}(x)^2\]<p>とその導関数</p>\[z^{\prime} = 2yy^{\prime} + 2y^{\prime}y^{\prime\prime}\]<p>を考えます。常微分方程式から</p>\[y^{\prime\prime} = -py^{\prime} - qy\]<p>を得て、これを $z^{\prime}$に関する式に代入すると</p>\[z^{\prime} = 2yy^{\prime} - 2p{y^{\prime}}^2 - 2qyy^{\prime} \label{eqn:z_prime}\tag{4}\]<p>となります。ここで $y$と $y^{\prime}$が実数であるため</p>\[(y\pm y^{\prime})^2 = y^2 \pm 2yy^{\prime} + {y^{\prime}}^2 \geq 0\]<p>となります。これと $z$の定義から二つの不等式</p>\[(a)\ 2yy^{\prime} \leq y^2 + {y^{\prime}}^2 = z, \qquad (b)\ 2yy^{\prime} \geq -(y^2 + {y^{\prime}}^2) = -z \label{eqn:inequalities}\tag{5}\]<p>を得ることができます。これら二つの不等式から $|2yy^{\prime}|\leq z$であることがわかり、式 ($\ref{eqn:z_prime}$)の最後の項については次の不等式が成立します。</p>\[\pm2qyy^{\prime} \leq |\pm 2qyy^{\prime}| = |q||2yy^{\prime}| \leq |q|z.\]<p>この結果と $-p \leq |p|$を用いて、式 ($\ref{eqn:z_prime}$)の項 $2yy^{\prime}$に式 ($\ref{eqn:inequalities}$a)を適用すると</p>\[z^{\prime} \leq z + 2|p|{y^{\prime}}^2 + |q|z\]<p>となります。${y^{\prime}}^2 \leq y^2 + {y^{\prime}}^2 = z$であるため、これから</p>\[z^{\prime} \leq (1 + 2|p| + |q|)z\]<p>を得て、括弧内の関数を $h = 1 + 2|p| + |q|$とおくと</p>\[z^{\prime} \leq hz \quad \forall x \in I \label{eqn:inequality_6a}\tag{6a}\]<p>となります。同様の方法で、式 ($\ref{eqn:z_prime}$)と ($\ref{eqn:inequalities}$)から</p>\[\begin{align*} -z^{\prime} &amp;= -2yy^{\prime} + 2p{y^{\prime}}^2 + 2qyy^{\prime} \\ &amp;\leq z + 2|p|z + |q|z = hz \end{align*} \label{eqn:inequality_6b}\tag{6b}\]<p>を得ます。これら二つの不等式 ($\ref{eqn:inequality_6a}$)、($\ref{eqn:inequality_6b}$)は次の不等式</p>\[z^{\prime} - hz \leq 0, \qquad z^{\prime} + hz \geq 0 \label{eqn:inequalities_7}\tag{7}\]<p>と同等であり、二つの式の左辺に対する<a href="/ja/posts/Solution-of-First-Order-Linear-ODE/#非同次線形常微分方程式">積分因子</a>は</p>\[F_1 = e^{-\int h(x)\ dx} \qquad \text{と} \qquad F_2 = e^{\int h(x)\ dx}\]<p>です。$h$が連続であるため不定積分 $\int h(x)\ dx$は存在し、$F_1$と $F_2$が正であるため式 ($\ref{eqn:inequalities_7}$)から</p>\[F_1(z^{\prime} - hz) = (F_1 z)^{\prime} \leq 0, \qquad F_2(z^{\prime} + hz) = (F_2 z)^{\prime} \geq 0\]<p>を得ます。これは区間 $I$で $F_1 z$が増加せず、$F_2 z$が減少しないことを意味します。式 ($\ref{eqn:initial_conditions_*}$)により $z(x_0) = 0$であるため、</p>\[\begin{cases} \left(F_1 z \geq (F_1 z)_{x_0} = 0\right)\ \&amp; \ \left(F_2 z \leq (F_2 z)_{x_0} = 0\right) &amp; (x \leq x_0) \\ \left(F_1 z \leq (F_1 z)_{x_0} = 0\right)\ \&amp; \ \left(F_2 z \geq (F_2 z)_{x_0} = 0\right) &amp; (x \geq x_0) \end{cases}\]<p>となります。最後に不等式の両辺を正の $F_1$と $F_2$で割ると、次のように解の一意性を示すことができます。</p>\[(z \leq 0) \ \&amp; \ (z \geq 0) \quad \forall x \in I\] \[z = y^2 + {y^{\prime}}^2 = 0 \quad \forall x \in I\] \[\therefore y \equiv y_1 - y_2 \equiv 0 \quad \forall x \in I. \ \blacksquare\]<h2 id="解の線形従属と線形独立">解の線形従属と線形独立</h2><p><a href="/ja/posts/homogeneous-linear-odes-of-second-order/#基底と一般解">2階同次線形常微分方程式</a>で扱った内容を少し思い出しましょう。開区間 $I$での一般解は $I$での<strong>基底（basis）</strong> $y_1$、$y_2$、つまり線形独立な解のペアから作られます。ここで $y_1$と $y_2$が区間 $I$で<strong>線形独立（linearly independent）</strong>であるとは、区間内のすべての $x$について次を満たすことを意味します。</p>\[k_1y_1(x) + k_2y_2(x) = 0 \Leftrightarrow k_1=0\text{かつ }k_2=0 \label{eqn:linearly_independent}\tag{8}\]<p>もし上記を満たさず、少なくとも一つの $0$でない $k_1$、$k_2$について $k_1y_1(x) + k_2y_2(x) = 0$が成立する場合、$y_1$と $y_2$は区間 $I$で<strong>線形従属（linearly dependent）</strong>です。この場合、区間 $I$のすべての $x$について</p>\[\text{(a) } y_1 = ky_2 \quad \text{または} \quad \text{(b) } y_2 = ly_1 \label{eqn:linearly_dependent}\tag{9}\]<p>となり、$y_1$と $y_2$は比例します。</p><p>ここで次の解の線形独立/線形従属の判別法を見ていきましょう。</p><blockquote class="prompt-info"><p><strong>ロンスキアン（Wronskian）を用いた解の線形従属/線形独立の判別</strong><br /> <strong>i.</strong> 常微分方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)が開区間 $I$で連続な係数 $p(x)$と $q(x)$を持つならば、区間 $I$で方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)の二つの解 $y_1$と $y_2$が線形従属となるための必要十分条件は、これらの解の<em>ロンスキー行列式（Wronski determinant）</em>、略して<strong>ロンスキアン（Wronskian）</strong>と呼ばれる次の行列式</p>\[W(y_1, y_2) = \begin{vmatrix} y_1 &amp; y_2 \\ y_1^{\prime} &amp; y_2^{\prime} \\ \end{vmatrix} = y_1y_2^{\prime} - y_2y_1^{\prime} \label{eqn:wronskian}\tag{10}\]<p>が区間 $I$内のある $x_0$で $0$となることである。</p>\[\exists x_0 \in I: W(x_0)=0 \iff y_1 \text{と } y_2 \text{は線形従属}\]<p><strong>ii.</strong> 区間 $I$内の一点 $x=x_0$で $W=0$ならば、区間 $I$内のすべての $x$で $W=0$である。</p>\[\exists x_0 \in I: W(x_0)=0 \implies \forall x \in I: W(x)=0\]<p>つまり、$W\neq 0$となる $x_1$が区間 $I$に存在するならば、その区間 $I$では $y_1$、$y_2$は線形独立である。</p>\[\begin{align*} \exists x_1 \in I: W(x_1)\neq 0 &amp;\implies \forall x \in I: W(x)\neq 0 \\ &amp;\implies y_1 \text{と } y_2 \text{は線形独立} \end{align*}\]</blockquote><blockquote class="prompt-tip"><p>ロンスキアンはポーランドの数学者ユゼフ・マリア・ホエネ＝ヴロンスキ（Józef Maria Hoene-Wroński）によって初めて導入され、彼の死後の11882 HEにスコットランドの数学者トーマス・ミュア（Sir Thomas Muir）によって現在の名前が付けられました。</p></blockquote><h3 id="証明">証明</h3><h4 id="i-a">i. (a)</h4><p>区間 $I$で $y_1$と $y_2$が線形従属であるとします。すると区間 $I$で式 ($\ref{eqn:linearly_dependent}$a)または($\ref{eqn:linearly_dependent}$b)が成立します。もし式 ($\ref{eqn:linearly_dependent}$a)が成立するなら</p>\[W(y_1, y_2) = y_1y_2^{\prime} - y_2y_1^{\prime} = ky_2ky_2^{\prime} - y_2ky_2^{\prime} = 0\]<p>となり、同様に式 ($\ref{eqn:linearly_dependent}$b)が成立する場合も</p>\[W(y_1, y_2) = y_1y_2^{\prime} - y_2y_1^{\prime} = y_1ly_1^{\prime} - ly_1y_1^{\prime} = 0\]<p>となるため、<u>区間 $I$内のすべての $x$について</u>ロンスキアン $W(y_1, y_2)=0$であることが確認できます。</p><h4 id="i-b">i. (b)</h4><p>逆に、ある $x = x_0$で $W(y_1, y_2)=0$であるとき、区間 $I$で $y_1$と $y_2$が線形従属となることを示します。未知数 $k_1$、$k_2$に関する線形連立方程式</p>\[\begin{gather*} k_1y_1(x_0) + k_2y_2(x_0) = 0 \\ k_1y_1^{\prime}(x_0) + k_2y_2^{\prime}(x_0) = 0 \end{gather*} \label{eqn:linear_system}\tag{11}\]<p>を考えます。これは次のようなベクトル方程式の形で表現できます。</p>\[\left[\begin{matrix} y_1(x_0) &amp; y_2(x_0) \\ y_1^{\prime}(x_0) &amp; y_2^{\prime}(x_0) \end{matrix}\right] \left[\begin{matrix} k_1 \\ k_2 \end{matrix}\right] = 0 \label{eqn:vector_equation}\tag{12}\]<p>このベクトル方程式の係数行列は</p>\[A = \left[\begin{matrix} y_1(x_0) &amp; y_2(x_0) \\ y_1^{\prime}(x_0) &amp; y_2^{\prime}(x_0) \end{matrix}\right]\]<p>であり、この行列の行列式はまさに $W(y_1(x_0), y_2(x_0))$です。$\det(A) = W=0$であるため、$A$は<strong>逆行列（inverse matrix）</strong>が存在しない<strong>特異行列（singular matrix）</strong>であり、したがって連立方程式 ($\ref{eqn:linear_system}$)は $k_1$と $k_2$の少なくとも一方は $0$でないゼロベクトル $(0,0)$以外の解 $(c_1, c_2)$を持ちます。ここで関数</p>\[y(x) = c_1y_1(x) + c_2y_2(x)\]<p>を導入します。方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)が同次線形であるため、<a href="/ja/posts/homogeneous-linear-odes-of-second-order/#重ね合わせの原理">重ね合わせの原理</a>によりこの関数は区間 $I$で ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)の解となります。式 ($\ref{eqn:linear_system}$)からこの解は初期条件 $y(x_0)=0$、$y^{\prime}(x_0)=0$を満たすことがわかります。</p><p>一方、同じ初期条件 $y^*(x_0)=0$、${y^*}^{\prime}(x_0)=0$を満たす自明解 $y^* \equiv 0$が存在します。方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)の係数 $p$と $q$が連続であるため、<a href="#初期値問題の解の存在性と一意性の定理">初期値問題の解の存在性と一意性の定理</a>により解の一意性が保証され、したがって $y \equiv y^*$です。つまり、区間 $I$で</p>\[c_1y_1 + c_2y_2 \equiv 0\]<p>となります。$c_1$と $c_2$の少なくとも一方は $0$でないため ($\ref{eqn:linearly_independent}$)を満たさず、これは区間 $I$で $y_1$、$y_2$が線形従属であることを意味します。</p><h4 id="ii">ii.</h4><p>もし区間 $I$内のある一点 $x_0$で $W(x_0)=0$ならば、<a href="#i-b">i.(b)</a>により区間 $I$で $y_1$、$y_2$は線形従属であり、そうすると<a href="#i-a">i.(a)</a>により $W\equiv 0$です。したがって $W(x_1)\neq 0$となる $x_1$が区間 $I$内に一つでも存在するならば、$y_1$と $y_2$は線形独立です。$\blacksquare$</p><h2 id="一般解はすべての解を含む">一般解はすべての解を含む</h2><h3 id="一般解の存在">一般解の存在</h3><blockquote class="prompt-info"><p>もし $p(x)$と $q(x)$が開区間 $I$で連続ならば、方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)は区間 $I$で一般解を持つ。</p></blockquote><h4 id="証明-1">証明</h4><p><a href="#初期値問題の解の存在性と一意性の定理">初期値問題の解の存在性と一意性の定理</a>により、常微分方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)は区間 $I$で初期条件</p>\[y_1(x_0) = 1, \qquad y_1^{\prime}(x_0) = 0\]<p>を満たす解 $y_1(x)$と区間 $I$で初期条件</p>\[y_2(x_0) = 0, \qquad y_2^{\prime}(x_0) = 1\]<p>を満たす解 $y_2(x)$を持ちます。これら二つの解のロンスキアンは $x=x_0$で$0$でない値</p>\[W(y_1(x_0), y_2(x_0)) = y_1(x_0)y_2^{\prime}(x_0) - y_2(x_0)y_1^{\prime}(x_0) = 1\cdot 1 - 0\cdot 0 = 1\]<p>を持つため、<a href="#解の線形従属と線形独立">ロンスキアン（Wronskian）を用いた解の線形従属/線形独立の判別</a>により区間 $I$で $y_1$と $y_2$は線形独立です。したがって、これら二つの解は区間 $I$で方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)の解の基底を形成し、任意の定数 $c_1$、$c_2$を持つ一般解 $y = c_1y_1 + c_2y_2$が区間 $I$で必ず存在します。$\blacksquare$</p><h3 id="特異解の非存在">特異解の非存在</h3><blockquote class="prompt-info"><p>常微分方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)がある開区間 $I$で連続な係数 $p(x)$と $q(x)$を持つならば、区間 $I$での方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)のすべての解 $y=Y(x)$は</p>\[Y(x) = C_1y_1(x) + C_2y_2(x) \label{eqn:particular_solution}\tag{13}\]<p>の形であり、ここで $y_1$、$y_2$は区間 $I$での方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)の解の基底であり、$C_1$、$C_2$ は適当な定数である。<br /> つまり、方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)は一般解から得られない解である<strong>特異解（singular solution）</strong>を持たない。</p></blockquote><h4 id="証明-2">証明</h4><p>$y=Y(x)$を区間 $I$での方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)のある解とします。<a href="#一般解の存在">一般解の存在定理</a>により常微分方程式 ($\ref{eqn:homogeneous_linear_ode_with_var_coefficients}$)は区間 $I$で一般解</p>\[y(x) = c_1y_1(x) + c_2y_2(x) \label{eqn:general_solution}\tag{14}\]<p>を持ちます。ここで任意の $Y(x)$について区間 $I$で $y(x)=Y(x)$となるような定数 $c_1$、$c_2$が存在することを示す必要があります。区間 $I$で任意の $x_0$を選んだとき、$y(x_0)=Y(x_0)$かつ $y^{\prime}(x_0)=Y^{\prime}(x_0)$となるような $c_1$、$c_2$の値を見つけられることをまず示しましょう。式 ($\ref{eqn:general_solution}$)から</p>\[\begin{gather*} \left[\begin{matrix} y_1(x_0) &amp; y_2(x_0) \\ y_1^{\prime}(x_0) &amp; y_2^{\prime}(x_0) \end{matrix}\right] \left[\begin{matrix} c_1 \\ c_2 \end{matrix}\right] = \left[\begin{matrix} Y(x_0) \\ Y^{\prime}(x_0) \end{matrix}\right] \end{gather*} \label{eqn:vector_equation_2}\tag{15}\]<p>が得られます。$y_1$と $y_2$が基底であるため、係数行列の行列式である $W(y_1(x_0), y_2(x_0))\neq 0$であり、したがって方程式 ($\ref{eqn:vector_equation_2}$)は $c_1$と $c_2$について解くことができます。その解を $(c_1, c_2) = (C_1, C_2)$とします。これを式 ($\ref{eqn:general_solution}$)に代入すると次の特殊解が得られます。</p>\[y^*(x) = C_1y_1(x) + C_2y_2(x).\]<p>$C_1$、$C_2$が方程式 ($\ref{eqn:vector_equation_2}$)の解であるため、</p>\[y^*(x_0) = Y(x_0), \qquad {y^*}^{\prime}(x_0) = Y^{\prime}(x_0)\]<p>となります。<a href="#初期値問題の解の存在性と一意性の定理">初期値問題の解の存在性と一意性の定理</a>の一意性により、区間 $I$内のすべての $x$について $y^* \equiv Y$です。$\blacksquare$</p>]]> </content> </entry> <entry><title xml:lang="ja">オイラー・コーシー方程式</title><link href="https://www.yunseo.kim/ja/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/euler-cauchy-equation/" rel="alternate" type="text/html" hreflang="am" /><published>2025-03-28T00:00:00+09:00</published> <updated>2025-07-11T20:37:36+09:00</updated> <id>https://www.yunseo.kim/ja/posts/euler-cauchy-equation/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Differential Equation" /> <summary xml:lang="ja">補助方程式の判別式の符号に応じて、それぞれの場合にオイラー・コーシー方程式の一般解がどのような形になるかを考察する。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>補助方程式の判別式の符号に応じて、それぞれの場合にオイラー・コーシー方程式の一般解がどのような形になるかを考察する。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><ul><li>オイラー・コーシー方程式: $x^2y^{\prime\prime} + axy^{\prime} + by = 0$<li><strong>補助方程式(auxiliary equation)</strong>: $m^2 + (a-1)m + b = 0$<li>補助方程式の判別式 $(1-a)^2 - 4b$の符号によって一般解の形を表のように三つの場合に分けることができる</ul><table><thead><tr><th style="text-align: center">場合<th style="text-align: center">補助方程式の解<th style="text-align: center">オイラー・コーシー方程式の解の基底<th style="text-align: center">オイラー・コーシー方程式の一般解<tbody><tr><td style="text-align: center">I<td style="text-align: center">異なる実根<br />$m_1$, $m_2$<td style="text-align: center">$x^{m_1}$, $x^{m_2}$<td style="text-align: center">$y = c_1 x^{m_1} + c_2 x^{m_2}$<tr><td style="text-align: center">II<td style="text-align: center">重実根<br /> $m = \cfrac{1-a}{2}$<td style="text-align: center">$x^{(1-a)/2}$, $x^{(1-a)/2}\ln{x}$<td style="text-align: center">$y = (c_1 + c_2 \ln x)x^m$<tr><td style="text-align: center">III<td style="text-align: center">共役複素根<br /> $m_1 = \cfrac{1}{2}(1-a) + i\omega$, <br /> $m_2 = \cfrac{1}{2}(1-a) - i\omega$<td style="text-align: center">$x^{(1-a)/2}\cos{(\omega \ln{x})}$, <br /> $x^{(1-a)/2}\sin{(\omega \ln{x})}$<td style="text-align: center">$y = x^{(1-a)/2}[A\cos{(\omega \ln{x})} + B\sin{(\omega \ln{x})}]$</table></blockquote><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/homogeneous-linear-odes-of-second-order/">2階同次線形常微分方程式 (Homogeneous Linear ODEs of Second Order)</a><li><a href="/ja/posts/homogeneous-linear-odes-with-constant-coefficients/">定数係数を持つ2階同次線形常微分方程式</a><li>オイラーの公式</ul><h2 id="補助方程式-auxiliary-equation">補助方程式 (auxiliary equation)</h2><p><strong>オイラー・コーシー方程式(Euler-Cauchy equation)</strong>は、与えられた定数 $a$と $b$、そして未知関数 $y(x)$を持つ</p>\[x^2y^{\prime\prime} + axy^{\prime} + by = 0 \label{eqn:euler_cauchy_eqn}\tag{1}\]<p>形式の常微分方程式である。式 ($\ref{eqn:euler_cauchy_eqn}$)に</p>\[y=x^m, \qquad y^{\prime}=mx^{m-1}, \qquad y^{\prime\prime}=m(m-1)x^{m-2}\]<p>を代入すると</p>\[x^2m(m-1)x^{m-2} + axmx^{m-1} + bx^m = 0,\]<p>つまり</p>\[[m(m-1) + am + b]x^m = 0\]<p>を得る。これより補助方程式</p>\[m^2 + (a-1)m + b = 0 \label{eqn:auxiliary_eqn}\tag{2}\]<p>を得る。$y=x^m$がオイラー・コーシー方程式 ($\ref{eqn:euler_cauchy_eqn}$)の解となるための必要十分条件は、$m$が補助方程式 ($\ref{eqn:auxiliary_eqn}$)の解となることである。</p><p>二次方程式 ($\ref{eqn:auxiliary_eqn}$)の解を求めると</p>\[\begin{align*} m_1 &amp;= \frac{1}{2}\left[(1-a) + \sqrt{(1-a)^2 - 4b} \right], \\ m_2 &amp;= \frac{1}{2}\left[(1-a) - \sqrt{(1-a)^2 - 4b} \right] \end{align*}\label{eqn:m1_and_m2}\tag{3}\]<p>となり、これより二つの関数</p>\[y_1 = x^{m_1}, \quad y_2 = x^{m_2}\]<p>が方程式 ($\ref{eqn:euler_cauchy_eqn}$)の解となる。</p><p><a href="/ja/posts/homogeneous-linear-odes-with-constant-coefficients/">定数係数を持つ2階同次線形常微分方程式</a>と同様に、補助方程式 ($\ref{eqn:auxiliary_eqn}$)の判別式 $(1-a)^2 - 4b$の符号によって場合を三つに分けることができる。</p><ul><li>$(1-a)^2 - 4b &gt; 0$: 異なる二つの実根<li>$(1-a)^2 - 4b = 0$: 実重根<li>$(1-a)^2 - 4b &lt; 0$: 共役複素根</ul><h2 id="補助方程式の判別式の符号による一般解の形">補助方程式の判別式の符号による一般解の形</h2><h3 id="i-異なる二つの実根-m_1と-m_2">I. 異なる二つの実根 $m_1$と $m_2$</h3><p>この場合、任意の区間で方程式 ($\ref{eqn:euler_cauchy_eqn}$)の解の基底は</p>\[y_1 = x^{m_1}, \quad y_2 = x^{m_2}\]<p>であり、これに対応する一般解は</p>\[y = c_1 x^{m_1} + c_2 x^{m_2} \label{eqn:general_sol_1}\tag{4}\]<p>である。</p><h3 id="ii-実重根-m--cfrac1-a2">II. 実重根 $m = \cfrac{1-a}{2}$</h3><p>$(1-a)^2 - 4b = 0$、つまり $b=\cfrac{(1-a)^2}{4}$の場合、二次方程式 ($\ref{eqn:auxiliary_eqn}$)は一つの解 $m = m_1 = m_2 = \cfrac{1-a}{2}$のみを持ち、したがってこれから得られる $y = x^m$ 形式の一つの解は</p>\[y_1 = x^{(1-a)/2}\]<p>であり、オイラー・コーシー方程式 ($\ref{eqn:euler_cauchy_eqn}$)は</p>\[y^{\prime\prime} + \frac{a}{x}y^{\prime} + \frac{(1-a)^2}{4x^2}y = 0 \label{eqn:standard_form}\tag{5}\]<p>の形になる。ここで線形独立なもう一つの解 $y_2$を<a href="/ja/posts/homogeneous-linear-odes-of-second-order/#次数低下法-reduction-of-order">次数低下法</a>を用いて求めよう。</p><p>求めたい二番目の解を $y_2=uy_1$とおくと</p>\[u = \int U, \qquad U = \frac{1}{y_1^2}\exp\left(-\int \frac{a}{x}\ dx \right)\]<p>を得る。</p><p>$\exp \left(-\int \cfrac{a}{x}\ dx \right) = \exp (-a\ln x) = \exp(\ln{x^{-a}}) = x^{-a}$なので、</p>\[U = \frac{x^{-a}}{y_1^2} = \frac{x^{-a}}{x^{(1-a)}} = \frac{1}{x}\]<p>となり、積分すると $u = \ln x$を得る。</p><p>したがって $y_2 = uy_1 = y_1 \ln x$であり、$y_1$と $y_2$はその比が定数ではないため線形独立である。基底 $y_1$と $y_2$に対応する一般解は</p>\[y = (c_1 + c_2 \ln x)x^m \label{eqn:general_sol_2}\tag{6}\]<p>である。</p><h3 id="iii-共役複素根">III. 共役複素根</h3><p>この場合、補助方程式 ($\ref{eqn:auxiliary_eqn}$)の解は $m = \cfrac{1}{2}(1-a) \pm i\sqrt{b - \frac{1}{4}(1-a)^2}$となり、これに対応する方程式 ($\ref{eqn:euler_cauchy_eqn}$)の二つの複素解は $x=e^{\ln x}$を利用して次のように書くことができる。</p>\[\begin{align*} x^{m_1} &amp;= x^{(1-a)/2 + i\sqrt{b - \frac{1}{4}(1-a)^2}} \\ &amp;= x^{(1-a)/2}(e^{\ln x})^{i\sqrt{b - \frac{1}{4}(1-a)^2}} \\ &amp;= x^{(1-a)/2}e^{i(\sqrt{b - \frac{1}{4}(1-a)^2}\ln x)}, \\ x^{m_2} &amp;= x^{(1-a)/2 - i\sqrt{b - \frac{1}{4}(1-a)^2}} \\ &amp;= x^{(1-a)/2}(e^{\ln x})^{-i\sqrt{b - \frac{1}{4}(1-a)^2}} \\ &amp;= x^{(1-a)/2}e^{i(-\sqrt{b - \frac{1}{4}(1-a)^2}\ln x)}. \end{align*} \tag{7}\]<p>$t=\sqrt{b - \frac{1}{4}(1-a)^2}\ln x$とおき、オイラーの公式 $e^{it} = \cos{t} + i\sin{t}$を用いると</p>\[\begin{align*} x^{m_1} &amp;= x^{(1-a)/2}\left[\cos\left(\sqrt{b - \tfrac{1}{4}(1-a)^2}\ln x \right) + i\sin\left(\sqrt{b - \tfrac{1}{4}(1-a)^2}\ln x \right) \right], \\ x^{m_2} &amp;= x^{(1-a)/2}\left[\cos\left(\sqrt{b - \tfrac{1}{4}(1-a)^2}\ln x \right) - i\sin\left(\sqrt{b - \tfrac{1}{4}(1-a)^2}\ln x \right) \right] \end{align*} \tag{8}\]<p>であることがわかり、これより次の二つの実数解</p>\[\begin{align*} \frac{x^{m_1} + x^{m_2}}{2} &amp;= x^{(1-a)/2}\cos\left(\sqrt{b - \tfrac{1}{4}(1-a)^2}\ln x \right), \\ \frac{x^{m_1} - x^{m_2}}{2i} &amp;= x^{(1-a)/2}\sin\left(\sqrt{b - \tfrac{1}{4}(1-a)^2}\ln x \right) \end{align*} \tag{9}\]<p>を得る。</p><p>これらの比 $\cos\left(\sqrt{b - \frac{1}{4}(1-a)^2}\ln x \right)$が定数ではないため、上記の二つの解は線形独立であり、したがって<a href="/ja/posts/homogeneous-linear-odes-of-second-order/#重ね合わせの原理">重ね合わせの原理</a>によりオイラー・コーシー方程式 ($\ref{eqn:euler_cauchy_eqn}$)の基底を形成する。これより次の実数一般解を得る。</p>\[y = x^{(1-a)/2} \left[ A\cos\left(\sqrt{b - \tfrac{1}{4}(1-a)^2}\ln x \right) + B\sin\left(\sqrt{b - \tfrac{1}{4}(1-a)^2}\ln x \right) \right]. \label{eqn:general_sol_3}\tag{10}\]<p>ただし、オイラー・コーシー方程式において補助方程式が共役複素根を持つ場合は実質的な重要性はそれほど大きくない。</p><h2 id="定数係数を持つ2階同次線形常微分方程式への変換">定数係数を持つ2階同次線形常微分方程式への変換</h2><p>オイラー・コーシー方程式は変数変換によって<a href="/ja/posts/homogeneous-linear-odes-with-constant-coefficients/">定数係数を持つ2階同次線形常微分方程式</a>に変換することができる。</p><p>$x = e^t$と変換すると</p>\[\frac{d}{dx} = \frac{1}{x}\frac{d}{dt}, \quad \frac{d^2}{dx^2} = \frac{1}{x^2}\left(\frac{d^2}{dt^2} - \frac{d}{dt} \right)\]<p>となり、オイラー・コーシー方程式 ($\ref{eqn:euler_cauchy_eqn}$)は次のように $t$に関する定数係数同次線形常微分方程式に変わる。</p>\[y^{\prime\prime}(t) + (a-1)y^{\prime}(t) + by(t) = 0. \label{eqn:substituted}\tag{11}\]<p>方程式 ($\ref{eqn:substituted}$)に<a href="/ja/posts/homogeneous-linear-odes-with-constant-coefficients/">定数係数を持つ2階同次線形常微分方程式</a>の解法を適用して $t$について解き、そうして得られた解を $t = \ln{x}$を用いて再び $x$に関する解に変換すると、<a href="#補助方程式の判別式の符号による一般解の形">先ほど検討したのと同じ結果</a>が得られる。</p>]]> </content> </entry> <entry><title xml:lang="ja">級数の収束/発散判定(Testing for Convergence or Divergence of a Series)</title><link href="https://www.yunseo.kim/ja/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/testing-for-convergence-or-divergence-of-a-series/" rel="alternate" type="text/html" hreflang="am" /><published>2025-03-18T00:00:00+09:00</published> <updated>2025-05-13T16:24:07+09:00</updated> <id>https://www.yunseo.kim/ja/posts/testing-for-convergence-or-divergence-of-a-series/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Calculus" /> <summary xml:lang="ja">級数の収束/発散を判定するさまざまな方法を総合的に考察する。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>級数の収束/発散を判定するさまざまな方法を総合的に考察する。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><ul><li><strong>一般項判定法($n$th-term test for divergence)</strong>: $\lim_{n\to\infty} a_n \neq 0 \Rightarrow \text{級数 }\sum a_n \text{は発散}$<li><strong>等比級数の収束/発散</strong>: 等比級数 $\sum ar^{n-1}$は<ul><li>$|r| &lt; 1$なら収束<li>$|r| \geq 1$なら発散</ul><li><strong>$p$-級数の収束/発散</strong>: $p$-級数 $\sum \cfrac{1}{n^p}$は<ul><li>$p&gt;1$なら収束<li>$p\leq 1$なら発散</ul><li><strong>比較判定法(Comparison Test)</strong>: $0 \leq a_n \leq b_n$のとき、<ul><li>$\sum b_n &lt; \infty \ \Rightarrow \ \sum a_n &lt; \infty$<li>$\sum a_n = \infty \ \Rightarrow \ \sum b_n = \infty$</ul><li><strong>極限比較判定法(Limit Comparison Test)</strong>: もし $\lim_{n\to\infty} \frac{a_n}{b_n} = c \text{ (}c\text{は有限な正数)}$ならば、二つの級数 $\sum a_n$と $\sum b_n$は両方とも収束するか両方とも発散する<li>正項級数 $\sum a_n$と正数 $\epsilon &lt; 1$に対して<ul><li>すべての $n$に対して $\sqrt[n]{a_n}&lt; 1-\epsilon$ならば級数 $\sum a_n$は収束<li>すべての $n$に対して $\sqrt[n]{a_n}&gt; 1+\epsilon$ならば級数 $\sum a_n$は発散</ul><li><strong>冪根判定法(Root Test)</strong>: 正項級数 $\sum a_n$において極限値 $\lim_{n\to\infty} \sqrt[n]{a_n} =: r$が存在する場合、<ul><li>$r&lt;1$ならば級数 $\sum a_n$は収束<li>$r&gt;1$ならば級数 $\sum a_n$は発散</ul><li><strong>比判定法(Ratio Test)</strong>: 正数の数列 $(a_n)$と $0 &lt; r &lt; 1$に対して<ul><li>すべての $n$に対して $a_{n+1}/a_n \leq r$ならば、級数 $\sum a_n$は収束<li>すべての $n$に対して $a_{n+1}/a_n \geq 1$ならば、級数 $\sum a_n$は発散</ul><li>正数の数列 $(a_n)$において極限値 $\rho := \lim_{n\to\infty} \cfrac{a_{n+1}}{a_n}$が存在するとすると、<ul><li>$\rho &lt; 1$ならば級数 $\sum a_n$は収束<li>$\rho &gt; 1$ならば級数 $\sum a_n$は発散</ul><li><strong>積分判定法(Integral Test)</strong>: 連続関数 $f: \left[1,\infty \right) \rightarrow \mathbb{R}$が減少関数であり常に $f(x)&gt;0$のとき、級数 $\sum f(n)$が収束する必要十分条件は積分 $\int_1^\infty f(x)\ dx := \lim_{b\to\infty} \int_1^b f(x)\ dx$が収束すること<li><strong>交代級数判定法(Alternating Series Test)</strong>: 次の条件を満たす場合、交代級数 $\sum a_n$は収束する<ol><li>すべての $n$に対して $a_n$と $a_{n+1}$の符号が異なる<li>すべての $n$に対して $|a_n| \geq |a_{n+1}|$<li>$\lim_{n\to\infty} a_n = 0$</ol><li>絶対収束する級数は収束する。逆は成立しない。</ul></blockquote><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/sequences-and-series/">数列と級数</a></ul><h2 id="はじめに">はじめに</h2><p>前回の<a href="/ja/posts/sequences-and-series/#級数の収束と発散">数列と級数</a>で級数の収束と発散の定義について学びました。この記事では、級数の収束/発散を判定する際に使用できるさまざまな方法をまとめます。一般的に、級数の収束/発散判定は、級数の和を正確に求めるよりもはるかに簡単です。</p><h2 id="一般項判定法">一般項判定法</h2><p>級数 $\sum a_n$において、$a_n$をその級数の<strong>一般項</strong>と呼びます。</p><p>次の定理により、ある級数が明らかに発散することを簡単に知ることができ、したがって、ある級数の収束/発散を判定する際には、これを最初に確認することが時間の無駄を防ぐ賢明な方法です。</p><blockquote class="prompt-info"><p><strong>一般項判定法($n$th-term test for divergence)</strong><br /> 級数 $\sum a_n$が収束するならば、</p>\[\lim_{n\to\infty} a_n=0\]<p>である。つまり、</p>\[\lim_{n\to\infty} a_n \neq 0 \Rightarrow \text{級数 }\sum a_n \text{は発散}\]<p>である。</p></blockquote><h3 id="証明">証明</h3><p>収束するある級数 $\sum a_n$の和を $l$とし、最初の $n$項までの和を</p>\[s_n := a_1 + a_2 + \cdots + a_n\]<p>とすると、</p>\[\forall \epsilon &gt; 0,\, \exists N \in \mathbb{N}\ (n &gt; N \Rightarrow |s_n - l| &lt; \epsilon).\]<p>したがって、十分大きい($&gt;N$) $n$に対して</p>\[|a_n| = |s_n - s_{n-1}| = |(s_n - l) - (s_{n-1} - l)| \leq |s_n - l| + |s_{n-1} - l| \leq \epsilon + \epsilon = 2\epsilon\]<p>となるため、数列の収束の定義から</p>\[\lim_{n\to\infty} |a_n| = 0. \quad \blacksquare\]<h3 id="注意事項">注意事項</h3><p>この定理の逆は一般的に真ではありません。これを示す代表的な例は<strong>調和級数(harmonic series)</strong>です。</p><p>調和級数は各項が<strong>等差数列</strong>の逆数で与えられる数列、つまり<strong>調和数列</strong>から得られる級数です。代表的な調和級数は</p>\[H_n := 1 + \frac{1}{2} + \cdots + \frac{1}{n} \quad (n=1,2,3,\dots)\]<p>です。この級数が発散することは次のように示すことができます。</p>\[\begin{align*} \lim_{n\to\infty} H_n &amp;= 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \frac{1}{5} + \frac{1}{6} + \frac{1}{7} + \frac{1}{8} + \frac{1}{9} + \cdots + \frac{1}{16} + \cdots \\ &amp;&gt; 1 + \frac{1}{2} + \frac{1}{4} + \frac{1}{4} + \frac{1}{8} + \frac{1}{8} + \frac{1}{8} + \frac{1}{8} + \frac{1}{16} + \cdots + \frac{1}{16} + \cdots \\ &amp;= 1 + \frac{1}{2} \qquad\, + \frac{1}{2} \qquad\qquad\qquad\ \ + \frac{1}{2} \qquad\qquad\quad + \frac{1}{2} + \cdots \\ &amp;= \infty. \end{align*}\]<p>このように級数 $H_n$は発散するにもかかわらず、一般項 $1/n$は $0$に収束することがわかります。</p><blockquote class="prompt-danger"><p>$\lim_{n\to\infty} a_n \neq 0$ならば級数 $\sum a_n$は必ず発散しますが、$\lim_{n\to\infty} a_n = 0$だからといって級数 $\sum a_n$が収束すると考えるのは危険であり、この場合は他の方法を使用して収束/発散を判定する必要があります。</p></blockquote><h2 id="等比級数">等比級数</h2><p>初項が1で<strong>公比</strong>が $r$の等比数列から得られる<strong>等比級数(geometric series)</strong></p>\[1 + r + r^2 + r^3 + \cdots \label{eqn:geometric_series}\tag{5}\]<p>は<u>最も重要で基本的な級数</u>です。このとき等式</p>\[(1-r)(1+r+\cdots + r^{n-1}) = 1 - r^n\]<p>から</p>\[1 + r + \cdots + r^{n-1} = \frac{1-r^n}{1-r} = \frac{1}{1-r} - \frac{r^n}{1-r} \qquad (r \neq 1) \label{eqn:sum_of_geometric_series}\tag{6}\]<p>を得ます。一方</p>\[\lim_{n\to\infty} r^n = 0 \quad \Leftrightarrow \quad |r| &lt; 1\]<p>であるため、等比級数 ($\ref{eqn:geometric_series}$)が収束する必要十分条件は $|r| &lt; 1$であることがわかります。</p><blockquote class="prompt-info"><p><strong>等比級数の収束/発散</strong><br /> 等比級数 $\sum ar^{n-1}$は</p><ul><li>$|r| &lt; 1$なら収束<li>$|r| \geq 1$なら発散</ul></blockquote><p>これにより</p>\[1 + r + r^2 + r^3 + \cdots = \frac{1}{1-r} \qquad (|r| &lt; 1) \label{eqn:sum_of_inf_geometric_series}\tag{7}\]<p>を得ます。</p><h3 id="等比級数と近似値">等比級数と近似値</h3><p>恒等式 ($\ref{eqn:sum_of_geometric_series}$)は $|r| &lt; 1$のとき $\cfrac{1}{1-r}$の近似値を求めるのに有用です。</p><p>この式に $r=-\epsilon$、$n=2$を代入すると</p>\[\frac{1}{1+\epsilon} - (1 - \epsilon) = \frac{\epsilon^2}{1 + \epsilon}\]<p>を得ます。したがって $0 &lt; \epsilon &lt; 1$ならば</p>\[0 &lt; \frac{1}{1 + \epsilon} - (1 - \epsilon) &lt; \epsilon^2\]<p>となるので</p>\[\frac{1}{1 + \epsilon} \approx (1 - \epsilon) \pm \epsilon^2 \qquad (0 &lt; \epsilon &lt; 1)\]<p>を得ます。これにより、十分小さい正数 $\epsilon$に対して $\cfrac{1}{1 + \epsilon}$は $1 - \epsilon$で近似できることがわかります。</p><h2 id="p-級数判定法-p-series-test">$p$-級数判定法 ($p$-Series Test)</h2><p>正の実数 $p$に対して、次のような形の級数を<strong>$p$-級数</strong>と呼びます。</p>\[\sum_{n=1}^{\infty} \frac{1}{n^p}\]<blockquote class="prompt-info"><p><strong>$p$-級数の収束/発散</strong><br /> $p$-級数 $\sum \cfrac{1}{n^p}$は</p><ul><li>$p&gt;1$なら収束<li>$p\leq 1$なら発散</ul></blockquote><p>$p$-級数で $p=1$の場合は調和級数となり、これが発散することは先に示しました。<br /> $p=2$の場合の $p$-級数、つまり $\sum \cfrac{1}{n^2}$の値を求める問題は、この級数が収束することを最初に示し、また何世代にもわたって有名な数学者を多数輩出した家系でもあるベルヌーイ家の拠点の名前にちなんで「バーゼル(Basel)問題」と呼ばれています。この問題の答えは $\cfrac{\pi^2}{6}$であることが知られています。</p><p>また、より一般的には、$p$-級数で $p&gt;1$の場合を<strong>ゼータ関数(zeta function)</strong>と呼びます。これはレオンハルト・オイラー(Leonhard Euler)が<a href="https://en.wikipedia.org/wiki/Holocene_calendar">人類紀元</a> 11740年に導入し、その後リーマンが名付けた特殊関数の一つで、</p>\[\zeta(s) := \sum_{n=1}^{\infty} \frac{1}{n^s} \qquad (s&gt;1)\]<p>と定義されます。</p><p>この記事のテーマからやや外れるうえ、正直に言って私は工学部生であって数学者ではないので私もよく知らないため、ここでは扱いませんが、レオンハルト・オイラーは<strong>オイラー積(Euler Product)</strong>という素数(prime number)の無限積の形でもゼータ関数を表現できることを示し、その後ゼータ関数は解析的整数論の下位の様々な分野で中心的な位置を占めています。ゼータ関数の定義域を複素数に拡張した<strong>リーマンゼータ関数(Riemann zeta function)</strong>とそれに関する重要な未解決問題である<strong>リーマン予想(Riemann hypothesis)</strong>もその一つです。</p><p>元のテーマに戻って、$p$-級数判定法の証明には後述する<a href="#比較判定法">比較判定法</a>と<a href="#積分判定法">積分判定法</a>が必要です。しかし、$p$-級数の収束/発散は等比級数とともにすぐ後で扱う<a href="#比較判定法">比較判定法</a>で有用に使えるため、意図的に前の方に配置しました。</p><h3 id="証明-1">証明</h3><h4 id="i-p1のとき">i) $p&gt;1$のとき</h4><p>積分</p>\[\int_1^\infty \frac{1}{x^p}\ dx = \left[\frac{1}{-p+1}\frac{1}{x^{p-1}} \right]^\infty_1 = \frac{1}{p-1}\]<p>が収束するため、<a href="#積分判定法">積分判定法</a>により級数 $\sum \cfrac{1}{n^p}$も収束することがわかります。</p><h4 id="ii-pleq-1のとき">ii) $p\leq 1$のとき</h4><p>この場合</p>\[0 \leq \frac{1}{n} \leq \frac{1}{n^p}\]<p>です。ここで調和級数 $\sum \cfrac{1}{n}$は発散することがわかっているので、<a href="#比較判定法">比較判定法</a>により $\sum \cfrac{1}{n^p}$ も発散することがわかります。</p><h4 id="結論">結論</h4><p>i)、ii)により、$p$-級数 $\sum \cfrac{1}{n^p}$は $p&gt;1$なら収束、$p \leq 1$なら発散します。$\blacksquare$</p><h2 id="比較判定法">比較判定法</h2><p>一般項が $0$ 以上の実数からなる級数である<strong>正項級数(series of positive terms)</strong>の収束/発散を判定するときは、ヤコブ・ベルヌーイ(Jakob Bernoulli)の<strong>比較判定法(Comparison Test)</strong>が有用です。</p><p>正項級数 $\sum a_n$は増加する数列であるため、無限大に発散する場合($\sum a_n = \infty$)でなければ必ず収束します。したがって正項級数において</p>\[\sum a_n &lt; \infty\]<p>という表現は<u>収束する</u>という意味です。</p><blockquote class="prompt-info"><p><strong>比較判定法(Comparison Test)</strong><br /> $0 \leq a_n \leq b_n$のとき、</p><ul><li>$\sum b_n &lt; \infty \ \Rightarrow \ \sum a_n &lt; \infty$<li>$\sum a_n = \infty \ \Rightarrow \ \sum b_n = \infty$</ul></blockquote><p>特に、正項級数の中でも $\sum \cfrac{1}{n^2 + n}$、$\sum \cfrac{\log n}{n^3}$、$\sum \cfrac{1}{2^n + 3^n}$、$\sum \cfrac{1}{\sqrt{n}}$、$\sum \sin{\cfrac{1}{n}}$ などのように、先に見た等比級数 $\sum ar^{n-1}$や $p$-級数 $\sum \cfrac{1}{n^p}$と類似した形を持つ級数の収束/発散を判定するときは、比較判定法を積極的に試してみるとよいでしょう。</p><p>後述する他の様々な収束/発散判定法はすべてこの<strong>比較判定法</strong>から導くことができ、その意味で比較判定法が最も重要だと言えます。</p><h3 id="極限比較判定法">極限比較判定法</h3><p>正項級数 $\sum a_n$と $\sum b_n$に対して、二つの級数の一般項の比 $a_n/b_n$で分子と分母の優勢な項(dominant term)が相殺されて $\lim_{n\to\infty} \cfrac{a_n}{b_n}=c \text{ (}c\text{は有限な正数)}$とします。このとき級数 $\sum b_n$の収束/発散がわかっていれば、次の<strong>極限比較判定法(Limit Comparison Test)</strong>を活用できます。</p><blockquote class="prompt-info"><p><strong>極限比較判定法(Limit Comparison Test)</strong><br /> もし</p>\[\lim_{n\to\infty} \frac{a_n}{b_n} = c \text{ (}c\text{は有限な正数)}\]<p>ならば、二つの級数 $\sum a_n$と $\sum b_n$は両方とも収束するか両方とも発散する。つまり、$ \sum a_n &lt; \infty \ \Leftrightarrow \ \sum b_n &lt; \infty$である。</p></blockquote><h2 id="冪根判定法">冪根判定法</h2><blockquote class="prompt-info"><p><strong>定理</strong><br /> 正項級数 $\sum a_n$と正数 $\epsilon &lt; 1$に対して</p><ul><li>すべての $n$に対して $\sqrt[n]{a_n}&lt; 1-\epsilon$ならば級数 $\sum a_n$は収束<li>すべての $n$に対して $\sqrt[n]{a_n}&gt; 1+\epsilon$ならば級数 $\sum a_n$は発散</ul></blockquote><blockquote class="prompt-info"><p><strong>系：冪根判定法(Root Test)</strong><br /> 正項級数 $\sum a_n$において極限値</p>\[\lim_{n\to\infty} \sqrt[n]{a_n} =: r\]<p>が存在するとする。このとき</p><ul><li>$r&lt;1$ならば級数 $\sum a_n$は収束<li>$r&gt;1$ならば級数 $\sum a_n$は発散</ul></blockquote><blockquote class="prompt-warning"><p>上記の系で $r=1$の場合は収束/発散を判定できないため、他の方法を使用する必要があります。</p></blockquote><h2 id="比判定法">比判定法</h2><blockquote class="prompt-info"><p><strong>比判定法(Ratio Test)</strong><br /> 正数の数列 $(a_n)$と $0 &lt; r &lt; 1$に対して</p><ul><li>すべての $n$に対して $a_{n+1}/a_n \leq r$ならば、級数 $\sum a_n$は収束<li>すべての $n$に対して $a_{n+1}/a_n \geq 1$ならば、級数 $\sum a_n$は発散</ul></blockquote><blockquote class="prompt-info"><p><strong>系</strong><br /> 正数の数列 $(a_n)$において極限値 $\rho := \lim_{n\to\infty} \cfrac{a_{n+1}}{a_n}$が存在するとする。このとき</p><ul><li>$\rho &lt; 1$ならば級数 $\sum a_n$は収束<li>$\rho &gt; 1$ならば級数 $\sum a_n$は発散</ul></blockquote><h2 id="積分判定法">積分判定法</h2><p>積分法を用いると、減少する正の数列からなる級数の収束/発散を判定できます。</p><blockquote class="prompt-info"><p><strong>積分判定法(Integral Test)</strong><br /> 連続関数 $f: \left[1,\infty \right) \rightarrow \mathbb{R}$が減少関数であり常に $f(x)&gt;0$のとき、級数 $\sum f(n)$が収束する必要十分条件は積分</p>\[\int_1^\infty f(x)\ dx := \lim_{b\to\infty} \int_1^b f(x)\ dx\]<p>が収束することである。</p></blockquote><h3 id="証明-2">証明</h3><p>関数 $f(x)$が連続で減少関数であり、符号は常に正であるため、不等式</p>\[f(n+1) \leq \int_n^{n+1} f(x)\ dx \leq f(n)\]<p>が成り立ちます。この不等式を $n=1$から一般項まで辺々足すと不等式</p>\[f(2) + \cdots + f(n+1) \leq \int_1^{n+1} f(x)\ dx \leq f(1) + \cdots + f(n)\]<p>を得ます。ここで<a href="#比較判定法">比較判定法</a>を使うと望む結果が得られます。$\blacksquare$</p><h2 id="交代級数">交代級数</h2><p>一般項が $0$でなく、各項 $a_n$の符号がその次の項 $a_{n+1}$の符号と異なる、つまり正項と負項が交互に現れる級数 $\sum a_n$を<strong>交代級数(alternating series)</strong>と呼びます。</p><p>交代級数について、ドイツの数学者ゴットフリート・ヴィルヘルム・ライプニッツ(Gottfried Wilhelm Leibniz)が発見した次の定理を収束/発散判定に有用に活用できます。</p><blockquote class="prompt-info"><p><strong>交代級数判定法(Alternating Series Test)</strong></p><ol><li>すべての $n$に対して $a_n$と $a_{n+1}$の符号が異なり、<li>すべての $n$に対して $|a_n| \geq |a_{n+1}|$であり、<li>$\lim_{n\to\infty} a_n = 0$ならば、</ol><p>交代級数 $\sum a_n$は収束する。</p></blockquote><h2 id="絶対収束級数">絶対収束級数</h2><p>級数 $\sum a_n$に対して級数 $\sum |a_n|$が収束するとき、「級数 $\sum a_n$は<strong>絶対収束</strong>する(<strong>converge absolutely</strong>)」と言います。</p><p>このとき次の定理が成り立ちます。</p><blockquote class="prompt-info"><p><strong>定理</strong><br /> 絶対収束する級数は収束する。</p></blockquote><blockquote class="prompt-warning"><p>上記定理の逆は成り立ちません。<br /> 級数が収束するが絶対収束しない場合、「<strong>条件収束</strong>する(<strong>converge conditionally</strong>)」と言います。</p></blockquote><h3 id="証明-3">証明</h3><p>実数 $a$に対して</p>\[\begin{align*} a^+ &amp;:= \max\{a,0\} = \frac{1}{2}(|a| + a), \\ a^- &amp;:= -\min\{a,0\} = \frac{1}{2}(|a| - a) \end{align*}\]<p>とおくと、</p>\[a = a^+ - a^-, \qquad |a| = a^+ + a^-\]<p>を得ます。すると $0 \leq a^\pm \leq |a|$であるため、<a href="#比較判定法">比較判定法</a>により級数 $\sum |a_n|$が収束する場合、級数 $\sum a_n^+$と $\sum a_n^-$もともに収束し、したがって<a href="/ja/posts/sequences-and-series/#収束する級数の基本的性質">収束する級数の基本的性質</a>により</p>\[\sum a_n = \sum (a_n^+ - a_n^-) = \sum a_n^+ - \sum a_n^-\]<p>も収束します。$\blacksquare$</p>]]> </content> </entry> <entry><title xml:lang="ja">数列と級数</title><link href="https://www.yunseo.kim/ja/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/sequences-and-series/" rel="alternate" type="text/html" hreflang="am" /><published>2025-03-16T00:00:00+09:00</published> <updated>2025-05-13T16:24:07+09:00</updated> <id>https://www.yunseo.kim/ja/posts/sequences-and-series/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Calculus" /> <summary xml:lang="ja">数列と級数の定義、数列の収束と発散、級数の収束と発散、自然対数の底eの定義など、微積分学の基礎概念を見ていきます。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>数列と級数の定義、数列の収束と発散、級数の収束と発散、自然対数の底eの定義など、微積分学の基礎概念を見ていきます。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="数列">数列</h2><p>微積分学で扱う<strong>数列（sequence）</strong>は主に無限数列を指します。つまり、数列とは<strong>自然数（natural number）</strong>の全体集合</p>\[\mathbb{N} := \{1,2,3,\dots\}\]<p>で定義された関数です。* この関数の値が実数（real number）であれば「実数列」、複素数（complex number）であれば「複素数列」、点（point）であれば「点列」、行列（matrix）であれば「行列列」、関数（function）であれば「関数列」、集合（set）であれば「集合列」などと呼ぶことができますが、これらすべてを簡単に「列」または「数列」と呼ぶことができます。</p><p>通常、<strong>実数体（the field of real numbers）</strong> $\mathbb{R}$に対して、数列 $\mathbf{a}: \mathbb{N} \to \mathbb{R}$で</p>\[a_1 := \mathbf{a}(1), \quad a_2 := \mathbf{a}(2), \quad a_3 := \mathbf{a}(3)\]<p>などとし、この数列を</p>\[a_1,\, a_2,\, a_3,\, \dots\]<p>または</p>\[\begin{gather*} (a_1,a_2,a_3,\dots), \\ (a_n: n=1,2,3,\dots), \\ (a_n)_{n=1}^{\infty}, \qquad (a_n) \end{gather*}\]<p>などと表します。</p><blockquote class="prompt-info"><p>*数列を定義する過程で、定義域を自然数全体集合 $\mathbb{N}$ の代わりに $0$ 以上の整数の集合</p>\[\mathbb{N}_0 := \{0\} \cup \mathbb{N} = \{0,1,2,\dots\}\]<p>または</p>\[\{2,3,4,\dots \}\]<p>などとすることもあります。例えば、べき級数理論を扱う際には、定義域が $\mathbb{N}_0$ の方がより自然です。</p></blockquote><h2 id="収束と発散">収束と発散</h2><p>数列 $(a_n)$ が実数 $l$ に収束するとき</p>\[\lim_{n\to \infty} a_n = l\]<p>と書き、このとき $l$ を数列 $(a_n)$ の<strong>極限値</strong>と呼びます。</p><blockquote class="prompt-info"><p><strong>イプシロン-デルタ論法（epsilon-delta argument）</strong>を用いた厳密な定義は次のとおりです。</p>\[\lim_{n\to \infty} a_n = l \overset{def}\Longleftrightarrow \forall \epsilon &gt; 0,\, \exists N \in \mathbb{N}\ (n &gt; N \Rightarrow |a_n - l| &lt; \epsilon)\]<p>つまり、どんなに小さな正数 $\epsilon$ に対しても $n&gt;N$ のとき $|a_n - l | &lt; \epsilon$ を満たす自然数 $N$ が常に存在するならば、十分大きな $n$ に対して $a_n$ と $l$ の差が限りなく小さくなるという意味なので、これを満たす数列 $(a_n)$ は実数 $l$ に収束すると定義します。</p></blockquote><p>収束しない数列は<strong>発散</strong>すると言います。<em>数列の収束または発散の可否は、その数列の有限個の項が変わっても変わりません。</em></p><p>もし数列 $(a_n)$ の各項が限りなく大きくなれば</p>\[\lim_{n\to \infty} a_n = \infty\]<p>と書き、<em>正の無限大に発散する</em>と言います。同様に、数列 $(a_n)$ の各項が限りなく小さくなれば</p>\[\lim_{n\to \infty} a_n = -\infty\]<p>と書き、<em>負の無限大に発散する</em>と言います。</p><h2 id="収束する数列の基本的性質">収束する数列の基本的性質</h2><p>数列 $(a_n)$ と $(b_n)$ がともに収束すれば（つまり極限値を持てば）、数列 $(a_n + b_n)$ と $(a_n \cdot b_n)$ も同様に収束し、このとき</p>\[\lim_{n\to \infty} (a_n + b_n) = \lim_{n\to \infty} a_n + \lim_{n\to \infty} b_n \label{eqn:props_of_conv_series_1}\tag{1}\] \[\lim_{n\to \infty} (a_n \cdot b_n) = \left(\lim_{n\to \infty} a_n \right) \cdot \left(\lim_{n\to \infty} b_n \right) \label{eqn:props_of_conv_series_2}\tag{2}\]<p>となります。また、任意の実数 $t$ に対して</p>\[\lim_{n\to \infty} (t a_n) = t\left(\lim_{n\to \infty} a_n \right) \label{eqn:props_of_conv_series_3}\tag{3}\]<p>となります。これらの性質を<strong>収束する数列の基本的性質</strong>または<strong>極限の基本的性質</strong>と呼びます。</p><h2 id="自然対数の底-e">自然対数の底 $e$</h2><p><strong>自然対数の底</strong>は</p>\[e := \lim_{n\to \infty} \left(1+\frac{1}{n} \right)^n \approx 2.718\]<p>と定義されます。これは数学で最も重要な定数の一つと言えます。</p><blockquote class="prompt-tip"><p>韓国でのみ特に「自然定数」という表現がかなり広く使われていますが、これは標準的な用語ではありません。韓国数学会が数学用語集に登録した公式用語は<a href="https://www.kms.or.kr/mathdict/list.html?key=kname&amp;keyword=%EC%9E%90%EC%97%B0%EB%A1%9C%EA%B7%B8%EC%9D%98+%EB%B0%91">‘自然対数の底’</a>であり、「自然定数」という表現はその用語集では見つかりません。さらに、国立国語院標準国語大辞典でも「自然定数」という単語は見つからず、<a href="https://stdict.korean.go.kr/search/searchView.do?pageSize=10&amp;searchKeyword=%EC%9E%90%EC%97%B0%EB%A1%9C%EA%B7%B8">‘自然対数’に関する辞書の説明</a>で「よくeで表される特定の数」としか言及されていません。<br /> 英語圏や日本でもこれに対応する用語は存在せず、英語基準では’the base of the natural logarithm’や略して’natural base’、あるいは’Euler’s number’や’the number $e$’程度で主に呼ばれているようです。<br /> 出所も不明で韓国数学会が公式用語として認めたこともないだけでなく、韓国を除けば世界中のどこでも使われていないこのような用語を固執する理由は全くないので、これからはここでも私も「自然対数の底」と呼ぶか、単に $e$ と表記することにします。</p></blockquote><h2 id="級数">級数</h2><p>数列</p>\[\mathbf{a} = (a_1, a_2, a_3, \dots)\]<p>に対して、この数列の部分和からなる別の数列</p>\[a_1, \quad a_1 + a_2, \quad a_1 + a_2 + a_3, \quad \dots\]<p>を数列 $\mathbf{a}$ の<strong>級数</strong>と呼びます。数列 $(a_n)$ の級数は</p>\[\begin{gather*} a_1 + a_2 + a_3 + \cdots, \qquad \sum_{n=1}^{\infty}a_n, \\ \sum_{n\geq 1} a_n, \qquad \sum_n a_n, \qquad \sum a_n \end{gather*}\]<p>などと表します。</p><h2 id="級数の収束と発散">級数の収束と発散</h2><p>数列 $(a_n)$ から得られる級数</p>\[a_1, \quad a_1 + a_2, \quad a_1 + a_2 + a_3, \quad \dots\]<p>がある実数 $l$ に収束すれば</p>\[\sum_{n=1}^{\infty} a_n = l\]<p>と表します。このとき極限値 $l$ を級数 $\sum a_n$ の<strong>和</strong>と呼びます。記号</p>\[\sum a_n\]<p>は状況に応じて<u>級数</u>を表したり、その<u>級数の和</u>を表したりします。</p><p>収束しない級数は<strong>発散</strong>すると言います。</p><h2 id="収束する級数の基本的性質">収束する級数の基本的性質</h2><p><a href="#収束する数列の基本的性質">収束する数列の基本的性質</a>から、次のように収束する級数の基本的性質が得られます。実数 $t$ と収束する二つの級数 $\sum a_n$、$\sum b_n$ に対して</p>\[\sum(a_n + b_n) = \sum a_n + \sum b_n, \qquad \sum ta_n = t\sum a_n \tag{4}\]<p>が成り立ちます。</p><p>級数の収束性は有限個の項の変化に影響を受けません。つまり、二つの数列 $(a_n)$、$(b_n)$ で有限個の $n$ を除いて $a_n=b_n$ であれば、級数 $\sum a_n$ が収束する必要十分条件は級数 $\sum b_n$ が収束することです。</p>]]> </content> </entry> <entry><title xml:lang="ja">ニュートンの運動法則</title><link href="https://www.yunseo.kim/ja/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/newtons-laws-of-motion/" rel="alternate" type="text/html" hreflang="am" /><published>2025-03-10T00:00:00+09:00</published> <updated>2026-02-16T05:09:10+09:00</updated> <id>https://www.yunseo.kim/ja/posts/newtons-laws-of-motion/</id> <author> <name>Yunseo Kim</name> </author> <category term="Physics" /> <category term="Classical Dynamics" /> <summary xml:lang="ja">ニュートンの運動法則とその3つの法則が持つ意味、そして慣性質量と重力質量の定義について学び、古典力学だけでなく後の一般相対性理論でも重要な意味を持つ等価原理を考察する。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>ニュートンの運動法則とその3つの法則が持つ意味、そして慣性質量と重力質量の定義について学び、古典力学だけでなく後の一般相対性理論でも重要な意味を持つ等価原理を考察する。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><p><strong>ニュートンの運動法則（Newton’s laws of motion）</strong></p><ol><li>外部から力が作用しない限り、物体は静止または等速直線運動を続ける。<li>物体の運動量の時間的変化率はその物体が受けた力に等しい。<ul><li>$\vec{F} = \cfrac{d\vec{p}}{dt} = \cfrac{d}{dt}(m\vec{v}) = m\vec{a}$</ul><li>二つの物体が互いに力を及ぼす時、この二つの力は大きさが等しく方向が反対である。<ul><li>$\vec{F_1} = -\vec{F_2}$</ul></ol></blockquote><blockquote class="prompt-info"><p><strong>等価原理（principle of equivalence）</strong></p><ul><li>慣性質量：与えられた力が作用した場合に物体の加速度を決定する質量<li>重力質量：ある物体と他の物体の間に作用する重力を決定する質量<li>現在、慣性質量と重力質量は$10^{-12}$程度の誤差範囲で明らかに一致していることが知られている<li>慣性質量と重力質量は正確に同じであるという主張を<strong>等価原理</strong>という</ul></blockquote><h2 id="ニュートンの運動法則">ニュートンの運動法則</h2><p>ニュートンの運動法則はアイザック・ニュートン（Issac Newton）が<a href="https://en.wikipedia.org/wiki/Holocene_calendar">人類紀元</a>11687年に著書Philosophiæ Naturalis Principia Mathematica（自然哲学の数学的原理、略称「プリンキピア」）を通じて発表した3つの法則で、ニュートン力学（Newtonian mechanics）の基礎を成している。</p><ol><li>外部から力が作用しない限り、物体は静止または等速直線運動を続ける。<li>物体の運動量の時間的変化率はその物体が受けた力に等しい。<li>二つの物体が互いに力を及ぼす時、この二つの力は大きさが等しく方向が反対である。</ol><h3 id="ニュートンの第1法則">ニュートンの第1法則</h3><blockquote><p>I. 外部から力が作用しない限り、物体は静止または等速直線運動を続ける。</p></blockquote><p>このように外部から力が作用していない状態の物体を<strong>自由物体（free body）</strong>または<strong>自由粒子（free particle）</strong>という。 ただし、第1法則単独では力に関する定性的な概念しか与えない。</p><h3 id="ニュートンの第2法則">ニュートンの第2法則</h3><blockquote><p>II. 物体の運動量の時間的変化率はその物体が受けた力に等しい。</p></blockquote><p>ニュートンは<strong>運動量（momentum）</strong>を質量と速度の積</p>\[\vec{p} \equiv m\vec{v} \label{eqn:momentum}\tag{1}\]<p>と定義した。これからニュートンの第2法則は次のように表現できる。</p>\[\vec{F} = \frac{d\vec{p}}{dt} = \frac{d}{dt}(m\vec{v}) = m\vec{a}. \label{eqn:2nd_law}\tag{2}\]<p>ニュートンの第1法則と第2法則は、名前とは異なり実際には「法則」というよりむしろ力に関する「定義」に近い。また力の定義は「質量」の定義に依存していることがわかる。</p><h3 id="ニュートンの第3法則">ニュートンの第3法則</h3><blockquote><p>III. 二つの物体が互いに力を及ぼす時、この二つの力は大きさが等しく方向が反対である。</p></blockquote><p>「作用・反作用の法則」としても知られる物理法則であり、ある物体が別の物体に及ぼす力が二つの作用点を結ぶ直線の方向を向いている場合に適用される。このような力を<strong>中心力（central force）</strong>といい、第3法則は中心力が引力であれ斥力であれ関係なく成立する。静止した二つの物体間の重力または静電気力、そして弾性力などがこのような中心力に該当する。一方、動いている電荷間の力、動いている物体間の重力など相互作用する二つの物体の速度に依存する力は非中心力に属し、このような場合第3法則は適用できない。</p><p>先に見た質量の定義を反映すると、第3法則を次のように言い換えることができる。</p><blockquote><p>III$^\prime$. 二つの物体が理想的な孤立系を構成する場合、この二つの物体の加速度は方向が反対であり、その大きさの比は二つの物体の質量の逆比に等しい。</p></blockquote><p>ニュートンの第3法則により</p>\[\vec{F_1} = -\vec{F_2} \label{eqn:3rd_law}\tag{3}\]<p>であり、ここに先に見た第2法則（$\ref{eqn:2nd_law}$）を代入すると</p>\[\frac{d\vec{p_1}}{dt} = -\frac{d\vec{p_2}}{dt} \label{eqn:3rd-1_law}\tag{4}\]<p>となる。これから二つの粒子の孤立した相互作用において運動量は保存されることがわかる。</p>\[\frac{d}{dt}(\vec{p_1}+\vec{p_2}) = 0 \label{eqn:conservation_of_momentum}\tag{5}\]<p>また式（$\ref{eqn:3rd-1_law}$）において$\vec{p}=m\vec{v}$であり質量$m$は定数であるため、</p>\[m_1\left(\frac{d\vec{v_1}}{dt} \right) = m_2\left(-\frac{d\vec{v_2}}{dt} \right) \tag{6a}\] \[m_1(\vec{a_1}) = m_2(-\vec{a_2}) \tag{6b}\]<p>となり、次を得る。</p>\[\frac{m_2}{m_1} = -\frac{a_1}{a_2}. \tag{7}\]<p>しかしニュートンの第3法則は二つの物体が孤立系を構成する場合について述べているが、実際にはそのような理想的な条件を実現することは不可能であるため、第3法則におけるニュートンの主張はある意味では相当大胆だったとも言える。このように限られた観察から得られた結論にもかかわらず、ニュートンの深い物理的洞察力のおかげでニュートン力学はほぼ300年間、様々な実験による検証で誤りが発見されることなく確固たる地位を占め、11900年代に入ってようやくニュートン理論の予測と実際との差を示せるほどの精密な測定が可能になり、これから相対性理論と量子力学が生まれた。</p><h2 id="慣性質量と重力質量">慣性質量と重力質量</h2><p>物体の質量を決定する方法の一つは、天秤のような道具を使用して当該物体の重さを標準重量と比較することである。この方法は重力場における物体の重さがその物体に作用する重力の大きさに等しいという事実を利用するもので、この場合第2法則$\vec{F}=m\vec{a}$は$\vec{W}=m\vec{g}$の形になる。この方法はIII$^\prime$で定義する質量$m$が重力方程式に現れる質量$m$と同じであるという基本仮定に基づいている。これら二つの質量をそれぞれ<strong>慣性質量（inertial mass）</strong>と<strong>重力質量（gravitational mass）</strong>と呼び、次のように定義する。</p><ul><li>慣性質量：与えられた力が作用した場合に物体の加速度を決定する質量<li>重力質量：ある物体と他の物体の間に作用する重力を決定する質量</ul><p>ガリレオ・ガリレイ（Galileo Galilei）とは無関係な後世に作られた話ではあるが、ピサの斜塔落下実験は最初に慣性質量と重力質量が同じであることを示した思考実験である。ニュートンもまた長さが同じで錘の質量が異なる振り子の周期を測定し、二つの質量の間に差がないことを示そうとしたが、実験方法と精度は粗雑なレベルであったため、正確な証明には失敗した。</p><p>その後11800年代末、ハンガリーの物理学者エトヴェシュ・ロラーンド・アーゴシュトン（Eötvös Loránd Ágoston）が慣性質量と重力質量の間の差を正確に測定するためのエトヴェシュ実験を行い、慣性質量と重力質量が同一であることをかなりの精度（2000万分の1以内の誤差）で証明した。</p><p>その後、ロバート・ヘンリー・ディッケ（Robert Henry Dicke）らが行ったさらに最近の実験では精度がさらに向上し、現在、慣性質量と重力質量は$10^{-12}$程度の誤差範囲で明らかに一致していることが知られている。この結果は一般相対性理論において非常に重要な意味を持ち、慣性質量と重力質量が正確に同じであるという主張を<strong>等価原理（principle of equivalence）</strong>という。</p>]]> </content> </entry> <entry><title xml:lang="ja">定数係数を持つ2階同次線形常微分方程式</title><link href="https://www.yunseo.kim/ja/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/homogeneous-linear-odes-with-constant-coefficients/" rel="alternate" type="text/html" hreflang="am" /><published>2025-02-22T00:00:00+09:00</published> <updated>2025-07-11T21:22:11+09:00</updated> <id>https://www.yunseo.kim/ja/posts/homogeneous-linear-odes-with-constant-coefficients/</id> <author> <name>Yunseo Kim</name> </author> <category term="Mathematics" /> <category term="Differential Equation" /> <summary xml:lang="ja">特性方程式の判別式の符号によって、それぞれの場合に定数係数同次線形常微分方程式の一般解がどのような形になるかを考察する。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>特性方程式の判別式の符号によって、それぞれの場合に定数係数同次線形常微分方程式の一般解がどのような形になるかを考察する。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="tldr">TL;DR</h2><blockquote class="prompt-info"><ul><li>定数係数を持つ2階同次線形常微分方程式: $y^{\prime\prime} + ay^{\prime} + by = 0$<li><strong>特性方程式(characteristic equation)</strong>: $\lambda^2 + a\lambda + b = 0$<li>特性方程式の判別式 $a^2 - 4b$の符号によって一般解の形を表のように三つの場合に分けることができる</ul><table><thead><tr><th style="text-align: center">場合<th style="text-align: center">特性方程式の解<th style="text-align: center">常微分方程式の解の基底<th style="text-align: center">常微分方程式の一般解<tbody><tr><td style="text-align: center">I<td style="text-align: center">異なる実根<br />$\lambda_1$, $\lambda_2$<td style="text-align: center">$e^{\lambda_1 x}$, $e^{\lambda_2 x}$<td style="text-align: center">$y = c_1e^{\lambda_1 x} + c_2e^{\lambda_2 x}$<tr><td style="text-align: center">II<td style="text-align: center">実重根<br /> $\lambda = -\cfrac{1}{2}a$<td style="text-align: center">$e^{-ax/2}$, $xe^{-ax/2}$<td style="text-align: center">$y = (c_1 + c_2 x)e^{-ax/2}$<tr><td style="text-align: center">III<td style="text-align: center">共役複素根<br /> $\lambda_1 = -\cfrac{1}{2}a + i\omega$, <br /> $\lambda_2 = -\cfrac{1}{2}a - i\omega$<td style="text-align: center">$e^{-ax/2}\cos{\omega x}$, <br /> $e^{-ax/2}\sin{\omega x}$<td style="text-align: center">$y = e^{-ax/2}(A\cos{\omega x} + B\sin{\omega x})$</table></blockquote><h2 id="prerequisites">Prerequisites</h2><ul><li><a href="/ja/posts/Bernoulli-Equation/">ベルヌーイ方程式(Bernoulli Equation)</a><li><a href="/ja/posts/homogeneous-linear-odes-of-second-order/">2階同次線形常微分方程式 (Homogeneous Linear ODEs of Second Order)</a><li>オイラーの公式</ul><h2 id="特性方程式-characteristic-equation">特性方程式 (characteristic equation)</h2><p>係数 $a$と $b$が定数である2階同次線形常微分方程式</p>\[y^{\prime\prime} + ay^{\prime} + by = 0 \label{eqn:ode_with_constant_coefficients}\tag{1}\]<p>を考えよう。この形の方程式は機械的、電気的振動において重要な応用がある。</p><p>先に<a href="/ja/posts/Bernoulli-Equation/">ベルヌーイ方程式(Bernoulli Equation)</a>でロジスティック方程式の一般解を求めたが、それによると定数係数 $k$を持つ1階線形常微分方程式</p>\[y^\prime + ky = 0\]<p>の解は指数関数 $y = ce^{-kx}$である。（その記事の式(4)で $A=-k$, $B=0$の場合）</p><p>したがって、同様の形の方程式である($\ref{eqn:ode_with_constant_coefficients}$)に対しても</p>\[y=e^{\lambda x}\label{eqn:general_sol}\tag{2}\]<p>形の解をまず試してみることができる。</p><blockquote class="prompt-info"><p>もちろんこれはあくまで推測に過ぎず、実際に一般解がこのような形であるという保証は全くない。しかし何であれ線形独立な二つの解さえ求めることができれば、<a href="/ja/posts/homogeneous-linear-odes-of-second-order/#基底と一般解">2階同次線形常微分方程式</a>で見たように<a href="/ja/posts/homogeneous-linear-odes-of-second-order/#重ね合わせの原理">重ね合わせの原理</a>によって一般解を求めることができる。<br /> 後で見るように、<a href="#ii-実重根-lambda---cfraca2">別の形の解を求める必要がある場合</a>もある。</p></blockquote><p>式($\ref{eqn:general_sol}$)とその導関数</p>\[y^\prime = \lambda e^{\lambda x}, \quad y^{\prime\prime} = \lambda^2 e^{\lambda x}\]<p>を式($\ref{eqn:ode_with_constant_coefficients}$)に代入すると</p>\[(\lambda^2 + a\lambda + b)e^{\lambda x} = 0\]<p>を得る。したがって、もし $\lambda$が<strong>特性方程式(characteristic equation)</strong></p>\[\lambda^2 + a\lambda + b = 0 \label{eqn:characteristic_eqn}\tag{3}\]<p>の解であれば、指数関数($\ref{eqn:general_sol}$)は常微分方程式($\ref{eqn:ode_with_constant_coefficients}$)の解である。二次方程式($\ref{eqn:characteristic_eqn}$)の解を求めると</p>\[\begin{align*} \lambda_1 &amp;= \frac{1}{2}\left(-a + \sqrt{a^2 - 4b}\right), \\ \lambda_2 &amp;= \frac{1}{2}\left(-a - \sqrt{a^2 - 4b}\right) \end{align*}\label{eqn:lambdas}\tag{4}\]<p>となり、これから二つの関数</p>\[y_1 = e^{\lambda_1 x}, \quad y_2 = e^{\lambda_2 x} \tag{5}\]<p>が方程式($\ref{eqn:ode_with_constant_coefficients}$)の解となる。</p><blockquote class="prompt-tip"><p><strong>特性方程式(characteristic equation)</strong>と<strong>補助方程式(auxiliary equation)</strong>という二つの用語がよく混用されるが、両者は全く同じ意味である。どちらで呼んでも構わない。</p></blockquote><p>ここで、特性方程式($\ref{eqn:characteristic_eqn}$)の判別式 $a^2 - 4b$の符号によって場合を三つに分けることができる。</p><ul><li>$a^2 - 4b &gt; 0$: 異なる二つの実根<li>$a^2 - 4b = 0$: 実重根<li>$a^2 - 4b &lt; 0$: 共役複素根</ul><h2 id="特性方程式の判別式の符号による一般解の形">特性方程式の判別式の符号による一般解の形</h2><h3 id="i-異なる二つの実根-lambda_1と-lambda_2">I. 異なる二つの実根 $\lambda_1$と $\lambda_2$</h3><p>この場合、任意の区間で方程式($\ref{eqn:ode_with_constant_coefficients}$)の解の基底は</p>\[y_1 = e^{\lambda_1 x}, \quad y_2 = e^{\lambda_2 x}\]<p>であり、これに対応する一般解は</p>\[y = c_1 e^{\lambda_1 x} + c_2 e^{\lambda_2 x} \label{eqn:general_sol_1}\tag{6}\]<p>である。</p><h3 id="ii-実重根-lambda---cfraca2">II. 実重根 $\lambda = -\cfrac{a}{2}$</h3><p>$a^2 - 4b = 0$の場合、二次方程式($\ref{eqn:characteristic_eqn}$)は一つの解 $\lambda = \lambda_1 = \lambda_2 = -\cfrac{a}{2}$しか得られず、したがってこれから得られる $y = e^{\lambda x}$ 形の解は</p>\[y_1 = e^{-(a/2)x}\]<p>の一つだけである。基底を得るためには $y_1$と独立した別の形の二番目の解 $y_2$を見つける必要がある。</p><p>このような状況で活用できるのが、先に学んだ<a href="/ja/posts/homogeneous-linear-odes-of-second-order/#次数低下法-reduction-of-order">次数低下法</a>である。求めたい二番目の解を $y_2=uy_1$とおき、</p>\[\begin{align*} y_2 &amp;= uy_1, \\ y_2^{\prime} &amp;= u^{\prime}y_1 + uy_1^{\prime}, \\ y_2^{\prime\prime} &amp;= u^{\prime\prime}y_1 + 2u^{\prime}y_1^{\prime} + uy_1^{\prime\prime} \end{align*}\]<p>を方程式($\ref{eqn:ode_with_constant_coefficients}$)に代入すると</p>\[(u^{\prime\prime}y_1 + 2u^\prime y_1^\prime + uy_1^{\prime\prime}) + a(u^\prime y_1 + uy_1^\prime) + buy_1 = 0\]<p>を得る。$u^{\prime\prime}$, $u^\prime$, $u$ の各項ごとにまとめて整理すると</p>\[y_1u^{\prime\prime} + (2y_1^\prime + ay_1)u^\prime + (y_1^{\prime\prime} + ay_1^\prime + by_1)u = 0\]<p>となる。ここで $y_1$が方程式($\ref{eqn:ode_with_constant_coefficients}$)の解であるため、最後の括弧内の式は $0$であり、</p>\[2y_1^\prime = -ae^{-ax/2} = -ay_1\]<p>なので最初の括弧内の式も $0$である。したがって $u^{\prime\prime}y_1 = 0$だけが残り、これから $u^{\prime\prime}=0$となる。二回積分すると $u = c_1x + c_2$となり、積分定数 $c_1$と $c_2$はどんな値でもよいので、単純に $c_1=1$, $c_2=0$を選んで $u=x$とすることができる。すると $y_2 = uy_1 = xy_1$となり、$y_1$と $y_2$は線形独立なのでこの二つは基底を形成する。したがって特性方程式($\ref{eqn:characteristic_eqn}$)が重根を持つ場合、任意の区間での方程式($\ref{eqn:ode_with_constant_coefficients}$)の解の基底は</p>\[e^{-ax/2}, \quad xe^{-ax/2}\]<p>であり、これに対応する一般解は</p>\[y = (c_1 + c_2x)e^{-ax/2} \label{eqn:general_sol_2}\tag{7}\]<p>である。</p><h3 id="iii-共役複素根--cfrac12a--iomegaと--cfrac12a---iomega">III. 共役複素根 $-\cfrac{1}{2}a + i\omega$と $-\cfrac{1}{2}a - i\omega$</h3><p>この場合 $a^2 - 4b &lt; 0$であり $\sqrt{-1} = i$なので、式($\ref{eqn:lambdas}$)から</p>\[\cfrac{1}{2}\sqrt{a^2 - 4b} = \cfrac{1}{2}\sqrt{-(4b - a^2)} = \sqrt{-(b-\frac{1}{4}a^2)} = i\sqrt{b - \frac{1}{4}a^2}\]<p>となり、ここで実数 $\sqrt{b-\cfrac{1}{4}a^2} = \omega$と定義しよう。</p><p>$\omega$を上のように定義すると特性方程式($\ref{eqn:characteristic_eqn}$)の解は共役複素根 $\lambda = -\cfrac{1}{2}a \pm i\omega$となり、これに対応する方程式($\ref{eqn:ode_with_constant_coefficients}$)の二つの複素解</p>\[\begin{align*} e^{\lambda_1 x} &amp;= e^{-(a/2)x + i\omega x}, \\ e^{\lambda_2 x} &amp;= e^{-(a/2)x - i\omega x} \end{align*}\]<p>を得る。ただしこの場合も虚数ではなく実数解の基底を次のように得ることができる。</p><p>オイラーの公式(Euler formula)</p>\[e^{it} = \cos t + i\sin t \label{eqn:euler_formula}\tag{8}\]<p>と、上の式で $t$ の代わりに $-t$を代入して得られる</p>\[e^{-it} = \cos t - i\sin t\]<p>の二つの式を辺ごとに足したり引いたりすると次を得る。</p>\[\begin{align*} \cos t &amp;= \frac{1}{2}(e^{it} + e^{-it}), \\ \sin t &amp;= \frac{1}{2i}(e^{it} - e^{-it}). \end{align*} \label{eqn:cos_and_sin}\tag{9}\]<p>実部 $r$と虚部 $it$を持つ複素変数 $z = r + it$の複素指数関数 $e^z$は実関数 $e^r$、$\cos t$と $\sin t$を使って次のように定義できる。</p>\[e^z = e^{r + it} = e^r e^{it} = e^r(\cos t + i\sin t) \label{eqn:complex_exp}\tag{10}\]<p>ここで $r=-\cfrac{1}{2}ax$, $t=\omega x$とおくと次のように書ける。</p>\[\begin{align*} e^{\lambda_1 x} &amp;= e^{-(a/2)x + i\omega x} = e^{-(a/2)x}(\cos{\omega x} + i\sin{\omega x}) \\ e^{\lambda_2 x} &amp;= e^{-(a/2)x - i\omega x} = e^{-(a/2)x}(\cos{\omega x} - i\sin{\omega x}) \end{align*}\]<p><a href="/ja/posts/homogeneous-linear-odes-of-second-order/#重ね合わせの原理">重ね合わせの原理</a>により、上の複素解の和と定数倍もまた解となる。したがって二つの等式を辺ごとに足して両辺に $\cfrac{1}{2}$をかけると、最初の実数解 $y_1$を次のように得ることができる。</p>\[y_1 = e^{-(a/2)x} \cos{\omega x}. \label{eqn:basis_1}\tag{11}\]<p>同様に、最初の等式から二番目の等式を辺ごとに引いて両辺に $\cfrac{1}{2i}$をかけることで、二番目の実数解 $y_2$を得ることができる。</p>\[y_2 = e^{-(a/2)x} \sin{\omega x}. \label{eqn:basis_2}\tag{12}\]<p>$\cfrac{y_1}{y_2} = \cot{\omega x}$であり、これは定数ではないので、$y_1$と $y_2$はすべての区間で線形独立であり、したがって方程式($\ref{eqn:ode_with_constant_coefficients}$)の実数解の基底をなす。これから一般解</p>\[y = e^{-ax/2}(A\cos{\omega x} + B\sin{\omega x}) \quad \text{(}A,\, B\text{は任意の定数)} \label{eqn:general_sol_3}\tag{13}\]<p>を得る。</p>]]> </content> </entry> <entry><title xml:lang="ja">PolyglotでJekyllブログの多言語対応を実現する方法 (3) - Chirpyテーマのビルド失敗と検索機能エラーのトラブルシューティング</title><link href="https://www.yunseo.kim/ja/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="en" /><link href="https://www.yunseo.kim/ko/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="ko" /><link href="https://www.yunseo.kim/ja/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="ja" /><link href="https://www.yunseo.kim/zh-TW/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="zh-TW" /><link href="https://www.yunseo.kim/es/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="es" /><link href="https://www.yunseo.kim/pt-BR/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="pt-BR" /><link href="https://www.yunseo.kim/fr/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="fr" /><link href="https://www.yunseo.kim/de/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="de" /><link href="https://www.yunseo.kim/pl/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="pl" /><link href="https://www.yunseo.kim/cs/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="cs" /><link href="https://www.yunseo.kim/sw/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="sw" /><link href="https://www.yunseo.kim/am/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/" rel="alternate" type="text/html" hreflang="am" /><published>2025-02-05T00:00:00+09:00</published> <updated>2025-10-08T00:53:56+09:00</updated> <id>https://www.yunseo.kim/ja/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-3/</id> <author> <name>Yunseo Kim</name> </author> <category term="Dev" /> <category term="Web Dev" /> <summary xml:lang="ja">&apos;jekyll-theme-chirpy&apos;ベースのJekyllブログにPolyglotプラグインを適用して多言語対応を実装した過程を紹介する。この投稿はシリーズの3番目の記事で、Chirpyテーマに Polyglot適用時に発生したエラーの原因を特定し解決する部分を扱います。</summary> <content type="html" xml:lang="ja"> <![CDATA[<p>'jekyll-theme-chirpy'ベースのJekyllブログにPolyglotプラグインを適用して多言語対応を実装した過程を紹介する。この投稿はシリーズの3番目の記事で、Chirpyテーマに Polyglot適用時に発生したエラーの原因を特定し解決する部分を扱います。</p><em><p>* Mathematical equations and diagrams included in posts may not display properly when viewed with a feed reader.</p></em><h2 id="概要">概要</h2><p>12024年7月初旬、Jekyll基盤でGitHub Pagesを通じてホスティング中の本ブログに<a href="https://github.com/untra/polyglot">Polyglot</a>プラグインを適用して多言語対応実装を追加した。 このシリーズはChirpyテーマにPolyglotプラグインを適用する過程で発生したバグとその解決過程、そしてSEOを考慮したhtmlヘッダーとsitemap.xmlの作成法を共有する。 シリーズは3つの記事で構成されており、現在読んでいるこの記事はそのシリーズの3番目の記事である。</p><ul><li>1編：<a href="/ja/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-1">Polyglotプラグインの適用 &amp; htmlヘッダー及びsitemap修正</a><li>2編：<a href="/ja/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-2">言語選択ボタンの実装 &amp; レイアウト言語のローカライゼーション</a><li>3編：Chirpyテーマビルド失敗及び検索機能エラーのトラブルシューティング（本文）</ul><blockquote class="prompt-info"><p>元々は全2編で構成していたが、その後数回にわたって内容を補強したことで分量が大幅に増加し、3編に改編した。</p></blockquote><h2 id="要求条件">要求条件</h2><ul class="task-list"><li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />ビルドした結果物（ウェブページ）を言語別パス（例：<code class="language-plaintext filepath highlighter-rouge">/posts/ko/</code>、<code class="language-plaintext filepath highlighter-rouge">/posts/ja/</code>）で区分して提供できなければならない。<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />多言語対応に追加的に要する時間と労力を可能な限り最小化するため、作成した原本マークダウンファイルのYAML front matterに’lang’及び’permalink’タグを一々指定しなくても、ビルド時に該当ファイルが位置するローカルパス（例：<code class="language-plaintext filepath highlighter-rouge">/_posts/ko/</code>、<code class="language-plaintext filepath highlighter-rouge">/_posts/ja/</code>）に応じて自動的に言語を認識できなければならない。<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />サイト内各ページのヘッダー部分は適切なContent-Languageメタタグとhreflang代替タグ、canonical linkを含んで多言語検索のためのGoogle SEOガイドラインを満たさなければならない。<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />サイト内で各言語バージョン別ページリンクを漏れなく<code class="language-plaintext filepath highlighter-rouge">sitemap.xml</code>で提供できなければならず、<code class="language-plaintext filepath highlighter-rouge">sitemap.xml</code>自体は重複なくルートパスに一つだけ存在しなければならない。<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" /><a href="https://github.com/cotes2020/jekyll-theme-chirpy">Chirpyテーマ</a>で提供するすべての機能は各言語ページで正常動作しなければならず、そうでなければ正常動作するよう修正しなければならない。<ul class="task-list"><li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />‘Recently Updated’、’Trending Tags’機能の正常動作<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />GitHub Actionsを利用したビルド過程でエラーが発生しないこと<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />ブログ右上の投稿検索機能の正常動作</ul></ul><h2 id="始める前に">始める前に</h2><p>この記事は<a href="/ja/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-1">第1回</a>と<a href="/ja/posts/how-to-support-multi-language-on-jekyll-blog-with-polyglot-2">第2回</a>からの続きですので、まだ読んでいない場合は、まず前の記事から読むことをお勧めします。</p><h2 id="トラブルシューティングrelative_url_regex-target-of-repeat-operator-is-not-specified">トラブルシューティング（’relative_url_regex’: target of repeat operator is not specified）</h2><p>（＋12025.10.08. アップデート）<a href="https://polyglot.untra.io/2025/09/20/polyglot.1.11.0/">本バグは Polyglot 1.11 バージョンで解決された</a>。</p><p>前のステップまで進めた後、<code class="language-plaintext highlighter-rouge">bundle exec jekyll serve</code>コマンドを実行してビルドテストをしたところ、<code class="language-plaintext highlighter-rouge">'relative_url_regex': target of repeat operator is not specified</code>というエラーが発生し、ビルドに失敗しました。</p><div class="language-shell highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre><td class="rouge-code"><pre>...<span class="o">(</span>前略<span class="o">)</span>
                    <span class="nt">------------------------------------------------</span>
      Jekyll 4.3.4   Please append <span class="sb">`</span><span class="nt">--trace</span><span class="sb">`</span> to the <span class="sb">`</span>serve<span class="sb">`</span> <span class="nb">command 
                     </span><span class="k">for </span>any additional information or backtrace. 
                    <span class="nt">------------------------------------------------</span>
/Users/yunseo/.gem/ruby/3.2.2/gems/jekyll-polyglot-1.8.1/lib/jekyll/polyglot/
patches/jekyll/site.rb:234:in <span class="sb">`</span>relative_url_regex<span class="s1">': target of repeat operator 
is not specified: /href="?\/((?:(?!*.gem)(?!*.gemspec)(?!tools)(?!README.md)(
?!LICENSE)(?!*.config.js)(?!rollup.config.js)(?!package*.json)(?!.sass-cache)
(?!.jekyll-cache)(?!gemfiles)(?!Gemfile)(?!Gemfile.lock)(?!node_modules)(?!ve
ndor\/bundle\/)(?!vendor\/cache\/)(?!vendor\/gems\/)(?!vendor\/ruby\/)(?!en\/
)(?!ko\/)(?!es\/)(?!pt-BR\/)(?!ja\/)(?!fr\/)(?!de\/)[^,'</span><span class="s2">"</span><span class="se">\s\/</span><span class="s2">?.]+</span><span class="se">\.</span><span class="s2">?)*(?:</span><span class="se">\/</span><span class="s2">[^
</span><span class="se">\]\[</span><span class="s2">)("</span><span class="s1">'\s]*)?)"/ (RegexpError)

...(後略)
</span></pre></div></div><p>同様の問題が報告されているか検索した結果、Polyglotリポジトリに<a href="https://github.com/untra/polyglot/issues/204">全く同じ問題</a>が既に登録されており、解決策も存在していました。</p><p>このブログに適用している<a href="https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/_config.yml">Chirpyテーマの<code class="language-plaintext filepath highlighter-rouge">_config.yml</code></a>ファイルには、次のような構文が存在します。</p><div file="\_config.yml" class="language-yml highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
</pre><td class="rouge-code"><pre><span class="na">exclude</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="s2">"</span><span class="s">*.gem"</span>
  <span class="pi">-</span> <span class="s2">"</span><span class="s">*.gemspec"</span>
  <span class="pi">-</span> <span class="s">docs</span>
  <span class="pi">-</span> <span class="s">tools</span>
  <span class="pi">-</span> <span class="s">README.md</span>
  <span class="pi">-</span> <span class="s">LICENSE</span>
  <span class="pi">-</span> <span class="s2">"</span><span class="s">*.config.js"</span>
  <span class="pi">-</span> <span class="s">package*.json</span>
</pre></div></div><p>問題の原因は<a href="https://github.com/untra/polyglot/blob/master/lib/jekyll/polyglot/patches/jekyll/site.rb">Polyglotの<code class="language-plaintext filepath highlighter-rouge">site.rb</code></a>ファイルに含まれる次の二つの関数の正規表現構文が、上記の<code class="language-plaintext highlighter-rouge">"*.gem"</code>、<code class="language-plaintext highlighter-rouge">"*.gemspec"</code>、<code class="language-plaintext highlighter-rouge">"*.config.js"</code>のようなワイルドカードを含むグロビング（globbing）パターンを正常に処理できないことにあります。</p><div file="(polyglot root path)/lib/jekyll/polyglot/patches/jekyll/site.rb" class="language-ruby highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre><td class="rouge-code"><pre>    <span class="c1"># a regex that matches relative urls in a html document</span>
    <span class="c1"># matches href="baseurl/foo/bar-baz" href="/ja/foo/bar-baz" and others like it</span>
    <span class="c1"># avoids matching excluded files.  prepare makes sure</span>
    <span class="c1"># that all @exclude dirs have a trailing slash.</span>
    <span class="k">def</span> <span class="nf">relative_url_regex</span><span class="p">(</span><span class="n">disabled</span> <span class="o">=</span> <span class="kp">false</span><span class="p">)</span>
      <span class="n">regex</span> <span class="o">=</span> <span class="s1">''</span>
      <span class="k">unless</span> <span class="n">disabled</span>
        <span class="vi">@exclude</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
          <span class="n">regex</span> <span class="o">+=</span> <span class="s2">"(?!</span><span class="si">#{</span><span class="n">x</span><span class="si">}</span><span class="s2">)"</span>
        <span class="k">end</span>
        <span class="vi">@languages</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
          <span class="n">regex</span> <span class="o">+=</span> <span class="s2">"(?!</span><span class="si">#{</span><span class="n">x</span><span class="si">}</span><span class="se">\/</span><span class="s2">)"</span>
        <span class="k">end</span>
      <span class="k">end</span>
      <span class="n">start</span> <span class="o">=</span> <span class="n">disabled</span> <span class="p">?</span> <span class="s1">'ferh'</span> <span class="p">:</span> <span class="s1">'href'</span>
      <span class="sr">%r{</span><span class="si">#{</span><span class="n">start</span><span class="si">}</span><span class="sr">="?</span><span class="si">#{</span><span class="vi">@baseurl</span><span class="si">}</span><span class="sr">/((?:</span><span class="si">#{</span><span class="n">regex</span><span class="si">}</span><span class="sr">[^,'"</span><span class="se">\s</span><span class="sr">/?.]+</span><span class="se">\.</span><span class="sr">?)*(?:/[^</span><span class="se">\]\[</span><span class="sr">)("'</span><span class="se">\s</span><span class="sr">]*)?)"}</span>
    <span class="k">end</span>

    <span class="c1"># a regex that matches absolute urls in a html document</span>
    <span class="c1"># matches href="http://baseurl/foo/bar-baz" and others like it</span>
    <span class="c1"># avoids matching excluded files.  prepare makes sure</span>
    <span class="c1"># that all @exclude dirs have a trailing slash.</span>
    <span class="k">def</span> <span class="nf">absolute_url_regex</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">disabled</span> <span class="o">=</span> <span class="kp">false</span><span class="p">)</span>
      <span class="n">regex</span> <span class="o">=</span> <span class="s1">''</span>
      <span class="k">unless</span> <span class="n">disabled</span>
        <span class="vi">@exclude</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
          <span class="n">regex</span> <span class="o">+=</span> <span class="s2">"(?!</span><span class="si">#{</span><span class="n">x</span><span class="si">}</span><span class="s2">)"</span>
        <span class="k">end</span>
        <span class="vi">@languages</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
          <span class="n">regex</span> <span class="o">+=</span> <span class="s2">"(?!</span><span class="si">#{</span><span class="n">x</span><span class="si">}</span><span class="se">\/</span><span class="s2">)"</span>
        <span class="k">end</span>
      <span class="k">end</span>
      <span class="n">start</span> <span class="o">=</span> <span class="n">disabled</span> <span class="p">?</span> <span class="s1">'ferh'</span> <span class="p">:</span> <span class="s1">'href'</span>
      <span class="sr">%r{(?&lt;!hreflang="</span><span class="si">#{</span><span class="vi">@default_lang</span><span class="si">}</span><span class="sr">" )</span><span class="si">#{</span><span class="n">start</span><span class="si">}</span><span class="sr">="?</span><span class="si">#{</span><span class="n">url</span><span class="si">}#{</span><span class="vi">@baseurl</span><span class="si">}</span><span class="sr">/((?:</span><span class="si">#{</span><span class="n">regex</span><span class="si">}</span><span class="sr">[^,'"</span><span class="se">\s</span><span class="sr">/?.]+</span><span class="se">\.</span><span class="sr">?)*(?:/[^</span><span class="se">\]\[</span><span class="sr">)("'</span><span class="se">\s</span><span class="sr">]*)?)"}</span>
    <span class="k">end</span>
</pre></div></div><p>この問題を解決する方法は二つあります。</p><h3 id="1-polyglotをフォークforkして問題のある部分を修正して使用する">1. Polyglotをフォーク（fork）して問題のある部分を修正して使用する</h3><p>この記事を書いている時点（12024.11.）では、<a href="https://jekyllrb.com/docs/configuration/options/#global-configuration">Jekyll公式ドキュメント</a>で<code class="language-plaintext highlighter-rouge">exclude</code>設定がグロビング（globbing）パターンの活用をサポートすると明記されています。</p><blockquote><p>“This configuration option supports Ruby’s File.fnmatch filename globbing patterns to match multiple entries to exclude.”</p></blockquote><p>つまり、問題の原因はChirpyテーマではなく、Polyglotの<code class="language-plaintext highlighter-rouge">relative_url_regex()</code>、<code class="language-plaintext highlighter-rouge">absolute_url_regex()</code>という二つの関数にあるため、これらを問題が発生しないように修正することが根本的な解決策です。</p><p><del>Polyglotではこのバグはまだ解決されていない状態なので、</del> 前述のとおり、<a href="https://polyglot.untra.io/2025/09/20/polyglot.1.11.0/">Polyglot 1.11 バージョンからこの問題は解決された</a>。問題が発生していた当時は、<del><a href="https://hionpu.com/posts/github_blog_4#4-polyglot-%EC%9D%98%EC%A1%B4%EC%84%B1-%EB%AC%B8%EC%A0%9C">このブログ投稿</a>(サイト削除)と</del> <a href="https://github.com/untra/polyglot/issues/204#issuecomment-2143270322">前述のGitHubイシューに付いた回答</a>を参考にして、Polyglotリポジトリをフォーク（fork）した後、問題のある部分を次のように修正し、オリジナルのPolyglotの代わりに使用することで解決可能だった。</p><div file="(polyglot root path)/lib/jekyll/polyglot/patches/jekyll/site.rb" class="language-ruby highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre><td class="rouge-code"><pre>    <span class="k">def</span> <span class="nf">relative_url_regex</span><span class="p">(</span><span class="n">disabled</span> <span class="o">=</span> <span class="kp">false</span><span class="p">)</span>
      <span class="n">regex</span> <span class="o">=</span> <span class="s1">''</span>
      <span class="k">unless</span> <span class="n">disabled</span>
        <span class="vi">@exclude</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
          <span class="n">escaped_x</span> <span class="o">=</span> <span class="no">Regexp</span><span class="p">.</span><span class="nf">escape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
          <span class="n">regex</span> <span class="o">+=</span> <span class="s2">"(?!</span><span class="si">#{</span><span class="n">escaped_x</span><span class="si">}</span><span class="s2">)"</span>
        <span class="k">end</span>
        <span class="vi">@languages</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
          <span class="n">escaped_x</span> <span class="o">=</span> <span class="no">Regexp</span><span class="p">.</span><span class="nf">escape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
          <span class="n">regex</span> <span class="o">+=</span> <span class="s2">"(?!</span><span class="si">#{</span><span class="n">escaped_x</span><span class="si">}</span><span class="se">\/</span><span class="s2">)"</span>
        <span class="k">end</span>
      <span class="k">end</span>
      <span class="n">start</span> <span class="o">=</span> <span class="n">disabled</span> <span class="p">?</span> <span class="s1">'ferh'</span> <span class="p">:</span> <span class="s1">'href'</span>
      <span class="sr">%r{</span><span class="si">#{</span><span class="n">start</span><span class="si">}</span><span class="sr">="?</span><span class="si">#{</span><span class="vi">@baseurl</span><span class="si">}</span><span class="sr">/((?:</span><span class="si">#{</span><span class="n">regex</span><span class="si">}</span><span class="sr">[^,'"</span><span class="se">\s</span><span class="sr">/?.]+</span><span class="se">\.</span><span class="sr">?)*(?:/[^</span><span class="se">\]\[</span><span class="sr">)("'</span><span class="se">\s</span><span class="sr">]*)?)"}</span>
    <span class="k">end</span>

    <span class="k">def</span> <span class="nf">absolute_url_regex</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">disabled</span> <span class="o">=</span> <span class="kp">false</span><span class="p">)</span>
      <span class="n">regex</span> <span class="o">=</span> <span class="s1">''</span>
      <span class="k">unless</span> <span class="n">disabled</span>
        <span class="vi">@exclude</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
          <span class="n">escaped_x</span> <span class="o">=</span> <span class="no">Regexp</span><span class="p">.</span><span class="nf">escape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
          <span class="n">regex</span> <span class="o">+=</span> <span class="s2">"(?!</span><span class="si">#{</span><span class="n">escaped_x</span><span class="si">}</span><span class="s2">)"</span>
        <span class="k">end</span>
        <span class="vi">@languages</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">x</span><span class="o">|</span>
          <span class="n">escaped_x</span> <span class="o">=</span> <span class="no">Regexp</span><span class="p">.</span><span class="nf">escape</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
          <span class="n">regex</span> <span class="o">+=</span> <span class="s2">"(?!</span><span class="si">#{</span><span class="n">escaped_x</span><span class="si">}</span><span class="se">\/</span><span class="s2">)"</span>
        <span class="k">end</span>
      <span class="k">end</span>
      <span class="n">start</span> <span class="o">=</span> <span class="n">disabled</span> <span class="p">?</span> <span class="s1">'ferh'</span> <span class="p">:</span> <span class="s1">'href'</span>
      <span class="sr">%r{(?&lt;!hreflang="</span><span class="si">#{</span><span class="vi">@default_lang</span><span class="si">}</span><span class="sr">" )</span><span class="si">#{</span><span class="n">start</span><span class="si">}</span><span class="sr">="?</span><span class="si">#{</span><span class="n">url</span><span class="si">}#{</span><span class="vi">@baseurl</span><span class="si">}</span><span class="sr">/((?:</span><span class="si">#{</span><span class="n">regex</span><span class="si">}</span><span class="sr">[^,'"</span><span class="se">\s</span><span class="sr">/?.]+</span><span class="se">\.</span><span class="sr">?)*(?:/[^</span><span class="se">\]\[</span><span class="sr">)("'</span><span class="se">\s</span><span class="sr">]*)?)"}</span>
    <span class="k">end</span>
</pre></div></div><h3 id="2-chirpyテーマの_configyml設定ファイルでグロビングglobbingパターンを正確なファイル名に置き換える">2. Chirpyテーマの’_config.yml’設定ファイルでグロビング（globbing）パターンを正確なファイル名に置き換える</h3><p>実際、正統的で理想的な方法は上記のパッチがPolyglotのメインストリームに反映されることです。しかし、それまではフォークしたバージョンを代わりに使用する必要がありますが、この場合、Polyglotのアップストリームがバージョンアップするたびにそのアップデートを見逃さずに反映しながら追いかけるのが面倒なため、私は別の方法を使用しました。</p><p><a href="https://github.com/cotes2020/jekyll-theme-chirpy">Chirpyテーマリポジトリ</a>でプロジェクトのルートパスに位置するファイルのうち、<code class="language-plaintext highlighter-rouge">"*.gem"</code>、<code class="language-plaintext highlighter-rouge">"*.gemspec"</code>、<code class="language-plaintext highlighter-rouge">"*.config.js"</code>パターンに対応するファイルを確認すると、以下の3つしかありません。</p><ul><li><code class="language-plaintext filepath highlighter-rouge">jekyll-theme-chirpy.gemspec</code><li><code class="language-plaintext filepath highlighter-rouge">purgecss.config.js</code><li><code class="language-plaintext filepath highlighter-rouge">rollup.config.js</code></ul><p>したがって、<code class="language-plaintext filepath highlighter-rouge">_config.yml</code>ファイルの<code class="language-plaintext highlighter-rouge">exclude</code>構文からグロビング（globbing）パターンを削除し、以下のように書き換えれば、Polyglotが問題なく処理できるようになります。</p><div file="\_config.yml" class="language-yml highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
</pre><td class="rouge-code"><pre><span class="na">exclude</span><span class="pi">:</span> <span class="c1"># https://github.com/untra/polyglot/issues/204 イシューを参考に修正。</span>
  <span class="c1"># - "*.gem"</span>
  <span class="pi">-</span> <span class="s">jekyll-theme-chirpy.gemspec</span> <span class="c1"># - "*.gemspec"</span>
  <span class="pi">-</span> <span class="s">tools</span>
  <span class="pi">-</span> <span class="s">README.md</span>
  <span class="pi">-</span> <span class="s">LICENSE</span>
  <span class="pi">-</span> <span class="s">purgecss.config.js</span> <span class="c1"># - "*.config.js"</span>
  <span class="pi">-</span> <span class="s">rollup.config.js</span>
  <span class="pi">-</span> <span class="s">package*.json</span>
</pre></div></div><h2 id="検索機能の修正">検索機能の修正</h2><p>前のステップまで進めた時点で、ほとんどのサイト機能が意図した通りに満足に動作していました。しかし、Chirpyテーマを適用したページの右上に位置する検索バーが<code class="language-plaintext highlighter-rouge">site.default_lang</code>（このブログの場合は英語）以外の言語で書かれたページをインデックスできず、英語以外の他の言語で検索した場合にも検索結果として英語ページを出力するという問題があることを後で発見しました。</p><p>原因を把握するために、検索機能に関わるファイルが何であり、その中でどこに問題が発生しているのかを見てみましょう。</p><h3 id="_layoutsdefaulthtml">‘_layouts/default.html’</h3><p>ブログ内のすべてのページの枠組みを構成する<a href="https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/_layouts/default.html"><code class="language-plaintext filepath highlighter-rouge">_layouts/default.html</code></a>ファイルを確認すると、<code class="language-plaintext highlighter-rouge">&lt;body&gt;</code>エレメント内に<code class="language-plaintext filepath highlighter-rouge">search-results.html</code>と<code class="language-plaintext filepath highlighter-rouge">search-loader.html</code>の内容を読み込んでいることが確認できます。</p><div file="\_layouts/default.html" class="language-liquid highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre><td class="rouge-code"><pre>  &lt;body&gt;
    <span class="cp">{%</span><span class="w"> </span><span class="nt">include</span><span class="w"> </span>sidebar.html<span class="w"> </span><span class="na">lang</span><span class="o">=</span><span class="nv">lang</span><span class="w"> </span><span class="cp">%}</span>

    &lt;div id="main-wrapper" class="d-flex justify-content-center"&gt;
      &lt;div class="container d-flex flex-column px-xxl-5"&gt;
        
        (...中略...)

        <span class="cp">{%</span><span class="w"> </span><span class="nt">include_cached</span><span class="w"> </span><span class="nv">search-results</span><span class="p">.</span><span class="nv">html</span><span class="w"> </span><span class="na">lang</span><span class="o">=</span><span class="nv">lang</span><span class="w"> </span><span class="cp">%}</span>
      &lt;/div&gt;

      &lt;aside aria-label="Scroll to Top"&gt;
        &lt;button id="back-to-top" type="button" class="btn btn-lg btn-box-shadow"&gt;
          &lt;i class="fas fa-angle-up"&gt;&lt;/i&gt;
        &lt;/button&gt;
      &lt;/aside&gt;
    &lt;/div&gt;

    (...中略...)

    <span class="cp">{%</span><span class="w"> </span><span class="nt">include_cached</span><span class="w"> </span><span class="nv">search-loader</span><span class="p">.</span><span class="nv">html</span><span class="w"> </span><span class="na">lang</span><span class="o">=</span><span class="nv">lang</span><span class="w"> </span><span class="cp">%}</span>
  &lt;/body&gt;
</pre></div></div><h3 id="_includessearch-resulthtml">‘_includes/search-result.html’</h3><p><a href="https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/_includes/search-results.html"><code class="language-plaintext filepath highlighter-rouge">_includes/search-result.html</code></a>は検索窓に検索語入力時、そのキーワードに対する検索結果を保存するための<code class="language-plaintext highlighter-rouge">search-results</code>コンテナを構成します。</p><div file="\_includes/search-result.html" class="language-html highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
</pre><td class="rouge-code"><pre><span class="c">&lt;!-- The Search results --&gt;</span>

<span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">"search-result-wrapper"</span> <span class="na">class=</span><span class="s">"d-flex justify-content-center d-none"</span><span class="nt">&gt;</span>
  <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">"col-11 content"</span><span class="nt">&gt;</span>
    <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">"search-hints"</span><span class="nt">&gt;</span>
      {% include_cached trending-tags.html %}
    <span class="nt">&lt;/div&gt;</span>
    <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">"search-results"</span> <span class="na">class=</span><span class="s">"d-flex flex-wrap justify-content-center text-muted mt-3"</span><span class="nt">&gt;&lt;/div&gt;</span>
  <span class="nt">&lt;/div&gt;</span>
<span class="nt">&lt;/div&gt;</span>
</pre></div></div><h3 id="_includessearch-loaderhtml">‘_includes/search-loader.html’</h3><p><a href="https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/_includes/search-loader.html"><code class="language-plaintext filepath highlighter-rouge">_includes/search-loader.html</code></a>がまさに<a href="https://github.com/christian-fei/Simple-Jekyll-Search">Simple-Jekyll-Search</a>ライブラリベースの検索を実装した核心的な部分で、これは<a href="#assetsjsdatasearchjson"><code class="language-plaintext filepath highlighter-rouge">search.json</code></a>インデックスファイルの内容のうち、入力キーワードと一致する部分を見つけて該当する投稿リンクを<code class="language-plaintext highlighter-rouge">&lt;article&gt;</code>エレメントとして返すJavaScriptを訪問者のブラウザ上で実行することによって、クライアントサイドで動作することがわかります。</p><div file="\_includes/search-loader.html" class="language-js highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre><td class="rouge-code"><pre><span class="p">{</span><span class="o">%</span> <span class="nx">capture</span> <span class="nx">result_elem</span> <span class="o">%</span><span class="p">}</span>
  <span class="o">&lt;</span><span class="nx">article</span> <span class="kd">class</span><span class="o">=</span><span class="dl">"</span><span class="s2">px-1 px-sm-2 px-lg-4 px-xl-0</span><span class="dl">"</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="nx">header</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="nx">h2</span><span class="o">&gt;&lt;</span><span class="nx">a</span> <span class="nx">href</span><span class="o">=</span><span class="dl">"</span><span class="s2">{url}</span><span class="dl">"</span><span class="o">&gt;</span><span class="p">{</span><span class="nx">title</span><span class="p">}</span><span class="o">&lt;</span><span class="sr">/a&gt;&lt;/</span><span class="nx">h2</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="nx">div</span> <span class="kd">class</span><span class="o">=</span><span class="dl">"</span><span class="s2">post-meta d-flex flex-column flex-sm-row text-muted mt-1 mb-1</span><span class="dl">"</span><span class="o">&gt;</span>
        <span class="p">{</span><span class="nx">categories</span><span class="p">}</span>
        <span class="p">{</span><span class="nx">tags</span><span class="p">}</span>
      <span class="o">&lt;</span><span class="sr">/div</span><span class="err">&gt;
</span>    <span class="o">&lt;</span><span class="sr">/header</span><span class="err">&gt;
</span>    <span class="o">&lt;</span><span class="nx">p</span><span class="o">&gt;</span><span class="p">{</span><span class="nx">snippet</span><span class="p">}</span><span class="o">&lt;</span><span class="sr">/p</span><span class="err">&gt;
</span>  <span class="o">&lt;</span><span class="sr">/article</span><span class="err">&gt;
</span><span class="p">{</span><span class="o">%</span> <span class="nx">endcapture</span> <span class="o">%</span><span class="p">}</span>

<span class="p">{</span><span class="o">%</span> <span class="nx">capture</span> <span class="nx">not_found</span> <span class="o">%</span><span class="p">}</span><span class="o">&lt;</span><span class="nx">p</span> <span class="kd">class</span><span class="o">=</span><span class="dl">"</span><span class="s2">mt-5</span><span class="dl">"</span><span class="o">&gt;</span><span class="p">{{</span> <span class="nx">site</span><span class="p">.</span><span class="nx">data</span><span class="p">.</span><span class="nx">locales</span><span class="p">[</span><span class="nx">include</span><span class="p">.</span><span class="nx">lang</span><span class="p">].</span><span class="nx">search</span><span class="p">.</span><span class="nx">no_results</span> <span class="p">}}</span><span class="o">&lt;</span><span class="sr">/p&gt;{% endcapture %</span><span class="err">}
</span>
<span class="o">&lt;</span><span class="nx">script</span><span class="o">&gt;</span>
  <span class="p">{</span><span class="o">%</span> <span class="nx">comment</span> <span class="o">%</span><span class="p">}</span> <span class="nl">Note</span><span class="p">:</span> <span class="nx">dependent</span> <span class="nx">library</span> <span class="nx">will</span> <span class="nx">be</span> <span class="nx">loaded</span> <span class="k">in</span> <span class="s2">`js-selector.html`</span> <span class="p">{</span><span class="o">%</span> <span class="nx">endcomment</span> <span class="o">%</span><span class="p">}</span>
  <span class="nb">document</span><span class="p">.</span><span class="nf">addEventListener</span><span class="p">(</span><span class="dl">'</span><span class="s1">DOMContentLoaded</span><span class="dl">'</span><span class="p">,</span> <span class="p">()</span> <span class="o">=&gt;</span> <span class="p">{</span>
    <span class="nc">SimpleJekyllSearch</span><span class="p">({</span>
      <span class="na">searchInput</span><span class="p">:</span> <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">search-input</span><span class="dl">'</span><span class="p">),</span>
      <span class="na">resultsContainer</span><span class="p">:</span> <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">search-results</span><span class="dl">'</span><span class="p">),</span>
      <span class="na">json</span><span class="p">:</span> <span class="dl">'</span><span class="s1">{{ </span><span class="dl">'</span><span class="o">/</span><span class="nx">assets</span><span class="o">/</span><span class="nx">js</span><span class="o">/</span><span class="nx">data</span><span class="o">/</span><span class="nx">search</span><span class="p">.</span><span class="nx">json</span><span class="dl">'</span><span class="s1"> | relative_url }}</span><span class="dl">'</span><span class="p">,</span>
      <span class="na">searchResultTemplate</span><span class="p">:</span> <span class="dl">'</span><span class="s1">{{ result_elem | strip_newlines }}</span><span class="dl">'</span><span class="p">,</span>
      <span class="na">noResultsText</span><span class="p">:</span> <span class="dl">'</span><span class="s1">{{ not_found }}</span><span class="dl">'</span><span class="p">,</span>
      <span class="na">templateMiddleware</span><span class="p">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">prop</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">template</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if </span><span class="p">(</span><span class="nx">prop</span> <span class="o">===</span> <span class="dl">'</span><span class="s1">categories</span><span class="dl">'</span><span class="p">)</span> <span class="p">{</span>
          <span class="k">if </span><span class="p">(</span><span class="nx">value</span> <span class="o">===</span> <span class="dl">''</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="s2">`</span><span class="p">${</span><span class="nx">value</span><span class="p">}</span><span class="s2">`</span><span class="p">;</span>
          <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="s2">`&lt;div class="me-sm-4"&gt;&lt;i class="far fa-folder fa-fw"&gt;&lt;/i&gt;</span><span class="p">${</span><span class="nx">value</span><span class="p">}</span><span class="s2">&lt;/div&gt;`</span><span class="p">;</span>
          <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">if </span><span class="p">(</span><span class="nx">prop</span> <span class="o">===</span> <span class="dl">'</span><span class="s1">tags</span><span class="dl">'</span><span class="p">)</span> <span class="p">{</span>
          <span class="k">if </span><span class="p">(</span><span class="nx">value</span> <span class="o">===</span> <span class="dl">''</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="s2">`</span><span class="p">${</span><span class="nx">value</span><span class="p">}</span><span class="s2">`</span><span class="p">;</span>
          <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="s2">`&lt;div&gt;&lt;i class="fa fa-tag fa-fw"&gt;&lt;/i&gt;</span><span class="p">${</span><span class="nx">value</span><span class="p">}</span><span class="s2">&lt;/div&gt;`</span><span class="p">;</span>
          <span class="p">}</span>
        <span class="p">}</span>
      <span class="p">}</span>
    <span class="p">});</span>
  <span class="p">});</span>
<span class="o">&lt;</span><span class="sr">/script</span><span class="err">&gt;
</span></pre></div></div><h3 id="assetsjsdatasearchjson">‘/assets/js/data/search.json’</h3><div file="/assets/js/data/search.json" class="language-liquid highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre><td class="rouge-code"><pre>---
layout: compress
swcache: true
---

[
  <span class="cp">{%</span><span class="w"> </span><span class="nt">for</span><span class="w"> </span><span class="nv">post</span><span class="w"> </span><span class="nt">in</span><span class="w"> </span><span class="nv">site</span><span class="p">.</span><span class="nv">posts</span><span class="w"> </span><span class="cp">%}</span>
  {
    "title": <span class="cp">{{</span><span class="w"> </span><span class="nv">post</span><span class="p">.</span><span class="nv">title</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">jsonify</span><span class="w"> </span><span class="cp">}}</span>,
    "url": <span class="cp">{{</span><span class="w"> </span><span class="nv">post</span><span class="p">.</span><span class="nv">url</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">relative_url</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">jsonify</span><span class="w"> </span><span class="cp">}}</span>,
    "categories": <span class="cp">{{</span><span class="w"> </span><span class="nv">post</span><span class="p">.</span><span class="nv">categories</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">join</span><span class="p">:</span><span class="w"> </span><span class="s1">', '</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">jsonify</span><span class="w"> </span><span class="cp">}}</span>,
    "tags": <span class="cp">{{</span><span class="w"> </span><span class="nv">post</span><span class="p">.</span><span class="nv">tags</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">join</span><span class="p">:</span><span class="w"> </span><span class="s1">', '</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">jsonify</span><span class="w"> </span><span class="cp">}}</span>,
    "date": "<span class="cp">{{</span><span class="w"> </span><span class="nv">post</span><span class="p">.</span><span class="nv">date</span><span class="w"> </span><span class="cp">}}</span>",
    <span class="cp">{%</span><span class="w"> </span><span class="nt">include</span><span class="w"> </span>no-linenos.html<span class="w"> </span><span class="na">content</span><span class="o">=</span><span class="nv">post</span><span class="p">.</span><span class="nv">content</span><span class="w"> </span><span class="cp">%}</span>
    <span class="cp">{%</span><span class="w"> </span><span class="nt">assign</span><span class="w"> </span><span class="nv">_content</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">content</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">strip_html</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">strip_newlines</span><span class="w"> </span><span class="cp">%}</span>
    "snippet": <span class="cp">{{</span><span class="w"> </span><span class="nv">_content</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">truncate</span><span class="p">:</span><span class="w"> </span><span class="mi">200</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">jsonify</span><span class="w"> </span><span class="cp">}}</span>,
    "content": <span class="cp">{{</span><span class="w"> </span><span class="nv">_content</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">jsonify</span><span class="w"> </span><span class="cp">}}</span>
  }<span class="cp">{%</span><span class="w"> </span><span class="nt">unless</span><span class="w"> </span><span class="nb">forloop.last</span><span class="w"> </span><span class="cp">%}</span>,<span class="cp">{%</span><span class="w"> </span><span class="nt">endunless</span><span class="w"> </span><span class="cp">%}</span>
  <span class="cp">{%</span><span class="w"> </span><span class="nt">endfor</span><span class="w"> </span><span class="cp">%}</span>
]
</pre></div></div><p>JekyllのLiquid構文を利用して、サイト内のすべての投稿のタイトル、URL、カテゴリーおよびタグ情報、作成日、本文の最初の200文字のスニペット、そして全文内容を含むJSONファイルを定義しています。</p><h3 id="検索機能の動作構造と問題発生部分の把握">検索機能の動作構造と問題発生部分の把握</h3><p>つまり整理すると、GitHub Pages上でChirpyテーマをホスティングする場合、検索機能は次のようなプロセスで動作します。</p><pre><code class="language-mermaid">stateDiagram
  state "Changes" as CH
  state "Build start" as BLD
  state "Create search.json" as IDX
  state "Static Website" as DEP
  state "In Test" as TST
  state "Search Loader" as SCH
  state "Results" as R
    
  [*] --&gt; CH: Make Changes
  CH --&gt; BLD: Commit &amp; Push origin
  BLD --&gt; IDX: jekyll build
  IDX --&gt; TST: Build Complete
  TST --&gt; CH: Error Detected
  TST --&gt; DEP: Deploy
  DEP --&gt; SCH: Search Input
  SCH --&gt; R: Return Results
  R --&gt; [*]
</code></pre><p>ここで<code class="language-plaintext filepath highlighter-rouge">search.json</code>はPolyglotによって次のように各言語別に生成されることを確認しました。</p><ul><li><code class="language-plaintext filepath highlighter-rouge">/assets/js/data/search.json</code><li><code class="language-plaintext filepath highlighter-rouge">/ko/assets/js/data/search.json</code><li><code class="language-plaintext filepath highlighter-rouge">/ja/assets/js/data/search.json</code><li><code class="language-plaintext filepath highlighter-rouge">/zh-TW/assets/js/data/search.json</code><li><code class="language-plaintext filepath highlighter-rouge">/es/assets/js/data/search.json</code><li><code class="language-plaintext filepath highlighter-rouge">/pt-BR/assets/js/data/search.json</code><li><code class="language-plaintext filepath highlighter-rouge">/fr/assets/js/data/search.json</code><li><code class="language-plaintext filepath highlighter-rouge">/de/assets/js/data/search.json</code></ul><p>したがって、問題の原因となる部分は「Search Loader」です。英語以外の他の言語バージョンのページが検索されない問題は、<code class="language-plaintext filepath highlighter-rouge">_includes/search-loader.html</code>で現在訪問中のページの言語に関係なく、英語インデックスファイル（<code class="language-plaintext filepath highlighter-rouge">/assets/js/data/search.json</code>）のみを静的に読み込むために発生します。</p><blockquote class="prompt-warning"><ul><li>ただし、マークダウンやhtml形式ファイルとは異なり、JSONファイルに対しては<code class="language-plaintext highlighter-rouge">post.title</code>、<code class="language-plaintext highlighter-rouge">post.content</code>などJekyll提供変数に対するPolyglot wrapperは動作しますが、<a href="https://github.com/untra/polyglot?tab=readme-ov-file#relativized-local-urls">Relativized Local Urls</a>機能は動作しないようです。<li>同様に、JSONファイルテンプレート内では、Jekyll基本提供変数以外に<a href="https://github.com/untra/polyglot?tab=readme-ov-file#features">Polyglotで追加提供する<code class="language-plaintext highlighter-rouge">{{ site.default_lang }}</code>、<code class="language-plaintext highlighter-rouge">{{ site.active_lang }}</code> liquidタグ</a>にはアクセスできないことをテスト過程で確認しました。</ul><p>したがって、インデックスファイル内の<code class="language-plaintext highlighter-rouge">title</code>、<code class="language-plaintext highlighter-rouge">snippet</code>、<code class="language-plaintext highlighter-rouge">content</code>などの値は言語別に異なって生成されますが、<code class="language-plaintext highlighter-rouge">url</code>値は言語を考慮しない基本パスを返すため、これに対する適切な処理を「Search Loader」部分に追加する必要があります。</p></blockquote><h3 id="問題解決">問題解決</h3><p>これを解決するには、<code class="language-plaintext filepath highlighter-rouge">_includes/search-loader.html</code>の内容を次のように修正します。</p><div file="\_includes/search-loader.html" class="language-plaintext highlighter-rouge"><div class="highlight">class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre><td class="rouge-code"><pre>{% capture result_elem %}
  &lt;article class="px-1 px-sm-2 px-lg-4 px-xl-0"&gt;
    &lt;header&gt;
      {% if site.active_lang != site.default_lang %}
      &lt;h2&gt;&lt;a {% static_href %}href="/{{ site.active_lang }}{url}"{% endstatic_href %}&gt;{title}&lt;/a&gt;&lt;/h2&gt;
      {% else %}
      &lt;h2&gt;&lt;a href="{url}"&gt;{title}&lt;/a&gt;&lt;/h2&gt;
      {% endif %}

(...中略...)

&lt;script&gt;
  {% comment %} Note: dependent library will be loaded in `js-selector.html` {% endcomment %}
  document.addEventListener('DOMContentLoaded', () =&gt; {
    {% assign search_path = '/assets/js/data/search.json' %}
    {% if site.active_lang != site.default_lang %}
      {% assign search_path = '/' | append: site.active_lang | append: search_path %}
    {% endif %}
    
    SimpleJekyllSearch({
      searchInput: document.getElementById('search-input'),
      resultsContainer: document.getElementById('search-results'),
      json: '{{ search_path | relative_url }}',
      searchResultTemplate: '{{ result_elem | strip_newlines }}',

(...後略)
</pre></div></div><ul><li><code class="language-plaintext highlighter-rouge">site.active_lang</code>（現在のページの言語）と<code class="language-plaintext highlighter-rouge">site.default_lang</code>（サイトのデフォルト言語）が同じでない場合、JSONファイルから読み込んだ投稿URLの前に<code class="language-plaintext highlighter-rouge">"/{{ site.active_lang }}"</code>プレフィックスを追加するように<code class="language-plaintext highlighter-rouge">{% capture result_elem %}</code>部分のliquid構文を修正しました。<li>同じ方法で、ビルド過程で現在のページの言語とサイトのデフォルト言語を比較し、同じであればデフォルトパス（<code class="language-plaintext filepath highlighter-rouge">/assets/js/data/search.json</code>）を、異なる場合はその言語に合ったパス（例：<code class="language-plaintext filepath highlighter-rouge">/ko/assets/js/data/search.json</code>）を<code class="language-plaintext highlighter-rouge">search_path</code>として指定するように<code class="language-plaintext highlighter-rouge">&lt;script&gt;</code>部分を修正しました。</ul><p>上記のように修正した後、ウェブサイトを再ビルドすると、各言語に合わせて検索結果が正常に表示されることを確認しました。</p><blockquote class="prompt-tip"><p><code class="language-plaintext highlighter-rouge">{url}</code>は後で検索実行時にJSによってJSONファイルから読み込んだURL値が入る場所であり、ビルド時点では有効なURLではないため、Polyglotではlocalizationの対象として認識しないため、直接言語に応じて処理する必要があります。問題は、そのように処理した<code class="language-plaintext highlighter-rouge">"/{{ site.active_lang }}{url}"</code>テンプレートはビルド時に相対URLとして認識され、すでにlocalizationが完了していますが、Polyglotはそこまで知らないため、重複してlocalizationを実行しようとすることです（例：<code class="language-plaintext filepath highlighter-rouge">"/ko/ko/posts/example-post"</code>）。これを防ぐために<a href="https://github.com/untra/polyglot?tab=readme-ov-file#disabling-url-relativizing"><code class="language-plaintext highlighter-rouge">{% static_href %}</code>タグ</a>を明示しました。</p></blockquote>]]> </content> </entry> </feed>
