Julia test page

Author

Mark Holmes

Published

June 5, 2024

Code
println(1 + 2)
3
Code
using GLMakie, LaTeXStrings

function logistic_map(x, r)
    return r * x * (1.0 - x)
end

function simulate!(out, r, x0)
    out[1] = x0
    for i in 2:length(out)
        out[i] = logistic_map(out[i-1], r)
    end
    return out
end

tsteps = 100
out = Vector{Float64}(undef, tsteps + 1)

begin
    f = Figure()
    
    Axis(f[1, 1], limits = (0, tsteps + 1, -0.05, 1.05), xlabel = "Time", ylabel = "x")

    sg = SliderGrid(
        f[2, 1],
        (label = L"x_0", range = LinRange(0, 1, 201), format = "{:.2f}", startvalue = 0.1),
        (label = L"r", range = LinRange(0, 5, 201), format = "{:.2f}", startvalue = 1.0))

    x0_obs, r_obs = [s.value for s in sg.sliders]

    trajectory = lift(x0_obs, r_obs) do x0, r
        simulate!(out, r, x0)
    end

    lines!(trajectory)

    f    
end
┌ Warning: Found `resolution` in the theme when creating a `Scene`. The `resolution` keyword for `Scene`s and `Figure`s has been deprecated. Use `Figure(; size = ...` or `Scene(; size = ...)` instead, which better reflects that this is a unitless size and not a pixel resolution. The key could also come from `set_theme!` calls or related theming functions.
└ @ Makie ~/.julia/packages/Makie/We6MY/src/scenes.jl:227