I need help with this excercise : Find $k$(speed constant ) $$\frac{dx}{dt}=k(a-x)^2)$$ with data , $$t[min]=[0, 2.5, 5.6 ,9.6 ,14.6, 21.5, 32.5, 52.2]$$ ;
$(a-x)$ (mol/l) = [$0.0050$ (if x=0), $0.0045$ , $0.0040,0.0035,0.0030,0.0025,0.0020,0.0015]$
I´ve tried next steps:
Command W. :
$$t=[0 , 2.5, 5.6 , 9.6 , 14.6, 21.5 , 32.5 , 52.2];$$
$$x=[0:0.0005:0.0035];$$
$$a=0.0050;$$
$$c=a-x;$$
Editor ( my skript):
function $$dx=f(t,x)$$
$$dx=k*.((a-x).^2)$$
$$end + Run$$
Command W. :
$$tspan=0:0.0005:0.0035;$$
$$[x,t]=ode45(f,[0:0.0005:0.0035],0)$$
I don´t know how to find k
Your ODE is separable and has as solution
$$ x(t) = \frac{a k t -1 + a c_0}{k t + c_0} $$
then one way to obtain the best fit to $k$ is by solving the following minimization problem
$$ \min_{k,c_0}\sum_{j=1}^n(a-x(t_j)-\delta_j)^2 $$
with
$$ \cases{ a = 0.0050\\ n = 8\\ t_j = \{0,2.5,5.6,9.6,14.6,21.5,32.5,52.2\}\\ \delta_j=\{0.0050,0.0045,0.0040,0.0035,0.0030,0.0025,0.0020,0.0015\} } $$
NOTE
If $x(0) = 0$ then
$$ x(t) = \frac{a^2k t}{a k t+1} $$
and now the minimization reads
$$ \min_{k}\sum_{j=1}^n\left(a-\frac{a^2k t_j}{a k t_j+1}-\delta_j\right)^2 $$