You are on page 1of 1

Ejemplo de julia

1 # Programando con Julia


2
3 using DifferentialEquations
4 f(u, p, t) = 0.98u
5 u0 = 1.0
6 tspan = (0.0, 1.0)
7 prob = ODEProblem(f, u0, tspan)
8 sol=solve(prob,abstol=1e-8,reltol=1e-8)
9 solpre=solve(prob)
10
11 using Plots, LaTeXStrings; gr()
12
13 plot(sol,linewidth=3,title="Solution to the linear ODE with a thick line",
14 xaxis="Time (t)", yaxis="u(t) (in µm )",label="My ODE solution with
15 reltol & abstol")
16
17 plot!(solpre.t, t->1.0*exp(0.98t),lw=3,ls=:dash,label="True Solution")
18
19 plot!(solpre,lw=3,ls=:dot,label="My ODE solution")

You might also like