Prof. Shigeto R. Nishitani's website - NumRecipe Diff

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

{{toc}}

// #+STARTUP: indent nolineimages content num
// #+OPTIONS: ^:{}
// #+OPTIONS:   H:4 toc:t num:2
// #+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup

! [[qiita_link|https://qiita.com/daddygongon/private/f5986138a214b188e26d]]
! 目的
「数値計算」の基礎的な事項をPython codeを通して理解する.
さらに,グループ評価を通じて,[[AM/PM|https://qiita.com/daddygongon/items/b0bf7fa06a3dd601529c]]的な学修スキルを身につける.
! 単位について
!! 全般の注意
* フォーマンセルで取り組む.==座席指定.==
* フォーマンセルですが,基本は4人,4人以下ならOK, 5人以上は不可.
* 期末試験の結果をフォーマンセルで平均する.
* 授業中に与えた課題に解答あるいはまともな質問をしたフォーマンセルに加点(合計20点程度).
* 章末の演習課題を提出したフォーマンセルに加点(2点X9回程度),
* 現在の各チーム得点
** [[NumRecipeScore24]]
* 過去年度の得点
** [[NumRecipeScore23]]
** [[NumRecipeScore22]]
** [[NumRecipeScore21]]
** [[NumRecipeScore20]]
** [[NumRecipeScore19]]
** [[NumRecipeScore18]]
** [[NumRecipeScore17]]
** [[NumRecipeScore16]]
** [[NumRecipeScore15]]
** [[NumRecipeScore14]]
** [[NumRecipeScore13]]
** [[NumRecipeScore12]]
** [[NumRecipeScore11]]
* 相当量の印刷物を配布予定(100page以上).試験に備えてバインダーに保存しておくこと.

!! 章末の演習課題について
* 次週の前日の夜中までにLUNAにpdfで提出.
* 全部やる必要はない.2,3問を指定します.
* 採点結果は私のURLへup.
* レポートっぽく色々試したり,追加してもらうと加点.
* ==ペア(ツーマンセル)==フォーマンセルで1つ出せばよい.
* 採点の都合上,遅れたら,0点.

!! 期末試験について(100点満点)
* [[NumRecipe_ExamTA_manual]]
* 7/12の講義時間中に,対面で実施.
* 講義室で実施
* 座席指定.時間中5分間だけ相談時間を設ける予定.
* ==大学のコンピュータを使って実際に数値計算をする課題がある.==
* BYODでcodeを実行,LUNAへ提出.
* メール(含むLINE等のSNS)の使用は一切不可.見つかれば即退場.webの利用はOKだけど,「教えて」なんかはダメよ.
* 資料などの持ち込みは,プリント,ノート,コピーおよびレポート.
* USBメモリーの試験時間中の使用は不可.必要な資料や課題のファイルはあらかじめ自分のフォルダーに入れておくように
* 章末の演習課題と重複する問題が多い.よく消化しておくように.

! 講義の目的:数値計算をPythonで解説
!! 数値計算
「数値計算」が対象とする分野は,関数の解,積分,微分方程式,固有値問題などで,数学の問題を解析的(analytical)
ではなく,数値的 (numerical)
に解く手法の集大成.数値計算には,料理と同じで,正しい調理法
(レシピ,recipe) がある.
!! 基本的な戦術
数値計算が必要となる問題を解くときの戦術は,
# 手持ちのツールで解いてみる,
# 解析的な解を捜す,
# 既存の数値計算のサブルーチンを写して,利用.
# 使いやすいライブラリを捜す,
# 自分でサブルーチンを考える,
という順でおおむね進める.
数値計算のサブルーチンを実際に自分で考えるということはほとんどない.
しかし,例え 3. や 4. の既存のサブルーチンに頼るときにも,
ブラックボックスの中で何がおこなわれているかを大まかに理解しておかないと
大失敗をしでかすことがある.

といっても,数値計算手法の全てを理解しておく必要はない.
料理において基本となる,切る,煮る, 焼くなどを知っていれば,recipe
を見ながら調理ができる.
数値計算においても同じで,基本となる誤差,精度,収束性,安定性,計算速度などの本質を理解しておけば,
新しい数値計算手法もだいたいの振る舞いを予測することが出来る.

本講義ではこのような視点にたって,
いくつかの典型的な数値計算手法の基礎的な考え方と実際のプログラムを紹介する.

!! python
* jupyter notebookで資料を提供
* [[github|https://github.com/daddygongon/jupyter_num_calc]] の数値計算
* [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/README.ipynb]] notebookのviewer
* 自習するならanaconda  
** [[https://www.anaconda.com]] でinstallするのが便利.
** 大学のpcにはサブセット(miniconda)が入っている.
** [[情報準備室提供installer (Windows用)|https://cs.kwansei.ac.jp/junbi/Python/]]
* エディターはvscode(Microsoft謹製)が便利
** 環境設定はほぼ自動です.
** インストールしますかと尋ねられたのをyesしていく
! スケジュール予定
!! 初回環境整備と諸注意
* [[github|https://github.com/daddygongon/jupyter_num_calc]]の数値計算(num_calc), [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/README.ipynb]]
* [[anacondaのinstall|https://kwanseio365-my.sharepoint.com/:b:/g/personal/cru32369_nuc_kwansei_ac_jp/ETMXnjOHKZtNvRx1i4eYFKoByg9nVEzABi2xbEQSbhxbgA?e=d28wk9]], [[python基礎|https://kwanseio365-my.sharepoint.com/:b:/g/personal/cru32369_nuc_kwansei_ac_jp/EUASKW9Xlx1JhzB8gytVmzEBJpc2xJ97dasYydlVwIR6Zw?e=Lfhxle]]([[動画|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/EY_8FHmiE4FDhpcqH7B-aMsBvJeV8mX0fseKf2kF2tR6Qw?e=KRxwiX]]),{{attach_anchor_string(チーム同意書, num_recipe_team_agreement.docx)}}(lunaへ提出)
// - 数式処理実習の受講生はanacondaのinstall, pythonの基礎は見る必要ありません.
!! 講義内容

||
|| date         || ipynb              || viewer   || pdf      || マーク付きpdf || 解答例   || 動画      
||
|| day 0(4/10)  || 授業進行説明       ||          || {{attach_anchor_string(テキスト,23s_num_recipte_kick_off.pdf)}} || {{attach_anchor_string(講義手順,d0_lecture_marked.pdf)}}      ||          ||            
|| day 1(4/10)  || {{attach_anchor_string(常微分方程式,d1_python_ode.ipynb)}}       || [[viewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d1_python_ode.ipynb]]   || {{attach_anchor_string(テキスト,d1_python_ode.pdf)}} || {{attach_anchor_string(テキスト,d1_python_ode_marked.pdf)}}      ||          || [[リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/EdrygCXzwlxNsUItfaCJ0zIBjLlK8ryHqNij1ThsoP3uTA?e=sUzuoe]]    
|| day 2(4/17)  || {{attach_anchor_string(代数方程式,d2_fsolve.ipynb)}}         || [[viewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d2_fsolve.ipynb]]   || {{attach_anchor_string(テキスト,d2_fsolve.pdf)}} || {{attach_anchor_string(テキスト,d2_fsolve_marked.pdf)}}      || {{attach_anchor_string(テキスト,r2_fsolve_ans.pdf)}} || [[リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/ETZKFcsZQ3FApDO-MvgBeqAB-udrGxmpH8oWsgLwG_OknA?e=6I0eHh]]    
|| day 3(4/24)  || {{attach_anchor_string(誤差,d3_error.ipynb)}}               || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d3_error.ipynb]] || {{attach_anchor_string(テキスト,d3_error.pdf)}} || {{attach_anchor_string(テキスト,d3_error_marked.pdf)}}      || {{attach_anchor_string(テキスト,r3_error_ans.pdf)}} || [[リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/EYrPSaNapexEiQjTbVOJVNYBD31B2EgV0h5SPVd1OtEo7g?e=JCpCR0]]    
|| day 4(5/01)  || {{attach_anchor_string(写像,d4_la_fundamentals.ipynb)}}               || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d4_la_fundamentals.ipynb]] || {{attach_anchor_string(テキスト,d4_la_fundamentals.pdf)}} || {{attach_anchor_string(テキスト,d4_la_fundamentals_marked.pdf)}}      || {{attach_anchor_string(テキスト,d5_la_basic_写像_さんしゃさんよー.pdf)}} || [[昨年リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/EWcheYDZznVNjoKl6wYE4pEBN79Rfg7LBlIM2YTRBfkLLg?e=vywT6B]]
|| day 5(5/08)  || {{attach_anchor_string(逆行列,d5_la_matrix_inverse.ipynb)}}             || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d5_la_matrix_inverse.ipynb]] || {{attach_anchor_string(テキスト,d5_la_matrix_inverse.pdf)}} || {{attach_anchor_string(テキスト,d5_la_matrix_inverse_marked.pdf)}}      || {{attach_anchor_string(テキスト,d5_la_basic_π息.pdf)}} ||            
|| day 6(5/15)  || {{attach_anchor_string(固有値とライブラリ,d6_la_eigen_vectors.ipynb)}} || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d6_la_eigen_vectors.ipynb]] || {{attach_anchor_string(テキスト,d6_la_eigen_vectors.pdf)}} || {{attach_anchor_string(テキスト,d6_la_eigen_vectors_marked.pdf)}}      || {{attach_anchor_string(テキスト,d6_la_eigen_sansha.pdf)}} || [[昨年リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/EUtVlRQ0PIBNpKckvpeYFH8BC31TNBhSGojRFyIHd3ju1Q?e=nBDUTg]]
||              || {{attach_anchor_string(計算速度競争,d6_la_speed_race.ipynb)}}       || [[nbviewer|https://nbviewer.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/./ipynb_text/d6_la_speed_race.ipynb]] || {{attach_anchor_string(テキスト,d6_la_speed_race.pdf)}} ||               ||          ||            
|| day 7(5/22)  || {{attach_anchor_string(補間と数値積分,d7_interpolation_integral.ipynb)}}     || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d7_interpolation_integral.ipynb]] || {{attach_anchor_string(テキスト,d7_interpolation_integral.pdf)}} || {{attach_anchor_string(テキスト,d7_interpolation_integral_memo.pdf)}}      || {{attach_anchor_string(テキスト,d7_interpolate_integral_python.pdf)}} || [[昨年リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/EboJwjWCCoVGn_eGF2d-zLEBRDd7EIdRdL466P7TPhMpqA?e=LR67c6]]
|| day 8(5/29)  || {{attach_anchor_string(線形最小二乗法,d8_least_square_fit.ipynb)}}     || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d8_least_square_fit.ipynb]] || {{attach_anchor_string(テキスト,d8_least_square_fit.pdf)}} || {{attach_anchor_string(テキスト,d8_least_square_fit_memo.pdf)}}      || {{attach_anchor_string(テキスト,d8_leastsquarefit.pdf)}} || [[昨年リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/Eb_K9_AlOW9EiAdYKJ5VRasBhAncHLF8tf0RyST5tiPW1A?e=tAlAwC]]
|| day 9(6/05)  || {{attach_anchor_string(非線形最小二乗法,d9_non_linear_fit.ipynb)}}   || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d9_non_linear_fit.ipynb]] || {{attach_anchor_string(テキスト,d9_non_linear_fit.pdf)}} || {{attach_anchor_string(テキスト,d9_non_linear_fit_marked.pdf)}}      || {{attach_anchor_string(テキスト,r9_non_linear_fit_ans.pdf)}} || [[昨年リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/EZSkF17RWMFEqTm5nhHOfd4BqAafUG99Eij_9EWl-sAiDA?e=Ztc9Ro]]
|| day 10(6/12) || {{attach_anchor_string(期末試験リハーサル,exam_22.ipynb)}} || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d9_non_linear_fit.ipynb]] || {{attach_anchor_string(テキスト,exam_22.pdf)}} ||               ||          ||            
|| day 11(6/19) || {{attach_anchor_string(FFT,d10_fft.ipynb)}}                || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d10_fft.ipynb]] || {{attach_anchor_string(テキスト,d10_fft.pdf)}} ||               ||          || [[昨年リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/EY-ntSMc7FVLnXic08naC40B4PwwixgyKDTF8-irI-0V0g?e=8sLqJ7]]
|| day 12(6/26) || {{attach_anchor_string(常微分方程式,python_ode.ipynb)}}       || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/d1_python_ode.ipynb]] || {{attach_anchor_string(テキスト,d1_python_ode.pdf)}} || {{attach_anchor_string(テキスト,d11_python_ode_marked.pdf)}}      ||          || [[昨年リンク|https://kwanseio365-my.sharepoint.com/:v:/g/personal/cru32369_nuc_kwansei_ac_jp/Ebq1Vx95hLpCjqUXw7gdwYEB7AtdLj9OzETpuYkHt-4TUQ?e=iKmFOe]]
|| day 13(7/3)  || 予備日             ||          ||          ||               ||          ||            
|| day 14(7/10) || {{attach_anchor_string(期末試験本番,ex23.ipynb)}}       || [[nbviewer|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/ipynb_text/ex23.ipynb]] || {{attach_anchor_string(テキスト,ex23.pdf)}} ||               || {{attach_anchor_string(解答例,ex23_ans.pdf)}}   ||            
||



// 第5回の発展課題(乳がん検出器)のdata  {{attach_anchor(train_A.data)}}, {{attach_anchor(train_b.data)}}, {{attach_anchor(validate_A.data)}}, {{attach_anchor(validate_b.data)}}
* [[svdによるfitting|https://qiita.com/daddygongon/items/5459a372569a63868f0a]]

! 期末試験関連資料
|| 年度   || 問題       || 内容                                                || 答案        
||
|| 22年度 || {{attach_anchor_string(ipynb,exam_22.ipynb)}}, {{attach_anchor_string(pdf,exam_22.pdf)}} || 行列,漸化式の誤差,積分, Verlet                    || {{attach_anchor_string(答案,exam_22_ans.ipynb)}}, {{attach_anchor_string(pdf,exam_22_ans.pdf)}}  
|| 21年度 || {{attach_anchor_string(ipynb,exam_21.ipynb)}}, {{attach_anchor_string(pdf,exam_21.pdf)}} || 行列,差分商,積分, スムースな静⽌                  || {{attach_anchor_string(答案,exam_21_ans.ipynb)}}, {{attach_anchor_string(pdf,exam_21_ans.pdf)}}  
|| 20年度 || {{attach_anchor_string(ipynb,exam_20.ipynb)}}, {{attach_anchor_string(pdf,exam_20.pdf)}} || fit, 数値解の収束性, 常微, fft                      || [[.ipynb|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/exams/exam_20_ans.ipynb]], {{attach_anchor_string(pdf,exam_20_ans.pdf)}}
|| 19年度 || {{attach_anchor_string(pdf,exam_19.pdf)}}        || 行列, fft, 解の収束性, ODE                          || [[nbview|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/exams/exam_19_ans.ipynb]], {{attach_anchor_string(pdf,exam_19_ans.pdf)}}
|| 18年度 || {{attach_anchor_string(pdf,exam18.pdf)}}        || 行列,解収束性,精度・誤差,最小二乗,常微              || [[nbview|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/exams/exam18_ans.ipynb]]      
|| 17年度 || {{attach_anchor_string(pdf,Exam17.pdf)}}        || 行列,精度・誤差,積分,最小2乗法,常微                 || [[nbview|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/exams/exam17_ans.ipynb]]      
|| 16年度 || {{attach_anchor_string(pdf,Exam16.pdf)}}        || 収束性,Gauss-Seidel,FFT強度表示,tanニュートン差分商 || [[nbview|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/exams/exam16_ans.ipynb]]      
|| 15年度 || {{attach_anchor_string(pdf,Exam15.pdf)}}        || 収束性,丸め誤差,Newton差分商,ページランク           || [[nbview|https://nbviewer.jupyter.org/github/daddygongon/jupyter_num_calc/blob/main/numerical_calc/exams/exam15_ans.ipynb]]      
|| 14年度 || {{attach_anchor_string(pdf,Exam14.pdf)}}        ||                                                     ||            
|| 11年度 || {{attach_anchor_string(pdf,Exam11r.pdf)}}        ||                                                     ||            

* [[NumRecipe_ExamTA_manual]]

! 来年度に向けて
* プリントアウトで不正が起こるかも.試験の提出はLUNAから.
* 学期の始めに,以下の項目を明言する
** コピペでいいこと.
** 何を削るべきか?
** どこを換えるべきか?
** どのような操作がJupyter Notebookで最低限修得しないといけないか?
** チームの結束.
** 課題の意味.

! 参考文献
:  William H. Press 他著「ニューメリカルレシピ・イン・シー C言語による数値計算レシピ」(技術評論社,1993) : 数値計算のバイブル.原著 Numerical recipeでは非常に広範な計算対象に対して,C, Fortran, C++, Pascal, Basic版が用意されており,数値計算プログラムをコーディングする際の洗練されたスタイルも提示している.記述は初学者には難しいが,ある程度経験を積んだプログラマには,手法を選ぶうえで非常に役に立つ情報である.

: 奥村晴彦著「C言語による最新アルゴリズム事典」(技術評論社,1991) : いわゆる数値計算に限らず,いろいろな計算機問題とその解法が載っている.数値計算についても必要最小限の記述とプログラムがまとめられており,非常に便利.改訂版が2018に出た.

: 数値解析法,森正武著,1984, 朝倉書店朝倉現代物理学講座7 :  
: 数値解析,一松信著,1982,朝倉書店新数学講座13 : 両書とも少し古いが,数値計算の基礎となる理論的な説明が明解.

: 河村哲也著「数値計算の初歩!」(山海堂,2002年) : レベルは高くないが,重要な数値計算の初歩を丁寧に解説.