Thanks, I'll take a look.


On Sun, Apr 2, 2017, 19:11 Michael Brand <michael.ch.brand@gmail.com> wrote:
Hi Manuel

Not sure if I understand your formulas right, so check my solutions with
the formula debugger.

On Thu, Mar 30, 2017 at 10:38 AM, Manuel Schneckenreither
<manuel.schnecki@gmail.com> wrote:

> So @5$3 should be 0.9^0*127 + 0.9^1*118 + 0.9^2*121 + 0.9^3*115.

Emacs Calc has map with anonymous function and one or more vectors for
the above:

vsum(map(<0.9^#1 * #2>, [3, 2, 1, 0], [115, 121, 118, 127]))

which equals

vsum(map(<0.9^(4 - #1) * #2>, [1, 2, 3, 4], [115, 121, 118, 127]))

The rest is Org spreadsheet. See the spreadsheet section in the Org
user manual to understand this solution:

| t | y_t | y_{t+1} |
|---+-----+---------|
| 1 | 115 | 115.000 |
| 2 | 121 | 224.500 |
| 3 | 118 | 320.050 |
| 4 | 127 | 415.045 |
#+TBLFM: $3 = vsum(map(<0.9^($1 - #1) * #2>, @I$1..@0$1, @I$2..@0$2)); f-3

The same with Emacs Lisp:

| t | y_t | y_{t+1} |
|---+-----+---------|
| 1 | 115 | 115.000 |
| 2 | 121 | 224.500 |
| 3 | 118 | 320.050 |
| 4 | 127 | 415.045 |
#+TBLFM: $3 = '(apply #'+ (cl-mapcar (lambda (tau y-tau) (* (expt 0.9
(- $1 tau)) y-tau)) '(@I$1..@0$1) '(@I$2..@0$2))); N %.3f

Michael