Day 24

Solving non-linear differential equations

Definition of the initial value problem

This is some work related to Jim's project. We are solving an initial value problem.

beta = .1gamma = .1end = 30\(a[t_] = Exp[\(-\ gamma\)\ t]; 
Plot[a[t], \ {t, 0, end}]; \)

Establish our given input:

solution = 
      NDSolve[{x'[t] == a[x[t]] x[t]^.25 - beta x[t]^.8, x[0] == 20}, 
        x[t], {t, 0, end},  Method -> RungeKutta]sol[t_]  =  x[t] /. solution[[1]]Plot[sol[t],  {t, 0, end}];

Let's make a plot of several solutions, using different initial values:

Clear[s]; \(s[i_] := 
      \((
		Clear[solution, \ sol, t]; 
		
        solution = 
          NDSolve[{\(x'\)[t] == a[x[t]]\ x[t]^.25 - beta\ x[t]^.8, 
              x[0] == i}, x[t], {t, 0, end}, \ Method -> RungeKutta]; 
		
        sol[t_]\  = \ x[t] /. solution[\([1]\)]; 
		
        Plot[sol[t], \ {t, 0, end}, DisplayFunction -> Identity]
	)\); 
    
Show[Table[s[i], {i, 1, 20}], DisplayFunction -> $DisplayFunction, 
      \ PlotRange -> {0, 20}]; \)

Now we're going to solve the non-linear system of the SIR model:

mu = .01U = .03beta = .5gamma = .2c = 1

goto = 500NDSolve[{x'[t]==U - x[t] 
                  (mu  + beta c y[t]/(x[t]  + z[t]  + y[t])),y'[t]==x[t] y[t] beta c /(x[t]  + z[t]  + y[t]) - 
                (mu + gamma) y[t],z'[t]==-mu z[t] + gamma y[t],x[0] == 1,y[0] == .5,z[0] == 0},{x, y, z},{t, 0, goto},MaxSteps -> 30000]ParametricPlot3D[Evaluate[{x[t], y[t], z[t]} /. %], {t, 0, goto}, 
      PlotPoints -> 10000, ViewPoint -> {1, 2, 2}];