Beginner really needs help with Maxima's basic concepts
Subject: Beginner really needs help with Maxima's basic concepts
From: Leo Butler
Date: Sat, 14 Nov 2009 08:48:48 +0000 (GMT)
On Sat, 14 Nov 2009, Julien Martin wrote:
< Thanks a lot to you too Eric!
<
< I am also experiencing difficulties with the syntax of your:
< s:solve([F-f,P-p],[F,u,d]);?
< ss:s[2][1];
<
< Can you please describe in English what the above two line mean - if and when you have the time to do so of course :-)
Eric has used solve to do most of the hard work in one go.
The idea is to treat your declarations as equations to be
solved.
%Delta:(fu-fd)/(S0*u-S0*d)$
p:(exp(r*T)-d)/(u-d)$
f:S0*%Delta*(1-u*exp(-r*T))+fu*exp(-r*T)$
/* F & P are undeclared */
solve([F=f,P=p],[F,u,d]);
(%o10) [[F = %r3,u = %e^(r*T),d = %e^(r*T)],
[F = ((fu-fd)*P+fd)*%e^-(r*T),u = %r4,d = -(%e^(r*T)-%r4*P)/(P-1)]]
/* The solution list is a 2 element list, each element
is itself a 3 element list. Let's see what the first list's
second element is:*/
(%i11) %[1][2];
(%o11) u = %e^(r*T)
/* Let's get F from the second list */
(%i12) %o10[2][1];
(%o12) F = ((fu-fd)*P+fd)*%e^-(r*T)
Leo
<
< Thanks in advance,
<
< Julien.
<
< 2009/11/11 reyssat <eric.reyssat at math.unicaen.fr>
< Julien Martin a ?crit :
< 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.
< ------------------------------------------------------------------------
<
< _______________________________________________
< Maxima mailing list
< Maxima at math.utexas.edu
< http://www.math.utexas.edu/mailman/listinfo/maxima
< ?
<
< Hello,
< since you want to eliminate u and d in f, and express it in terms of the other parameters only, you can solve in terms of f,u,d :
<
< (%i2) %Delta:(fu-fd)/(S0*u-S0*d);
< (%o2) (fu-fd)/(u*S0-d*S0)
<
< (%i3) p:(exp(r*T)-d)/(u-d);
< (%o3) (%e^(r*T)-d)/(u-d)
<
< (%i4) f:S0*%Delta*(1-u*exp(-r*T))+fu*exp(-r*T);
< (%o4) (fu-fd)*S0*(1-u*%e^-(r*T))/(u*S0-d*S0)+fu*%e^-(r*T)
<
< (%i5) s:solve([F-f,P-p],[F,u,d]); ?ss:s[2][1];
< (%o5) [[F = %r1,u = %e^(r*T),d = %e^(r*T)],
< ? ? ?[F = ((fu-fd)*P+fd)*%e^-(r*T),u = %r2,d = -(%e^(r*T)-%r2*P)/(P-1)]]
< (%o6) F = ((fu-fd)*P+fd)*%e^-(r*T)
<
< which is almost your expected answer (need to collect coefficient of fd).
<
< Eric
<
<
<
<
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.