This is really amazing how J does it, but
in fact the logic is simple:

   (1.10 * _50 + ])^:3 b. _1
(50 + 0.90909090909090906 * ])^:3

- power remains power (^:)
- 1.1 times (_50 plus o) becomes 50 plus (%1.1 times  o)


This could be solved by hand like this

   f=: (1.1 * _50 + ])^:3
   2 -~/\f i.10 NB. linear with such factor
1.331 1.331 1.331 1.331 1.331 1.331 1.331 1.331 1.331
   f 0          NB. and such free element
_182.05

   lsfit=: {:@] %. [EMAIL PROTECTED] ^/ i.@>:@[  NB. also
   ]C=: 1 lsfit (,: f) 0 1
_182.05 1.331

   +/(f +/@- C p. ]) i.1000  NB. very close
6.24262e_8


   NB. 1000 = f x  <=> 0 = _1000 + f x
   p. _1000 0+C
+-----+-------+
|1.331|888.092|
+-----+-------+
   1{::p. _1000 0+C    NB. sought value
888.092

   C p. 888.092
1000
   f 888.092
1000


--- Scott Russell <[EMAIL PROTECTED]> wrote:

> Thanks Henry. 
> 
> Can you give me the original equation and then how do you make an inverse of 
> the equation ?
> 
> Scott
> 
>   ----- Original Message ----- 
>   From: Henry Rich<mailto:[EMAIL PROTECTED]> 
>   To: 'Programming forum'<mailto:[email protected]> 
>   Sent: Monday, May 08, 2006 2:59 PM
>   Subject: RE: [Jprogramming] J question
> 
> 
>   I would never have thought of doing it this way, but you can
>   solve it in J just as you would in Excel.  Defines the function,
>   and use the inverse to ask what value would give you 1000:
> 
>     (1.10 * 50 -~ ])^:3 ^:_1 (1000)
>   888.092 
> 
>   Henry Rich
> 
>   > -----Original Message-----
>   > From: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> 
>   > [mailto:[EMAIL PROTECTED] On Behalf Of Scott Russell
>   > Sent: Monday, May 08, 2006 2:34 PM
>   > To: [email protected]<mailto:[email protected]>
>   > Subject: [Jprogramming] J question
>   > 
>   > Hello,
>   > 
>   > I'm a newbie to J and I have a general programming question.
>   > 
>   > Say I wanted to find a solution to a problem that would 
>   > normally require an iterative technique.  For a very 
>   > simplified example:
>   > 
>   > Say you purchased a CD or some other financial instrument 
>   > where you wanted to accumulate $1,000 at the end of 3 years.
>   > This CD had an annual fee of $50 (payable at the beginning of 
>   > the year) and it guaranteed an interest rate of 10%.  How 
>   > much would you need to invest at the beginning of the 3 years 
>   > ?  In other words, solve for X:
>   > 
>   > (((((X-50) * 1.10) - 50) * 1.10) - 50) * 1.10 = $1,000
>   > 
>   > In Excel, I could set up a macro that searched for the 
>   > solution through the bisection algorithm or I could use the 
>   > "Goal Seek" function if I really wanted to take a short cut.
>   > 
>   > But I wouldn't know where to start in J.  Any ideas ? Thanks
>   > ----------------------------------------------------------------------
>   > For information about J forums see 
>   > http://www.jsoftware.com/forums.htm<http://www.jsoftware.com/forums.htm>
> 
>   ----------------------------------------------------------------------
>   For information about J forums see
> http://www.jsoftware.com/forums.htm<http://www.jsoftware.com/forums.htm>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to