In [1]:
;type "lin_interp.jl"


LoadError: could not spawn `type lin_interp.jl`: no such file or directory (ENOENT)
while loading In[1], in expression starting on line 1

In [2]:
include("lin_interp.jl")


Out[2]:
call (generic function with 1093 methods)

In [3]:
grid = [0, 2, 4, 6, 8, 10]
vals = [1, 4, 5, 8, 9, 11]
f = my_lin_interp(grid,vals)


Out[3]:
my_lin_interp([0,2,4,6,8,10],[1,4,5,8,9,11])

In [4]:
println(f([3.5,10,-5,20]))


[4.75,11.0,0.0,0.0]

In [5]:
# 齊藤一織です。

In [6]:
g(x)=2 .*cos(6x) .+sin(14x) .+ 2.5


Out[6]:
g (generic function with 1 method)

In [7]:
c_grid = 0:.2:1


Out[7]:
0.0:0.2:1.0

In [8]:
Af = my_lin_interp(c_grid,g(c_grid))


Out[8]:
my_lin_interp([0.0,0.2,0.4,0.6,0.8,1.0],[4.5,3.5597036591092523,0.3939459310451876,1.5610820754199866,1.6958202377275753,5.410947928995602])

In [9]:
residual(x)=g(x)-Af(x)


Out[9]:
residual (generic function with 1 method)

In [10]:
using PyPlot


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

In [11]:
plot(f([0,1,2,3,4,5,6,7,8,9,10,11]),"b-")


Out[11]:
1-element Array{Any,1}:
 PyObject <matplotlib.lines.Line2D object at 0x000000001ECAB518>

In [17]:
plot(residual([-3,-2,-1,0,1,2,3]),"b-")


Out[17]:
1-element Array{Any,1}:
 PyObject <matplotlib.lines.Line2D object at 0x00000000010814A8>

In [ ]:


In [ ]: