Beginner really needs help with Maxima's basic concepts




On Tue, 10 Nov 2009, Julien Martin wrote:

< Hello,
< 
< I am working on the binomial model and my example is based on that but really my question relates to Maxima's basic concepts.
< 
< Here is my example:
< 
< I have %Delta and p defined as follows:
< 
< %Delta:(fu-fd)/(S0*u-S0*d); (1)
< 
< p:(exp(r*T)-d)/(u-d); (2)
< 
< I need to have the following expression (3) simplified by replacing the %Delta with the expression given above in (1) and expressed in terms of p as defined above
< in (2)...
< 
< f:S0*%Delta*(1-u*exp(-r*T))+fu*exp(-r*T); (3)
< 
< ...so that I would ideally get this:
< 
< f:exp(-r*T)*(p*fu + (1-p) * fd); (4)
< 
< Is this possible? Can someone please help?
< 
< Julien.
< 
< 

Julien,
I think the key to the problem is to model your own
manipulations. To subst p into f, you need to solve for %e^(r*T) 
in terms of p:

(%i2) f:S0*%Delta*(1-u*exp(-r*T))+fu*exp(-r*T);

(%o2) %Delta*S0*(1-u*%e^-(r*T))+fu*%e^-(r*T)
(%i3) %Delta:(fu-fd)/(S0*u-S0*d);

(%o3) (fu-fd)/(u*S0-d*S0)
(%i4) p:(exp(r*T)-d)/(u-d);

(%o4) (%e^(r*T)-d)/(u-d)
(%i5) peq : solve(p='p,exp(r*T));

(%o5) [%e^(r*T) = p*u-d*p+d]
(%i6) f;

(%o6) %Delta*S0*(1-u*%e^-(r*T))+fu*%e^-(r*T)
(%i7) rpeq : 1/peq;

(%o7) [%e^-(r*T) = 1/(p*u-d*p+d)]
(%i8) subst(rpeq,f);

(%o8) %Delta*(1-u/(p*u-d*p+d))*S0+fu/(p*u-d*p+d)
(%i9) subst(rpeq,''f);

(%o9) (fu-fd)*(1-u/(p*u-d*p+d))*S0/(u*S0-d*S0)+fu/(p*u-d*p+d)
(%i10) rat(%);

(%o10) ((fu-fd)*p+fd)/(p*u-d*p+d)
(%i11) subst(rhs(peq[1])=lhs(peq[1]),%);

(%o11) ((fu-fd)*p+fd)*%e^-(r*T)

This final expression is almost what you want. 

(%i12) collectterms(expand(part(%o11,1)),fu,fd);

(%o12) fu*p+fd*(1-p)
(%i13) %*part(%o11,2);

(%o13) (fu*p+fd*(1-p))*%e^-(r*T)

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.