From mboxrd@z Thu Jan 1 00:00:00 1970 From: Manuel Schneckenreither Subject: Re: Table formula references Date: Sun, 02 Apr 2017 17:31:13 +0000 Message-ID: References: <8760irgnwj.fsf@uibk.ac.at> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c1245346b5ab6054c3269c5 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cujLZ-0000My-TO for emacs-orgmode@gnu.org; Sun, 02 Apr 2017 13:31:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cujLY-0003q6-W0 for emacs-orgmode@gnu.org; Sun, 02 Apr 2017 13:31:25 -0400 Received: from mail-it0-x22c.google.com ([2607:f8b0:4001:c0b::22c]:37163) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cujLY-0003pO-RF for emacs-orgmode@gnu.org; Sun, 02 Apr 2017 13:31:24 -0400 Received: by mail-it0-x22c.google.com with SMTP id a140so543438ita.0 for ; Sun, 02 Apr 2017 10:31:24 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Michael Brand Cc: Org Mode --94eb2c1245346b5ab6054c3269c5 Content-Type: text/plain; charset=UTF-8 Thanks, I'll take a look. On Sun, Apr 2, 2017, 19:11 Michael Brand 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 > 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 > --94eb2c1245346b5ab6054c3269c5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Thanks, I'll take a look.


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

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 =3D 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 =3D '(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
--94eb2c1245346b5ab6054c3269c5--