SlideShare a Scribd company logo
1 of 25
Your logo
Wolfram Language コトハジメ
Noboru Wakabayashi
Mar. 19, 2016 @ dots / Shibuya
ヒューリンクス所属:株式会社 /執行役員
プログラマのための数学勉強会
2016 / 3 / 19 渋谷 dots.  Page 2
のセッション今日
 簡単な歴史:
 むかしむかし、イギリスに Stephen Wolfram という頭の良い少年がいました。彼
は物理が大好きで、12歳の時に自分で物理学の辞書を書きました。
最初の30分は、できるだけ商売抜きでお話します。
で、、、、最後の2分は本日のスポンサーとして、宣伝させてください。
Wolfram Language って聞いたことがあります?
 15歳になると彼は量子場理論と素粒子力学を研究し始めました。17歳で、
オックスフォード大学に入ったのですが、卒業することなく大西洋を渡ることを
決心しました。
 大陸を横断し、カリフォルニア工科大学に入りました。そこで彼は20歳で素粒
子力学において博士号をとりました(ファインマンらが指導)。そのままカリ
フォルニア工科大学の教授として研究を続けました。その後、イリノイ大学に移
り、教鞭をとっていました。
 Mathematica へ: カリフォルニア工科大学での研究の時に、自分が使う数式の
処理のために、現在の Mathematica の原型となる処理システムを作ったと言われ
ています。
Wolfram Language って聞いたことがあります? > つづき
 1986年にイリノイ大学を退職し、このシステムを販売するために Wolfram
Research という会社を作りました。
 1987年、 Stephen は NeXT にいた Steve Jobs と出会い、製品の話をしました。
Stephen が考えていた名前は Omega と PolyMath でしたが、 Jobs は「みにくい
名前だ」と言いました。 Sony Trinitron の名前を例に出して、 Jobs は
「 Mathematica 」という名前を提案し、それ以来、 Mathematica という名前に
なったとさ。
 続編: それから20年以上がたちました。 Mathematica はぐんぐん育ち、その
数学的機能も、計算能力もパソコンの中に収まりきらなくなりました。
 2010年代になって Mathematica の計算能力を活かした Computational
Engine 、 Wolfram|Alpha のサービスが開始しました。さらに世界は広が
り、 Mathematica で記述するための言語も、単なる数学の枠を超え始めたため、
その体系を Wolfram Language とよぶようになりました。
2016 / 3 / 19 渋谷 dots.  Page 3
で、 は の今日 何 話?
 Web ページを検索する検索エンジンではない
 なんか単語(英語)を入れると、データベース化されている「数値化されているデー
タ」から 何か情報を引っ張ってきてくれる
 「 Cheeseburger 」 >>> 何が返ってくる?
 「 Today 」 >>> 何が返ってくる?
 「 Triangle and circle 」 >>> 何が返ってくる?
 「 Triangle in a circle 」 に変えると???
 「 How many baseballs fit in a Boeing 747? 」
 自然言語的な記述で数式を解いてくれる。可視化してくれる
>> 例は次のページ から
Wolfram | Alpha でできること
まずは、軽いところで、 Woflram|Alpha で遊ぶ方法を見てみます。最近は、ちょ
っと難しいことをさせようとすると、「お金を払うバージョンにしてください」な
んていうようになってしまいましたが、無料で遊べる範囲で使ってみます。
2016 / 3 / 19 渋谷 dots.  Page 4
 次のようなグラフを書いてみます。
 「  plot x^3 - 6x^2 + 4x + 12  」
 に かしようとすると の次 何 有料 「 PRO にしろと ってくる  う む。。」版 言 ! ~
。
 もう少し違う関数で
 「  plot sin(x)/x  」
x3
-6 x2
+4 x+12
Sin(x)
x
2016 / 3 / 19 渋谷 dots.  Page 5
 んじゃ、次は3次元グラフ
 「  plot sin(x)*cos(y)  」
 インタラクティブには せない。回
 表示範囲もこんな感じで指定 (英語そのもの)
 「  plot sin(x)*cos(y)   from 0 to 10*pi 」
