Subject: Resolving the following system of equations:
From: Julien Martin
Date: Wed, 10 Jun 2009 17:35:26 +0200
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);
*Can you please advise as to how to explicitly assign a value to f[9][10]?
Thanks in advance,
Julien.
2009/6/10 Leo Butler <l.butler at ed.ac.uk>
>
>
> On Wed, 10 Jun 2009, Julien Martin wrote:
>
> < Hello,
> <
> < I am trying to numerically resolve the following system of equations:
> <
> < f9_8 = (f10,9 - c9 * f9_10 -b9 * f9_9)/a9
> < f9_7 = (f10_8 - c8 * f9_9 - b8 * f9_8)/a8
> < f9_6 = (f10_7 - c7 * f9_8 - b7 * f9_7)/a7
> < ...
> < f9_1 = (f10_2 - c2 * f9_3 - b2 * f9_2)/a2
> < f9_0 = (f10_1 - c1 * f9_2 - b1 * f9_1)/a1
> <
> < where the following are known:
> < c1,c2,c3,...,c9
> < b1,b2,b3,...,b9
> < a1,a2,a3,...,a9
> < f10_1,f10_2,f10_3,...,f10_9
> < and also f9_10, f9_0
>
> Look at the examples in the online help for linsolve:
>
> ? linsolve
>
> You might also this about some labour-saving devices,
> e.g.
>
> eq[i] := f[9][i-1] = (f[10][i] - c[i]*f[9][i+1] etc. etc.
>
> and then defining your equations by
>
> eqns : makelist(eq[i],i,1,9);
>
> Leo
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>