Thanks Mike

I am keeping this as part of my growing library of such stuff.

Incidentally my own problem with imitating spreadsheet behaviour has moved from 
financial functions (solved for now thanks to your help and some internet 
searches) to the problem of simulating recursive evaluation in a grid of 
values: A1 to An is a set of values; B1 to Bn is another set - think of them 
both as rows in a spreadsheet. On first glance, A depends on B and B depends on 
A! Oops. On second glance, A1 is an initial value as is B1, then A2 depends on 
B1 etc., so the grid can be solved after all. I am hand-crafting all this when 
it would work automatically in a spreadsheet… a generalised spreadsheet object 
for iOS would be a fine thing, but IMHO we will never see one.

Back to the grindstone

Graham

On 9 Nov 2012, at 14:27, Mike Bonner wrote:

> found my other stack, heres the script from it. (got the script from
> somewhere else and adjusted for lc)
> 
> */
> 
> *
> //----------------------------------------------------------------------------------------------
> *
> 
> *// COMPOUND INTEREST*
> 
> *// present value, future value, imputed compound interest rate per period.*
> 
> *// NumPeriods and InterestPerPeriod are relative to each other, regardless
> of the units used for either.*
> 
> *
> //----------------------------------------------------------------------------------------------
> *
> 
> *function* PresentValue NumPeriods, InterestPerPeriod, FutureValue
> 
>   *return* FutureValue / (1 + InterestPerPeriod) ^ NumPeriods
> 
> *end* presentvalue
> 
> 
> *function* FutureValue NumPeriods, InterestPerPeriod, PresentValue
> 
>   *return* PresentValue * (1 + InterestPerPeriod) ^ NumPeriods
> 
> *end* futurevalue
> 
> 
> *function* ImputedInterest PresentValue, FutureValue, NumPeriods
> 
>   *return* (FutureValue / PresentValue) ^ ((1 / NumPeriods) - 1)
> 
> *end* imputedInterest
> 
> 
> *function* NumPeriods PresentValue, FutureValue, InterestPerPeriod
> 
>   *return* (log10(FutureValue) - log10(PresentValue)) / log10(1 +
> InterestPerPeriod)
> 
> *end* numPeriods
> 
> 
> 
> *
> //----------------------------------------------------------------------------------------------
> *
> 
> *// PERIODIC INTEREST RATES*
> 
> *// Given an annual rate, returns an array containing the rates for shorter
> periods. *
> 
> *// The elements can be accessed as, for example, Rates["Daily"] or
> Rates.Daily.*
> 
> *function* GetPeriodicInterestRates AnnualRate
> 
>   *put* AnnualRate into Rates["Annually"]
> 
>   *put* AnnualRate /2 into Rates["Semiannually"]
> 
>   *put* AnnualRate /4 into Rates["Quarterly"]
> 
>   *put* AnnualRate /12 into Rates["Monthly"]
> 
>   *put* AnnualRate /52 into Rates["Weekly"]
> 
>   *put* AnnualRate /365 into Rates["Daily"]
> 
>   *return* Rates
> 
> *end* getPeriodicInterestRates
> 
> 
> On Thu, Nov 8, 2012 at 9:53 PM, Peter M. Brigham <pmb...@gmail.com> wrote:
> 
>> On Nov 5, 2012, at 3:02 AM, Graham Samuel wrote:
>> 
>>> You know I did search the dictionary, but never thought of something so
>> obvious as 'annuity' or 'compound'. Well, you learn something new every day
>> (at least I do).
>> 
>> I have been known to browse through the dictionary from time to time. That
>> must make me some kind of geek, but I have discovered a few things doing
>> this that I didn't know.
>> 
>> -- Peter
>> 
>> Peter M. Brigham
>> pmb...@gmail.com
>> http://home.comcast.net/~pmbrig
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to