In [45]:
#課題1 修正版  高橋 雅士 
#関数の定義はここ https://github.com/masashitshit/Interpolations.jl/blob/master/src/Interpolations.jl")
using Interpolations

In [46]:
grid = [1,2]
vals = [2,0]


Out[46]:
2-element Array{Int64,1}:
 2
 0

In [47]:
f = linerinterp(grid,vals)


Out[47]:
(::funfun) (generic function with 1 method)

In [48]:
f(1.25)


Out[48]:
1.5

In [49]:
using Plots


WARNING: using Plots.grid in module Main conflicts with an existing identifier.

In [50]:
plotlyjs()


Plotly javascript loaded.

To load again call

init_notebook(true)

WARNING: Method definition describe
Out[50]:
Plots.PlotlyJSBackend()
(AbstractArray) in module StatsBase at C:\Users\Masashi Takahashi\.julia\v0.5\StatsBase\src\scalarstats.jl:573 overwritten in module DataFrames at C:\Users\Masashi Takahashi\.julia\v0.5\DataFrames\src\abstractdataframe\abstractdataframe.jl:407.

In [51]:
grid2 = -5:5              #cosxを線形補間してみる
vals2 = cos(grid2)
f = linerinterp(grid2,vals2)

grid3 =linspace(-5, 5,1000)
vals3 = cos(grid3)


Out[51]:
1000-element Array{Float64,1}:
 0.283662
 0.274049
 0.264409
 0.254742
 0.24505 
 0.235333
 0.225592
 0.215829
 0.206044
 0.196239
 0.186414
 0.17657 
 0.166709
 ⋮       
 0.17657 
 0.186414
 0.196239
 0.206044
 0.215829
 0.225592
 0.235333
 0.24505 
 0.254742
 0.264409
 0.274049
 0.283662

In [52]:
plot(f)
plot!(grid3,vals3)


Out[52]:

In [53]:
grid = -5:5                  #sinxを線形補間してみる
vals = sin(grid)
f = linerinterp(grid,vals)

grid1 =linspace(-5, 5,1000)
vals1 = sin(grid1)


Out[53]:
1000-element Array{Float64,1}:
  0.958924
  0.961716
  0.964411
  0.967009
  0.969511
  0.971915
  0.974222
  0.976431
  0.978543
  0.980556
  0.982471
  0.984288
  0.986006
  ⋮       
 -0.984288
 -0.982471
 -0.980556
 -0.978543
 -0.976431
 -0.974222
 -0.971915
 -0.969511
 -0.967009
 -0.964411
 -0.961716
 -0.958924

In [54]:
plot(f)
plot!(grid1,vals1)


Out[54]:

In [ ]: