What does an argument to "V" look like?

On 9/11/07, Alistair Tucker <[EMAIL PROTECTED]> wrote:
>
> Hi
> I'm a little disconcerted to find that I'm getting stack overflows for
> more than two thousand iterations of my recursive function.
> This is a problem.  As it stands, my program (below) is unable to price a
> convertible bond with more than about a year to maturity.
> Is there some way round this?  Perhaps I should be implementing the
> iteration in some other way?
> Alistair
>
> NAS=: 100
> dS=: 2
> S=: dS*i.NAS
> k=: 135
> r=: 0.05
> b=: 113.22
> dL=: %365
> sigma=: 0.4
> dt=: 0.9%*:sigma*NAS
>
> Sgtk=: S#~S>k
> Sltk=: S#~S<:k
>
> Delta=: (2*dS)%~2&}.-_2&}.
> Gamma=: (*:dS)%~2&}.+_2&}.-2*}.@:}:
> dV_dL=: dL%~}."_1-}:"_1
>
> negTheta_ltk=: ([:-r*{.@:[),(((r*}.Sltk)*Delta)+(0.5**:sigma*
> }.Sltk)*Gamma)@:([,{.@:{.@:])-r*}.@:[
>
> step_gtk=: ((}:@:]+dt*(((r*}:Sgtk)*Delta)+(0.5**:sigma*
> }:Sgtk)*Gamma)@:({:@:[,])-r*}:@:])(}:"_1@:]))+(dt*dV_dL@:}:@:])
>
> V_ltk=: Sltk>.[+dt*negTheta_ltk
> V_gtk=: (Sgtk>.b,.~],({.-~2*{:)@:(_2&{.))@:step_gtk
>
> Vrec=: (>@:{.(V_ltk;V_gtk)>@:{:)@:V@:<:
> V=: Vrec`((b$~+/S<:k);(b$~16,~+/S>k)"0)@.(0=])
>
>
>
>
>
>
>       ___________________________________________________________
> Want ideas for reducing your carbon footprint? Visit Yahoo! For Good
> http://uk.promotions.yahoo.com/forgood/environment.html
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to