Sin(x) x Cos(y)
Sin(x) x Cos(x) (0<x<10π)
2016 / 3 / 19 渋谷 dots.  Page 6
 んじゃ、 Fourier Transform をさせてみる?
 「  Fourier transform ln(x)  」
 微積分
 「  Differential 4*x^3+5*x^2+2*x+7  」
 「  Integral 4*x^3+5*x^2+2*x+7  」
 構文を気にせず、ほぼ英語の自然言語で表現できるので、プログラミングをしている
感覚はない
 これが Wolfram Language ???
2016 / 3 / 19 渋谷 dots.  Page 7
…ではなくて
2016 / 3 / 19 渋谷 dots.  Page 8
Woflram Mathematica とか、 Mathematica Online
とかで使う、プログラミング言語のことを
「 Wolfram Language 」
と呼びます。
ここまで紹介してきた Wolfram Alpha も、
自然言語 ⇒  Wolfram Language
に変換して、 Mathematica のグリッド
版、 gridMathematica に食わせています。
2016 / 3 / 19 渋谷 dots.  Page 9
言語の特徴をわかりやすくするために、同じ
式やグラフを Wolfram Language と Python
で比べてみます。
問題は、 Mathematica にはお金がかかります
。その分、 Python よりも記述が楽。
(<少し商売を入れた)
* Python は numPy や SciPy を前提
2016 / 3 / 19 渋谷 dots.  Page 10
Mathematica は他のプログラミング言語で言
うところの IDE と思ってよいでしょう。
作成したファイルはノートブック( .nb )と呼
ばれます。
>>> つまり、自分でノートを書いて次々
と計算をさせていく感じ。思考と実証を繰り
返しながら、計算の目的地に到達するという
のがコンセプトです。
2016 / 3 / 19 渋谷 dots.  Page 11
2 次元の線グラフを書いてみる1 ( sin(x) )
Python
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(- 2*np.pi, 2*np.pi, 100)
y = np.sin(x)
plt.plot(x, y)
plt.axes()
plt.show()
2016 / 3 / 19 渋谷 dots.  Page 12
2 次元の線グラフを書いてみる1 ( sin(x) )
Wolfram Language
Plot[Sin[x], {x, -2*π, 2*π}]
ちょっと座標軸が違うが、まあ
こんな感じ
2016 / 3 / 19 渋谷 dots.  Page 13
実際の画面で実際の画面で
2 次元の線グラフを書いてみる2 ( a sin(b x) )
Python
前のページのコードに a と b を変化させるスライドバーと、その
移動にあわせてグラフを書くのは結構、行数を書く必要があります。
スライダーを書くだけでも:
Import wx
panel = wx.Panel(frame, wx.ID_ANY)
slider = wx.Slider(panel,
         style=wx.SL_HORIZONTAL)
