A substance is said to be subject to exponential decay if it
Solution
The Matlab function expDecay.m
function Nt = expDecay(N0,L,t)
 % this function compute the quantity at time t using the
 % numerical solution of differentil equation given in the
 % problem using the matlab ode solver ode45
 [~,N] = ode45(@(t,x) -L*x,[0 t],N0);
 Nt= N(end);
 end
The Matlab function expDecay_exact.m
function Nt = expDecay_exact(N0,L,t)
 % this function compute the quantity at time t using the
 % exact solution of differential equation given in the
 % problem
 Nt = N0*exp(-L*t);
 end
The Matlab script test_case_of_decay.m
N0 = [10000 5500 9999 500]; % The intial values of N, N(0) for 4 test case
 L = [0.5 1 0.9 .3]; % four decay constants for four test case
 t = [3 1 2 .5]; % final time
 % Edit the above data for variaous test problems
 for k = 1:length(N0)
     futureQuantituy = expDecay(N0(k),L(k),t(k));
 fprintf(\'N0=%f, L=%f, t=%f, (ode45)Nt=%f, (exact)Nt=%f\ \',N0(k),L(k),t(k),futureQuantituy,expDecay_exact(N0(k),L(k),t(k)));
  end
OUTPUT
>> test_case_of_dacay
 N0=10000.000000, L=0.500000, t=3.000000, (ode45)Nt=2231.301692, (exact)Nt=2231.301601
 N0=5500.000000, L=1.000000, t=1.000000, (ode45)Nt=2023.336933, (exact)Nt=2023.336926
 N0=9999.000000, L=0.900000, t=2.000000, (ode45)Nt=1652.823794, (exact)Nt=1652.823583
 N0=500.000000, L=0.300000, t=0.500000, (ode45)Nt=430.353988, (exact)Nt=430.353988
 >>

