function [q,v]=trinomial(p,s0,r,u)
%outputs the value of the trinomial tree v and corresponding probabilities q
v=s0*[u^2 u 1 1/u 1/u^2];
q=[ p(1)*p(2) p(1)*(1-2*p(2))+(1-2*p(1))*p(2)];
q=[q p(1)*(p(2)+p(4))+(1-2*p(1))*(1-2*p(3)) ];
q=[q p(1)*(1-2*p(4))+(1-2*p(1))*p(3) p(1)*p(4)];


