# Neke funkcije iz biologije i kemije

## Von Bertalanffyjeva funkcija

L(t):=A-B*exp(-k*t);

L(t);

L(0);

diff(L(t),t);

limit(L(t),t,inf);

assume(k>0);

limit(L(t),t,inf);

diff(L(t),t,2);

A: L_inf;

solve(L(0)=L_0,B);

B: L_inf-L_0;

L(t);

L(t), A=100, B=90;

with_slider_draw(k,makelist(0.2*k,k,1,10),yrange=[0,110],axis_left=false,axis_top=false,axis_bottom=false,xtics=false,
    ytics={["10",10],["100",100]},axis_right=false,xaxis=true,xaxis_type=solid,xtics_axis=true,ytics_axis=true,yaxis=true,
    yaxis_type=solid,title=concat("k=",float(round(k*10)/10)),explicit(100-90*%e^(-k*t),t,0,6),color=black,line_type=dots,
    parametric(t,100,t,0,6));

## Monodova funkcija

kill(A,B);

f(s):=A*s/(s+B);

f(0);

diff(f(s),s);

factor(%);

diff(f(s),s,2);

factor(%);

limit(f(s),s,inf);

f(B);

A: 10;

f(s);

with_slider_draw(B,makelist(0.5*(12-B)^2,B,1,10),yrange=[0,11],axis_left=false,axis_top=false,axis_bottom=false,
    xtics={["B",B]},ytics={["A/2",A/2],["A",A]},axis_right=false,xaxis=true,xaxis_type=solid,xtics_axis=true,
    ytics_axis=true,yaxis=true,yaxis_type=solid,explicit(10*s/(s+B),s,0,100),color=black,line_type=dots,
    parametric(t,A,t,0,100),parametric(t,A/2,t,0,B),parametric(B,t,t,0,A/2),title=concat("B=",float(round(B*10)/10)));

## Logistička funkcija

f(t):=1/(1+exp(-t));

wxplot2d(f(t),[t,-5,5]);

f(t):=K/(1+C*exp(-r*t));

f(t);

assume(r>0);

limit(f(t),t,inf);

limit(f(t),t,-inf);

diff(f(t),t);

diff(f(t),t,2);

factor(%);

solve(diff(f(t),t,2)=0,t);

f(t),t=log(C)/r;

f(t),K=1,C=1;

with_slider_draw(r,makelist(0.5*r,r,1,10),yrange=[0,1.1],axis_left=false,axis_top=false,axis_bottom=false,xtics=false,
    ytics={["K",1],["K/2",0.5]},axis_right=false,xaxis=true,xaxis_type=solid,xtics_axis=true,ytics_axis=true,yaxis=true,
    yaxis_type=solid,title=concat("r=",float(round(r*10)/10)),explicit(1/(%e^(-r*t)+1),t,-5,5),color=black,line_type=dots,
    parametric(t,1,t,-5,5));

f(t),K=1,r=1;

with_slider_draw(C,makelist(0.2*C,C,1,20),yrange=[0,1.1],axis_left=false,axis_top=false,axis_bottom=false,xtics=false,
    ytics={["K",1],["K/2",0.5]},axis_right=false,xaxis=true,xaxis_type=solid,xtics_axis=true,ytics_axis=true,yaxis=true,
    yaxis_type=solid,title=concat("C=",float(round(C*10)/10)),explicit(1/(C*%e^(-t)+1),t,-5,5),color=black,line_type=dots,
    parametric(t,1,t,-5,5),xtics={["t_0",log(C)]},parametric(log(C),t,t,0,0.5),parametric(t,0.5,t,-5,5));

## Gompertzova funkcija

f(t):=K*exp(-a*exp(-b*t));

f(t);

assume(a>0,b>0);

limit(f(t),t,inf);

limit(f(t),t,-inf);

diff(f(t),t);

diff(f(t),t,2);

factor(%);

solve(diff(f(t),t,2)=0,t);

f(t),t=log(a)/b;

f(t),K=1,a=1;

with_slider_draw(b,makelist(0.2*b,b,1,10),yrange=[0,1.1],axis_left=false,axis_top=false,axis_bottom=false,xtics=false,
    ytics={["K",1],["K/e",exp(-1)]},axis_right=false,xaxis=true,xaxis_type=solid,xtics_axis=true,ytics_axis=true,yaxis=true,
    yaxis_type=solid,title=concat("b=",float(round(b*10)/10)),explicit(%e^(-%e^(-b*t)),t,-5,5),color=black,line_type=dots,
    parametric(t,1,t,-5,5));

f(t),K=1,b=1;

with_slider_draw(a,makelist(0.2*a,a,1,20),yrange=[0,1.1],axis_left=false,axis_top=false,axis_bottom=false,xtics=false,
    ytics={["K",1],["K/e",exp(-1)]},axis_right=false,xaxis=true,xaxis_type=solid,xtics_axis=true,ytics_axis=true,yaxis=true,
    yaxis_type=solid,title=concat("a=",float(round(a*10)/10)),explicit(%e^(-a*%e^(-t)),t,-5,5),color=black,line_type=dots,
    parametric(t,1,t,-5,5),xtics={["t_0",log(a)]},parametric(log(a),t,t,0,exp(-1)),parametric(t,exp(-1),t,-5,5));

## Levakovićeva funkcija

f(t):=a*(t/(b+t))^c;

f(0);

limit(f(t),t,inf);

diff(f(t),t);

radcan(%);

factor(%);

diff(%,t);

factor(%);

solve(diff(f(t),t,2)=0,t);

factor(%);

f(b*(c-1)/2);

factor(%);

f(t), a=1, b=1;

with_slider_draw(c,makelist(c,c,1,20,0.5),yrange=[0,1.1],axis_left=false,axis_top=false,axis_bottom=false,xtics=false,
    axis_right=false,xaxis=true,xaxis_type=solid,xtics_axis=true,ytics_axis=true,yaxis=true,ytics={["a",1]},
    yaxis_type=solid,title=concat("c=",float(round(c*10)/10)),explicit((t/(t+1))^c,t,0,10),color=black,line_type=dots,
    parametric(t,1,t,0,10),xtics={["t_0",(c-1)/2]},parametric((c-1)/2,t,t,0,((c-1)/(c+1))^c),
    parametric(t,((c-1)/(c+1))^c,t,0,(c-1)/2));

limit(a*((c-1)/(c+1))^c,c,inf);

f(t), a=1, c=3;

solve(diff(%,t,2)=0,t);

f(b), a=1, c=3;

with_slider_draw(b,makelist(b,b,0.04,1.5,0.05),yrange=[0,1.1],axis_left=false,axis_top=false,axis_bottom=false,xtics=false,
    ytics={["a",1]},axis_right=false,xaxis=true,xaxis_type=solid,xtics_axis=true,ytics_axis=true,yaxis=true,
    yaxis_type=solid,title=concat("b=",float(round(b*100)/100)),explicit(t^3/(t+b)^3,t,0,10),color=black,line_type=dots,
    parametric(t,1,t,0,10),xtics={["t_0",b]},parametric(b,t,t,0,1/8),parametric(t,1/8,t,0,b));