Skip to content

Instantly share code, notes, and snippets.

@ceptreee
Created April 6, 2018 08:45
Show Gist options
  • Save ceptreee/fb4fa937d588d2364fca395a307404c5 to your computer and use it in GitHub Desktop.
Save ceptreee/fb4fa937d588d2364fca395a307404c5 to your computer and use it in GitHub Desktop.
using Plots; gr();
ENV["PLOTS_TEST"] = "true"
using IntervalArithmetic
N = 27
x0 = @interval(0.11)
x0_sol = 0.11
f(x) = 4*x*(1-x)
sol(n, x0) = ( 1 - cos(2^n * acos(1-2x0) ) ) / 2
x_sol = sol.(1:N, x0_sol)
xhi = zeros(N)
xlo = zeros(N)
x = x0
for n in 1:N
x = f(x)
xhi[n] = x.hi
xlo[n] = x.lo
end
plot(1:N, xlo, label="lo", ls=:dash)
plot!(1:N, xhi, label="hi", ls=:dash)
plot!(1:N, x_sol, label="exact")
savefig("IA.png")
using Plots; gr();
ENV["PLOTS_TEST"] = "true"
using IntervalArithmetic
setprecision(Interval,500)
N = 251
x0 = @interval(0.11)
x0_sol = big"0.11"
f(x) = 4*x*(1-x)
sol(n, x0) = (big"1" - cos(big"2"^n*acos(big"1"-big"2"*x0)))/big"2"
x_sol = sol.(1:N, x0_sol)
xhi = zeros(N)
xlo = zeros(N)
x = x0
for n in 1:N
x = f(x)
xhi[n] = x.hi
xlo[n] = x.lo
end
plot(1:N, xlo, label="lo", ls=:dash)
plot!(1:N, xhi, label="hi", ls=:dash)
plot!(1:N, x_sol, label="exact")
savefig("IA_500.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment