In [1]:
Pkg.add("ApproxFun")
INFO: Nothing to be done
INFO: METADATA is out-of-date — you may not have the latest version of ApproxFun
INFO: Use `Pkg.update()` to get the latest versions of your packages
In [2]:
using ApproxFun # this can take a while!
In [3]:
using Plots
In [5]:
x = Fun(x -> x,[-1,1])
Out[5]:
Fun([0.0,1.0],Chebyshev(【-1.0,1.0】))
In [6]:
f = 1/(1+x^2)
Out[6]:
Fun([0.707107,-0.0,-0.242641,-0.0,0.0416306,-0.0,-0.00714267,-0.0,0.00122549,-0.0  …  -0.0,7.97425e-13,-0.0,-1.36791e-13,-0.0,2.3356e-14,-0.0,-3.56718e-15,-0.0,-6.60728e-16],Chebyshev(【-1.0,1.0】))
In [7]:
plot(f)
[Plots.jl] Initializing backend: pyplot
WARNING: No working GUI backend found for matplotlib.
Out[7]:
In [8]:
# f is a polynomial at Chebyshev points.
length(f.coefficients)
Out[8]:
41
In [9]:
g = f+x
plot(g)
Out[9]:
In [10]:
plot(g') # this is the derivative!
Out[10]:
In [11]:
gppppp = differentiate(g, 5)
plot(gppppp)
Out[11]:
In [12]:
maximum(gppppp)
Out[12]:
100.45898286233134
In [15]:
h = sin(g)

plot(h)
Out[15]:
In [18]:
z = abs(g)
Out[18]:
Fun([0.252746,0.91977,-0.250122,0.723114,-0.00276592,-0.189732,0.000121404,0.0321735,1.96552e-5,0.0221218  …  -2.61423e-17,-6.6267e-13,1.0833e-17,1.15536e-13,2.31786e-17,7.74296e-14,-2.90731e-17,-2.20361e-14,0.0,-8.79252e-15],Chebyshev(【-1.0,-0.6823278038280207】)⨄Chebyshev(【-0.6823278038280207,1.0】))
In [18]:
roots(h + z)
Out[18]:
0-element Array{Float64,1}
In [19]:
plot(h+z)
Out[19]:
In [20]:
roots(h+z-1)
Out[20]:
1-element Array{Float64,1}:
 0.109765
In [20]:
plot(cumsum(h+z-1)) # this is the integral!
Out[20]:
In [21]:
sum(h+z-1)
Out[21]:
0.938578933117223
In [22]:
k = h+z-1
length(k.coefficients)
Out[22]:
71
In [33]:
f = min(x,x^3)
plot(f)
Out[33]:
In [40]:
plot(sqrt(cumsum(f^2)))
Out[40]:
In [41]:
norm(f)
Out[41]:
0.6900655593423543
In [42]:
sqrt(sum(f^2)) # this is integration!
Out[42]:
0.6900655593423543