# Exercici 12.12

kill(all)$

x*(50/100 - (30-x)/100);

Dy(t)=k*x*(50/100 - (30-x)/100);

(1/(1/2-(30-x)/100)*x)*Dy(t)=k;

1/2-(30-x)/100;

expand(%);

ratsimp(%);

partfrac(1/(x*(x+20)) , x);

EDO_a:  (1/(20*x)-1/(20*(x+20)))*'diff(x,t) = k/100 ;

ode2(EDO_a, x, t);

log(x/(x+20))=k*t/5 + C;

Eq1: x/(x+20)=C1*exp(k*t/5);

solve(Eq1, x);

x(t):= (20*C1*%e^(k*t/5))/(1 - C1*%e^(k*t/5)) ;

x(0);

Eq2: 30 = (20*C1)/(1-C1) ;
solve( [Eq2], [C1]);

C1=C1:3/5;

x(t);

x1(t):= (12*%e^((k*t)/5))/(1-(3*%e^((k*t)/5))/5) ;

x1(2);

Eq3:  20 = (12*%e^((2*k)/5))/(1-(3*%e^((2*k)/5))/5)  ;
solve( [Eq3], [k]);

k=k:5*log(sqrt(5)/sqrt(6)), numer;

x1(t);

wxplot2d([x1(t)], [t,0,6], [y,0,30] , [ylabel, ""] , [legend, "x1(t)"] , [style, [lines, 2]] ,
 [gnuplot_preamble, "set grid; set zeroaxis;"])$

x1(5);

30 - x1(5);