LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default HELP NEEDED - Iterative process in a VBA function

On Mar 13, 2:19 am, Paul S wrote:
Thanks for your response, in the meantime I have received
some other help. The function now looks like this and it
works!


I can confirm that it converges on a result. It is unclear to me why,
and I cannot say whether or not the result is correct (the definition
of "it works"). But that is because I am not familiar with the
financial theory here.

However, I do believe there might be instances where the loop does not
terminate. That is because "loan_amt < settlement_amount + fpa_cost"
might never be true, even though it should be mathematically, due to
anomalies of binary floating-point arithmetic, which is the internal
representation of type Double.

(Admittedly, it works for the several example parameters that I
tested.)

I assume that at least "coupon" and risk_free_rate are non-integers,
and I suspect that "fraction" is also a non-integer. In any case, it
appears that fpa_cost might become a non-integer.

With type Double (binary floating-point), most non-integers (and most
integers 2^53) cannot be represented exactly. Thus, arithmetic
often results in unexpected anomalies. For example, 10.1 - 10 < 0.1
(!). Likewise, adding 0.1 repeatedly starting with 0 will never
exactly equal 10.1 (!).

Therefore, it would be prudent to implement the loop termination
condition by one of the following options:

Do While Abs(settlement_amount + fpa_cost - loan_amt) = 0.0000005

Do While Round(settlement_amount + fpa_cost - loan_amt, 6) < 0

The choice of 0.0000005 and 6 is arbitrary. I chose them based on
rounding precision used to compute FPA_test.

Aside.... It is not necessary to compute FPA_test within the loop.
There is no advantage to computing it within the loop as it is written.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Major help needed - Iterative Functions LiAD Excel Programming 15 April 1st 09 08:30 PM
Iterative process of running queries frequently abends for no clr. LD Excel Programming 0 August 13th 08 10:11 PM
Process monitor macro needed Mark Creager Excel Programming 1 February 18th 08 02:33 PM
Iterative process, bioyyy Excel Discussion (Misc queries) 5 December 1st 05 02:07 AM
Urgent Help needed - I need to stop a process that is running forever in Excel shadestreet Excel Discussion (Misc queries) 2 October 6th 05 09:59 PM


All times are GMT +1. The time now is 01:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"