In [1]:
using ApproxFun
using Plots


## We are going to look at approximations to this function!¶

In [15]:
x = Fun(identity,[-1,1.])
f = x
plot(f)

Out[15]:
In [22]:
x = Fun(identity,[-1,1.])
f = x
pole = 1.5
g = Fun( x -> x + 0.01*sin(5*2*pi*x./((x-pole).*(x+pole))) )
plot([f,differentiate(f),g,differentiate(g)],layout=(2,1))
title!("f, g and df, dg")

Out[22]:

## But this can be very ill-conditioned!¶

In [30]:
x = Fun(identity,[-1,1.])
f = x
pole = 1.0005
perb = 0.0001
g = Fun( x -> x + perb*sin(5*2*pi*x./((x-pole).*(x+pole))) )
plot([f,differentiate(f),g,differentiate(g)],layout=(2,1))
title!("f, g and df, dg")
yaxis!([0.95,1.05])

Out[30]: