Subject: Resolving the following system of equations:
From: Leo Butler
Date: Wed, 10 Jun 2009 18:18:34 +0100 (BST)
On Wed, 10 Jun 2009, Julien Martin wrote:
< Hello again Leo,
<
< Here is what I came up with:
< *
< **r:0.1;
< q:0.0;
< K:50;
< deltaT:0.0833;
< sigma:0.4;
<
< a(x) := (1.0 / 2.0) * (r - q) * x * deltaT - (1.0 / 2.0) * sigma^2 * x^2 *
< deltaT;
< b(x) := 1 + sigma^2 * x^2 * deltaT + r * deltaT;
< c(x) := -(1.0 / 2.0) * (r - q) * x * deltaT - (1.0 / 2.0) * sigma^2 * x^2 *
< deltaT;
<
< f(x) := max(K - x * 5, 0);
<
< eq[i] := f[9][i-1] = (f(i) - c(i)*f[9][i+1] - b(i)*f[9][i])/a(i);
<
< f[9][10]:0;/*HERE*/
< f[9][0]:K;/*HERE*/
<
< eqns : makelist(eq[i],i,1,9);
In place of the two assignment lines, do the following after
defining your equations:
eqns : subst( [ f[9][10]=0, f[9][0]=0 ], eqns );
To have floating point answers, do
sols : linsolve(eqns,vars)$
float(sols);
See ? float and ? bfloat.
---------------------------------------------------
Concerning syntax highlighting, you should know that the email list
is archived and searchable. Just go to http://maxima.sourceforge.net
and follow the link. An answer to your question is in a thread from
earlier this year.
You will also find many other interesting discussions there.
Leo
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.