な感じ。
a と b は定数だが、ダイナミックに変えて状態を確認したい
2016 / 3 / 19 渋谷 dots.  Page 14
2 次元の線グラフを書いてみる2 ( a sin(b x) )
Wolfram Language
Manipulate[Plot[a * Sin[b * x],
{x, -2*π, 2*π}], {a, 1, 3},
{b, 1, 4}]
の1行で OK 。これで a と b を可変にして
変化を見ることができる。
これは結構簡単。
a と b は定数だが、ダイナミックに変えて状態を確認したい
2016 / 3 / 19 渋谷 dots.  Page 15
実際の画面で実際の画面で
3次元のグラフを動かすぞ ( sin(a x) * cos (b y) )
Python
グラフが3次元になっても同じ。
a と b は定数だが、ダイナミックに変えて状態を確認したい
2016 / 3 / 19 渋谷 dots.  Page 16
3次元のグラフを動かすぞ ( sin(a x) * cos (b y) )
Wolfram Language
Manipulate[
Plot3D[Sin[a*x]*Cos[b*y],{x, 0, 6*π}, {y, 0, 6*π}],
{a, 1, 3}, {b, 1, 4}]
の1行で OK 。これで a と b を可変にして
変化を見ることができる。
スライダーが動いているときは、描画
速度を上げるために画像が荒くなった
りする。
a と b は定数だが、ダイナミックに変えて状態を確認したい
2016 / 3 / 19 渋谷 dots.  Page 17
実際の画面で実際の画面で
書く行数が少ないだけでなく、シンボリックに簡単
に計算できる
2016 / 3 / 19 渋谷 dots.  Page 18
a x2
+ bx + c = 0 を に を れないまま定数 数値 入 計算
Python
from sympy import *
a = Symbol(‘a’)
b = Symbol(‘b’)
c = Symbol(‘c’)
result = solve(a*x**2 + b*x + c, x)
print(result)
な感じ。結果は、
[(-b + sqrt(-4*a*c + b**2))/(2*a),
  -(b + sqrt(-4*a*c + b**2))/(2*a)]
書く行数が少ないだけでなく、シンボリックに簡単
に計算できる
Wolfram Language
Solve[a*x^2 + b*x + c ==0, x]
の1行で OK 。これで a と b と c をその
ままに計算ができる。
計算部分の書く行数はほぼ同じ。「これがシンボル
だよ」という宣言が Python では必要。
2016 / 3 / 19 渋谷 dots.  Page 19
実際の画面で実際の画面で
a x2
+ bx + c = 0 を に を れないまま定数 数値 入 計算
微分方程式を解いてみる ( y’(x)+y(x) = a sin(x) )
2016 / 3 / 19 渋谷 dots.  Page 20
Python
from sympy import *
a,x = symbols(‘a x’)
y = symbols(‘y’, cls=Fuction)
result = dsolve(Eq(y(x).diff(x)+y(x), a*sin(x)), y(x))
print(result)
な感じ。結果は、
y(x) == (C1 + a*(sin(x) - cos(x)
*exp(x)/2)*exp(-x)
微分方程式を解いてみる ( y’(x)+y(x) = a sin(x) )
Wolfram Language
DSolve[y’[x] + y[x] == a Sin[x], y[x], x]
の1行で OK 。
dsolve を実装しだしたのは、 Mathematica が先なんだろうな―、と
想像します。裏を取っていないので、信じないように。
2016 / 3 / 19 渋谷 dots.  Page 21
実際の画面で実際の画面で
ちなみに上の入力を Wolfram Alpha
に突っ込むと計算してくれたりする
Wolfram Language って、やたらと関数が多い。
>だからプログラムを短く書くことができる
なんでー、覚えるのが大変。。。
2016 / 3 / 19 渋谷 dots.  Page 22
以前に聞いたことがあります。。。
「頭のいい人は、関数を覚えられるから、短く書けるほう
が思考の邪魔をしない。
関数が少ないと、高度なことを計算させるときに、本質的
ではない細かなところで行をたくさん書く必要がある」
セッションはここで終わり
あと1~2分、宣伝につきあって!
2016 / 3 / 19 渋谷 dots.  Page 23
株式会社ヒューリンクス
今日紹介した Wolfram Mathematica を始め、科学
技術研究開発用ソフトを海外から輸入して開発してい
る会社です。
数学・統計・データ系でいうと:
Mathematica 、 Geometry Expressions,
KaleidaGraph 、 IGOR Pro
SigmaPlot 、 Pro Fortran 、 Predictive Modeler
2016 / 3 / 19 渋谷 dots.  Page 24
Noboru Wakabayashi
Thank you for your attention!
2016 / 3 / 19 渋谷 dots.  Page 25

More Related Content

Recently uploaded

LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイスCRI Japan, Inc.
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)Hiroshi Tomioka
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NTT DATA Technology & Innovation
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルCRI Japan, Inc.
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 

