emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Table formula references


From: Manuel Schneckenreither
Subject: Re: [O] Table formula references
Date: Sun, 02 Apr 2017 17:31:13 +0000

Thanks, I'll take a look.


On Sun, Apr 2, 2017, 19:11 Michael Brand <address@hidden> 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
<address@hidden> 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>, @address@hidden, @address@hidden)); 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)) '(@address@hidden) '(@address@hidden))); N %.3f

Michael

reply via email to

[Prev in Thread] Current Thread [Next in Thread]