SageMathで数学の力を上げます PyCon mini Hiroshima 2019 / Enlarge your ability of mathematics with SageMath

853cd87b5c317b8c16b0e78c2efbf8d1?s=47 北䑓如法
October 12, 2019

SageMathで数学の力を上げます PyCon mini Hiroshima 2019 / Enlarge your ability of mathematics with SageMath

SageMathで数学の力を上げます PyCon mini Hiroshima 2019 / Enlarge your ability of mathematics with SageMath
PyCon mini Hiroshima 2019 での講演資料です。
@広島市立大学サテライトキャンパス 2019年10月12日(土)

853cd87b5c317b8c16b0e78c2efbf8d1?s=128

北䑓如法

October 12, 2019
Tweet

Transcript

  1. SageMathͰ ਺ֶͷ ྗΛ ্͛·͢ Enlarge your ability of mathematics with

    SageMath ๺㝳೗๏ PyCon mini Hiroshima 2019 @޿ౡࢢཱେֶαςϥΠτΩϟϯύε @2019೥10݄12೔(౔)
  2. ͜ͷࢿྉ͸Ξοϓϩʔυ൛ ▸ ౰೔Demoͱ͍ͯͨ͠ͱ͜Ζ͸ɺ͍͔ͭ͘εΫϦʔϯγϣοτΛషΓ෇͚ ·ͨ͠ɻ ▸ ͕࣌ؒ͋ͬͨΒ͠Ό΂Ζ͏ͱࢥͬͨεϥΠυ͕ޙΖʹ෇͚ͯ͋Γ·͢ɻ

  3. ࣗݾ঺հ ͋ Μ ͨ ͊ ୭ ͳ ͊

  4. None
  5. ๺㝳೗๏ ▸ ͖͍ͨͩΏ͖ͷΓ ▸ ʮ೗๏ʯΛԻಡΈ(༗৬ಡΈ)ͯ͠ňʹΐ΄͏ʼn ▸ ϋΠύɾϝσΟΞɾτϥϯεϨʔλ ▸ ೔༵ϓϩάϥϚ

  6. iPad ޿ౡห ݕࡧ ৄ͘͠͸

  7. ʮ͜Μͳײ͡ͷ͕ग़͖ͯ·͢ɻʯ

  8. (͜͜Ͱ࠷ۙͷଞͷ׆ಈΛը૾(ུ)෇͖Ͱ͝঺հͨ͠) ▸ ཆ໋ञ΢Σϒಈը޿ࠂ ެࣜwwwww ୈ26ճ೔ຊϓϩϞʔγϣϯاըίϯςετͰάϥ ϯϓϦ৆wwww ▸ όϑΝϦϯ ΢Σϒಈը޿ࠂ ެࣜwwwww

    ▸ ؟ڸࢢ৔ ެࣜww ςϨϏCM wwww ▸ ؟ڸࢢ৔ TVCM (2018) Χʔϓww Τϧwww ▸ ؟ڸࢢ৔ TVCM (2019) ϑϥϯεΞwwwwwww ▸ ࠓ೥ RCCதࠃ์ૹ(TBSܥ) ʰΠϚͳ·ͬ!ʱίϝϯςʔλwwww
  9. ͋ͱ਺ֶ͕ ޷͖

  10. ͱ͍͏Θ͚ Ͱ

  11. SageMathͰ ਺ֶͷ ྗΛ ্͛·͢

  12. SageMathͰ ਺ֶͷ ྗΛ ্͛·͢

  13. SageMathͰ ਺ֶͷ ྗΛ ্͛·͢ ͞ ͛ · ͢ ͋ ͛

    · ͢ ʊਓਓਓਓਓਓʊ ʼɹμδϟϨɹʻ ʉ̮̮̮̮̮̮ʉ
  14. SageMathͰ ਺ֶͷ ྗΛ ্͛·͢

  15. SageMathͰ ਺ֶͷ ྗΛ ্͛ΒΕͨΒɺ

  16. (ɾ㱼ɾ) ŘŘ!!

  17. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ

  18. ΋͏ͪΐͬͱ ৄ͘͠

  19. ຊ೔ͷϝχϡʔ 4BHFͱ͸ 4BHFΛେֶͷतۀͰซ༻ ༡ͼ΍ݚڀʹ

  20. օ͞Μ͸ ਺ֶେ޷͖

  21. Sageͱ͸

  22. Sage ▸ Φʔϓϯιʔεͷ਺ֶιϑτ΢ΣΞγεςϜ ▸ ͍ΖΜͳ਺ֶιϑτ΢ΣΞΛPythonͰ౷߹ ▸ GAP, Maxima, NumPy, SciPy,

    mathplotlib, Sympy, FLINT, R ▸ ϛογϣϯ: Mathematica ͱ͔ Maple, Matlab, Magmaͷ୅ସΛ࡞Δ͜ͱ
  23. ਺ࣜॲཧγε ςϜ

  24. ਺ࣜॲཧγεςϜ͸਺ࣜΛ਺ࣜͷ··ѻ͑Δ ▸ ුಈখ਺఺਺ͷۙࣅͰ͸ͳ͘୅਺ܭࢉ͕ͦͷ··Ͱ͖Δ ▸ ԁप཰Λͦͷ·· ▸ ؔ਺ͷඍ෼ੵ෼ͷΑ͏ͳ΋ͷͱ͔ ▸ ͳͲ

  25. ؆୯ʹࢼ͢

  26. ؆୯ʹࢼ͢ ▸ ΢Σϒ ▸ Sage Cell Server https://sagecell.sagemath.org/ ▸ CoCalc

    (چSageMathCloud) https://cocalc.com ▸ Πϯετʔϧ ▸ ϩʔΧϧʹ ▸ ίϚϯυϥΠϯͰ΋
  27. CoCalc ͍͢͝ɻ ▸ SageNotebook ▸ Jupyter Notebook ▸ Rmarkdown ▸

    ͚ͩ͡Όͳ͍ ▸ X11 ͱ͔΋Ͱ͖Δ
  28. Demo

  29. ͜Μͳײ͡ͷ΋ͷΛ ͓ݟͤ͠·ͨ͠ɻ

  30. ͜Μͳײ͡ͷ΋ͷΛ ͓ݟͤ͠·ͨ͠ɻ

  31. ຊ೔ͷϝχϡʔ 4BHFͱ͸ 4BHFΛେֶͷतۀͰซ༻ ༡ͼ΍ݚڀʹ

  32. ຊ೔ͷϝχϡʔ 4BHFͱ͸ 4BHFΛେֶͷतۀͰซ༻ ༡ͼ΍ݚڀʹ

  33. SageΛେֶͷ तۀͰซ༻

  34. SageΛେֶͷतۀͰซ༻ ▸ ޿ౡେֶͷڭҭֶ෦Ͱ਺ֶΛڭ͍͑ͯΔ ▸ ୅਺ֶܥͷೖ໳ߨٛͷҰ෦ Sage Λ࢖༻ͨ͠ ▸ ڭҭֶ෦Ͱɺதɾߴͷ਺ֶՊͷڭһ໔ڐΛऔΖ͏ͱ͢Δֶੜ ▸

    ͕ͬͭΓϓϩάϥϛϯάΛ͢Δਓ޲͚Ͱ͸ͳ͍ ▸ ͪΐͬͱίϚϯυΛଧͬͯΈͯܭࢉͤ͞Δ͙Β͍Ͱे෼ศར ▸ ʮߴڃి୎ʯͱͯ͠
  35. ྫ ▸ ഒ਺ is Կ? ▸ ໿਺ is Կ? ▸

    ࠷େެ໿਺ is Կ?
  36. ࠷େެ໿਺ ▸ ࠷େެ໿਺ greatest common divisor (GCD) ▸ (1) 12,

    18 ͷ࠷େެ໿਺͸? ▸ (2) 123456789 ͱ 987654321 ͷ࠷େެ໿਺͸? ▸ ΍Γํ ▸ ໿਺Λશ෦͍͋͛ͯ͘ ▸ ૉҼ਺෼ղͯ͠ڞ௨ͷૉҼ਺Λ͔͚Δ ▸ ϢʔΫϦουͷޓআ๏
  37. GCD΍Γํ͍Ζ͍Ζ ▸ ·ͣ͸खܭࢉͰख৮ΓײΛ ▸ खʹෛ͑ͳ͍ن໛͸ɺͦͷ͋ͱܭࢉػ࣮ݧ

  38. Demo

  39. ͜Μͳײ͡ͷ΋ͷΛ ͓ݟͤ͠·ͨ͠ɻ ૉҼ਺෼ղͷॏ͞ͷײ֮

  40. ͜͏͍͏ͱ͜Ζ͕ 4BHFΒ͍͠ ਺ֶιϑτ΢ΣΞΒ͍͠  XIJMFɻ OFYU@QSJNF ਺ Ͱ਺ΑΓେ͖͍ૉ਺Λฦ͢ ‏ʮΊͪΌͪ͘Ό଎͍ɻԿ͔͋Γͦ͏ͩͳʯͱٯʹࢥ͏

  41. ΞϧΰϦζϜͷҧ͍ ▸ खܭࢉʹՃ͑ͯ ▸ ܭࢉػ࣮ݧʹΑΓॏ͞ʹख৮ΓײΛಘΔ

  42. ָ͍͠!

  43. ຊ೔ͷϝχϡʔ 4BHFͱ͸ 4BHFΛେֶͷतۀͰซ༻ ༡ͼ΍ݚڀʹ

  44. ຊ೔ͷϝχϡʔ 4BHFͱ͸ 4BHFΛେֶͷतۀͰซ༻ ༡ͼ΍ݚڀʹ

  45. ༡ͼ΍ݚڀ ʹ

  46. ༡ͼ΍ݚڀʹSageΛ࢖͏࿩ ▸ ྫ Twitter ΑΓ

  47. ༡ͼ΍ݚڀʹSageΛ࢖͏࿩ ▸ ྫ Twitter ΑΓ

  48. ༡ͼ΍ݚڀʹSageΛ࢖͏࿩ ▸ ྫ Twitter ΑΓ ▸ ࣗવ਺ ʹରͯ͠
 
 ͕੔਺ͷͱ͖

    ͸ԿͰ͠ΐ͏͔ n 12502 + n3 n
  49. ͜͏͍͏ͷΛݟΔͱʮզʑʯ͸ɺ ʮପԁۂઢͷ࿩ͩͳʯ ͱɺࢥ͏ɻ ʮ͋ɺପԁۂઢͷ࿩ͩͳʯ

  50. ପԁۂઢ?

  51. ପԁۂઢ ▸ (ॏࠜͳ͠) Ͱఆٛ͞ΕΔʮۂઢʯ ▸ ΋ͷ͘͢͝ݚڀ͞Ε͍ͯΔɻݱࡏ΋ɻ ▸ ਺ֶతʹ͘͢͝ັྗతͳର৅ ▸ ઌ΄Ͳͷ໰୊ͩͱɺ

    ▸ Λ ͱ͓͍ͨΒɺ ▸ ͱ͍͏ପԁۂઢͷ্ͷ֨ࢠ఺ (੔਺఺) (࠲ඪ͕੔਺ʹͳ͍ͬͯΔ ఺) (ͷ͏ͪ ͷ΋ͷ) ΛٻΊΔ໰୊ y2 = xͷ3࣍ࣜ 12502 + n3 y y2 = 12502 + n3 y2 = x3 + 12502 x > 0
  52. ପԁۂઢ ▸ ͷ஥ؒͨͪ y2 = x3 + 12502 -4 -2

    0 2 4 -4 -2 0 2 4 y2 = x3 − x -4 -2 0 2 4 -4 -2 0 2 4 y2 = x3 + 1
  53. ପԁۂઢ ▸ ͷ஥ؒͨͪ ▸ ͜Ε͸ ͕࣮਺Λಈ͍ͨਤ ▸ ͜ͷதͰ ͕ͱ΋ʹ੔਺ʹͳΔ఺Λ୳͢ ▸

    ࣮͸δʔήϧͷఆཧʮପԁۂઢͷ੔਺ղ͸ৗʹ༗ݶݸʯ y2 = x3 + 12502 x, y x, y -4 -2 0 2 4 -4 -2 0 2 4 y2 = x3 − x -4 -2 0 2 4 -4 -2 0 2 4 y2 = x3 + 1
  54. SageͰପԁۂઢΛѻ͏ ▸ Λ΍Δ ▸ Weierstrassํఔࣜ ͩͱ EllipticCurve([a1,a2,a3,a4,a6]) Ͱ࡞ΕΔɻ ▸ ͷ

    লུܗ: EllipticCurve([a4,a6]) ▸ E = EllipticCurve([0,0,0,0,1562500]) ▸ E.integral_points() y2 = x3 + 12502 y2 + a1 xy + a3 y = x3 + a2 x2 + a4 x + a6 a1 = a2 = a3 = 0
  55. Demo

  56. None
  57. verbose=True ͢Δͱ్தͲΜͳܭࢉΛ͔ͨ͠ڭ͑ͯ͘Ε·͢

  58. Model-Weil܈(આ໌ུ)ͷੜ੒ݩ(આ໌ུ)ͱ͔΋Θ͔Δ

  59. SageͰପԁۂઢΛѻ͏ ▸ E.integral_points() ▸ [(-100 : 750 : 1),
 (0

    : 1250 : 1),
 (125 : 1875 : 1),
 (500 : 11250 : 1),
 (600 : 14750 : 1),
 (66500 : 17148750 : 1)] ▸ ౴͑ n = 125, 500, 600, 66500
  60. None
  61. ָ͍͠ ✌('ω'✌ )ࡾ✌('ω')✌ࡾ( ✌'ω')✌

  62. ·ͱΊ ▸ SageΛ࢖͏ͱ ▸ ਺ֶͷɺڭҭɾֶशɾݚڀͰ ▸ ໾ཱͭɾ༡΂Δ ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ

  63. ͔͜͜Β͸͕࣌ؒ͋Ε͹͓·͚ ▸ scheme ͱ͔ generic point ͱ͔Ψνͷ୅਺زԿͷΫϥε΋༻ҙ͞Ε͍ͯ Δɻ ▸ Try:

    ݚڀͰ࢖͓͏ͱͯ͠։ൃʹߩݙ͍ͨ͠ͱ͜Ζ͕Ͱ͖ͯͨͷͰߩݙ͢Δ ▸ ྫ΋͏Ұͭ
  64. ༡ͼ΍ݚڀʹSageΛ࢖͏࿩ ▸ ྫ Twitter ΑΓ (·ͨTwitter͔wwww)

  65. None
  66. Demo

  67. Python 3 ରԠͲ͏ͳͷ? ▸ ରԠ͍ͯ͠Δɻ ▸ Python3-compatible code - Sage

    Wiki https://wiki.sagemath.org/Python3-compatible%20code ࢀর ▸ ࠓޙ͸όΠφϦ΋ఏڙ༧ఆɻversion 8.8 ͷޙ͔ΒΒ͍͠ͷͰͦΖͦΖɻ ▸ CoCalcͰ͸ΧʔωϧͰબ΂·͢ɻ ▸ खಈϏϧυ͸
 $ make configure
 $ ./configure --with-python=3
 $ make build
 ͰOK
  68. ݱ୅਺ֶ΋͔ͳΓॆ࣮ ▸ scheme ͱ͔ generic point ͱ͔Ψνͷ୅਺زԿͷΫϥε΋༻ҙ͞Ε͍ͯΔ ▸ Points on

    projective varieties, Scheme morphism for points on projective varieties https:// github.com/sagemath/sage/blob/master/src/sage/schemes/projective/projective_point.py ▸ P = ProjectiveSpace(2, QQ) ←༗ཧ਺܎਺ͷࣹӨฏ໘͕͜ΕͰͰ͖Δ ▸ P(2, 3/5, 4) ←Pͷ্ͷ੪࣍࠲ඪ (2 : 3/5 : 4) ͷ఺ͷΦϒδΣΫτ͕͜ΕͰͰ͖Δ ▸ ࣹӨۭؒͷ఺ΛྻڍରԠʹ͔ͨͬͨ͠ɻ ▸ → ࠓޙ͸։ൃʹࢀՃ͍ͨ͠ɻ ▸ ChangeLog ΛݟΔͱ৽͍͠ίϯτϦϏϡʔλ͕ଟ਺!