Recently uploaded (7)

LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

20160319 プログラマのための数学勉強会

  • 1. Your logo Wolfram Language コトハジメ Noboru Wakabayashi Mar. 19, 2016 @ dots / Shibuya ヒューリンクス所属:株式会社 /執行役員 プログラマのための数学勉強会
  • 2. 2016 / 3 / 19 渋谷 dots.  Page 2 のセッション今日  簡単な歴史:  むかしむかし、イギリスに Stephen Wolfram という頭の良い少年がいました。彼 は物理が大好きで、12歳の時に自分で物理学の辞書を書きました。 最初の30分は、できるだけ商売抜きでお話します。 で、、、、最後の2分は本日のスポンサーとして、宣伝させてください。 Wolfram Language って聞いたことがあります?  15歳になると彼は量子場理論と素粒子力学を研究し始めました。17歳で、 オックスフォード大学に入ったのですが、卒業することなく大西洋を渡ることを 決心しました。  大陸を横断し、カリフォルニア工科大学に入りました。そこで彼は20歳で素粒 子力学において博士号をとりました(ファインマンらが指導)。そのままカリ フォルニア工科大学の教授として研究を続けました。その後、イリノイ大学に移 り、教鞭をとっていました。
  • 3.  Mathematica へ: カリフォルニア工科大学での研究の時に、自分が使う数式の 処理のために、現在の Mathematica の原型となる処理システムを作ったと言われ ています。 Wolfram Language って聞いたことがあります? > つづき  1986年にイリノイ大学を退職し、このシステムを販売するために Wolfram Research という会社を作りました。  1987年、 Stephen は NeXT にいた Steve Jobs と出会い、製品の話をしました。 Stephen が考えていた名前は Omega と PolyMath でしたが、 Jobs は「みにくい 名前だ」と言いました。 Sony Trinitron の名前を例に出して、 Jobs は 「 Mathematica 」という名前を提案し、それ以来、 Mathematica という名前に なったとさ。  続編: それから20年以上がたちました。 Mathematica はぐんぐん育ち、その 数学的機能も、計算能力もパソコンの中に収まりきらなくなりました。  2010年代になって Mathematica の計算能力を活かした Computational Engine 、 Wolfram|Alpha のサービスが開始しました。さらに世界は広が り、 Mathematica で記述するための言語も、単なる数学の枠を超え始めたため、 その体系を Wolfram Language とよぶようになりました。 2016 / 3 / 19 渋谷 dots.  Page 3
  • 4. で、 は の今日 何 話?  Web ページを検索する検索エンジンではない  なんか単語(英語)を入れると、データベース化されている「数値化されているデー タ」から 何か情報を引っ張ってきてくれる  「 Cheeseburger 」 >>> 何が返ってくる?  「 Today 」 >>> 何が返ってくる?  「 Triangle and circle 」 >>> 何が返ってくる?  「 Triangle in a circle 」 に変えると???  「 How many baseballs fit in a Boeing 747? 」  自然言語的な記述で数式を解いてくれる。可視化してくれる >> 例は次のページ から Wolfram | Alpha でできること まずは、軽いところで、 Woflram|Alpha で遊ぶ方法を見てみます。最近は、ちょ っと難しいことをさせようとすると、「お金を払うバージョンにしてください」な んていうようになってしまいましたが、無料で遊べる範囲で使ってみます。 2016 / 3 / 19 渋谷 dots.  Page 4
  • 5.  次のようなグラフを書いてみます。  「  plot x^3 - 6x^2 + 4x + 12  」  に かしようとすると の次 何 有料 「 PRO にしろと ってくる  う む。。」版 言 ! ~ 。  もう少し違う関数で  「  plot sin(x)/x  」 x3 -6 x2 +4 x+12 Sin(x) x 2016 / 3 / 19 渋谷 dots.  Page 5
  • 6.  んじゃ、次は3次元グラフ  「  plot sin(x)*cos(y)  」  インタラクティブには せない。回  表示範囲もこんな感じで指定 (英語そのもの)  「  plot sin(x)*cos(y)   from 0 to 10*pi 」 Sin(x) x Cos(y) Sin(x) x Cos(x) (0<x<10π) 2016 / 3 / 19 渋谷 dots.  Page 6
  • 7.  んじゃ、 Fourier Transform をさせてみる?  「  Fourier transform ln(x)  」  微積分  「  Differential 4*x^3+5*x^2+2*x+7  」  「  Integral 4*x^3+5*x^2+2*x+7  」  構文を気にせず、ほぼ英語の自然言語で表現できるので、プログラミングをしている 感覚はない  これが Wolfram Language ??? 2016 / 3 / 19 渋谷 dots.  Page 7
  • 8. …ではなくて 2016 / 3 / 19 渋谷 dots.  Page 8
  • 9. Woflram Mathematica とか、 Mathematica Online とかで使う、プログラミング言語のことを 「 Wolfram Language 」 と呼びます。 ここまで紹介してきた Wolfram Alpha も、 自然言語 ⇒  Wolfram Language に変換して、 Mathematica のグリッド 版、 gridMathematica に食わせています。 2016 / 3 / 19 渋谷 dots.  Page 9
  • 10. 言語の特徴をわかりやすくするために、同じ 式やグラフを Wolfram Language と Python で比べてみます。 問題は、 Mathematica にはお金がかかります 。その分、 Python よりも記述が楽。 (<少し商売を入れた) * Python は numPy や SciPy を前提 2016 / 3 / 19 渋谷 dots.  Page 10
  • 11. Mathematica は他のプログラミング言語で言 うところの IDE と思ってよいでしょう。 作成したファイルはノートブック( .nb )と呼 ばれます。 >>> つまり、自分でノートを書いて次々 と計算をさせていく感じ。思考と実証を繰り 返しながら、計算の目的地に到達するという のがコンセプトです。 2016 / 3 / 19 渋谷 dots.  Page 11
  • 12. 2 次元の線グラフを書いてみる1 ( sin(x) ) Python import numpy as np import matplotlib.pyplot as plt x = np.linspace(- 2*np.pi, 2*np.pi, 100) y = np.sin(x) plt.plot(x, y) plt.axes() plt.show() 2016 / 3 / 19 渋谷 dots.  Page 12
  • 13. 2 次元の線グラフを書いてみる1 ( sin(x) ) Wolfram Language Plot[Sin[x], {x, -2*π, 2*π}] ちょっと座標軸が違うが、まあ こんな感じ 2016 / 3 / 19 渋谷 dots.  Page 13 実際の画面で実際の画面で
  • 14. 2 次元の線グラフを書いてみる2 ( a sin(b x) ) Python 前のページのコードに a と b を変化させるスライドバーと、その 移動にあわせてグラフを書くのは結構、行数を書く必要があります。 スライダーを書くだけでも: Import wx panel = wx.Panel(frame, wx.ID_ANY) slider = wx.Slider(panel,          style=wx.SL_HORIZONTAL) な感じ。 a と b は定数だが、ダイナミックに変えて状態を確認したい 2016 / 3 / 19 渋谷 dots.  Page 14
  • 15. 2 次元の線グラフを書いてみる2 ( a sin(b x) ) Wolfram Language Manipulate[Plot[a * Sin[b * x], {x, -2*π, 2*π}], {a, 1, 3}, {b, 1, 4}] の1行で OK 。これで a と b を可変にして 変化を見ることができる。 これは結構簡単。 a と b は定数だが、ダイナミックに変えて状態を確認したい 2016 / 3 / 19 渋谷 dots.  Page 15 実際の画面で実際の画面で
  • 16. 3次元のグラフを動かすぞ ( sin(a x) * cos (b y) ) Python グラフが3次元になっても同じ。 a と b は定数だが、ダイナミックに変えて状態を確認したい 2016 / 3 / 19 渋谷 dots.  Page 16
  • 17. 3次元のグラフを動かすぞ ( sin(a x) * cos (b y) ) Wolfram Language Manipulate[ Plot3D[Sin[a*x]*Cos[b*y],{x, 0, 6*π}, {y, 0, 6*π}], {a, 1, 3}, {b, 1, 4}] の1行で OK 。これで a と b を可変にして 変化を見ることができる。 スライダーが動いているときは、描画 速度を上げるために画像が荒くなった りする。 a と b は定数だが、ダイナミックに変えて状態を確認したい 2016 / 3 / 19 渋谷 dots.  Page 17 実際の画面で実際の画面で
  • 18. 書く行数が少ないだけでなく、シンボリックに簡単 に計算できる 2016 / 3 / 19 渋谷 dots.  Page 18 a x2 + bx + c = 0 を に を れないまま定数 数値 入 計算 Python from sympy import * a = Symbol(‘a’) b = Symbol(‘b’) c = Symbol(‘c’) result = solve(a*x**2 + b*x + c, x) print(result) な感じ。結果は、 [(-b + sqrt(-4*a*c + b**2))/(2*a),   -(b + sqrt(-4*a*c + b**2))/(2*a)]
  • 19. 書く行数が少ないだけでなく、シンボリックに簡単 に計算できる Wolfram Language Solve[a*x^2 + b*x + c ==0, x] の1行で OK 。これで a と b と c をその ままに計算ができる。 計算部分の書く行数はほぼ同じ。「これがシンボル だよ」という宣言が Python では必要。 2016 / 3 / 19 渋谷 dots.  Page 19 実際の画面で実際の画面で a x2 + bx + c = 0 を に を れないまま定数 数値 入 計算
  • 20. 微分方程式を解いてみる ( y’(x)+y(x) = a sin(x) ) 2016 / 3 / 19 渋谷 dots.  Page 20 Python from sympy import * a,x = symbols(‘a x’) y = symbols(‘y’, cls=Fuction) result = dsolve(Eq(y(x).diff(x)+y(x), a*sin(x)), y(x)) print(result) な感じ。結果は、 y(x) == (C1 + a*(sin(x) - cos(x) *exp(x)/2)*exp(-x)
  • 21. 微分方程式を解いてみる ( y’(x)+y(x) = a sin(x) ) Wolfram Language DSolve[y’[x] + y[x] == a Sin[x], y[x], x] の1行で OK 。 dsolve を実装しだしたのは、 Mathematica が先なんだろうな―、と 想像します。裏を取っていないので、信じないように。 2016 / 3 / 19 渋谷 dots.  Page 21 実際の画面で実際の画面で ちなみに上の入力を Wolfram Alpha に突っ込むと計算してくれたりする
  • 22. Wolfram Language って、やたらと関数が多い。 >だからプログラムを短く書くことができる なんでー、覚えるのが大変。。。 2016 / 3 / 19 渋谷 dots.  Page 22 以前に聞いたことがあります。。。 「頭のいい人は、関数を覚えられるから、短く書けるほう が思考の邪魔をしない。 関数が少ないと、高度なことを計算させるときに、本質的 ではない細かなところで行をたくさん書く必要がある」
  • 24. 株式会社ヒューリンクス 今日紹介した Wolfram Mathematica を始め、科学 技術研究開発用ソフトを海外から輸入して開発してい る会社です。 数学・統計・データ系でいうと: Mathematica 、 Geometry Expressions, KaleidaGraph 、 IGOR Pro SigmaPlot 、 Pro Fortran 、 Predictive Modeler 2016 / 3 / 19 渋谷 dots.  Page 24
  • 25. Noboru Wakabayashi Thank you for your attention! 2016 / 3 / 19 渋谷 dots.  Page 25