evaluation of calc formulas in orgtbl?

in calc mode, 'subst (2 * x, x, 5)' is evaluated to 10, but in an orgtbl table the formula is evaluated incompletely to '2 5'. How to force evaluation into orgtbl-mode? Here is my example:

|-----+--------+-----+-------|
| x   | -2     |   0 |   3.7 |
|-----+--------+-----+-------|
| 2 x | 2*-2   | 2 0 | 2 3.7 |
| x^2 | (-2)^2 | 0^2 | 3.7^2 |
#+TBLFM: @<<\$<<..@>\$>=subst(\$<,@<\$<,@1)::@2\$1=deriv(@+1,@1\$1)

|-----+----+---+-----|
| x   | -2 | 0 | 3.7 |
|-----+----+---+-----|
| 2 x |  2 | 2 |   2 |
| x^2 | -2 | 0 | 3.7 |
#+TBLFM: @<<\$<<..@>\$>=subst(\$<,@<\$<,@1);N::@2\$1=deriv(@+1,@1\$1)

(The example can also be downloaded from http://ix.io/EaH.)

It is clear that the second table with the mode switch ;N for the formula gives wrong results since the non-number x is replaced by 0. From the org mode manual:

If you provide the `N' mode switch, all referenced elements will be numbers (non-number fields will be zero) and interpolated as Lisp numbers, without quotes.

So we look at the first table. You can enforce an additional evaluation of calc by simplify:

|-----+----+---+-------|
| x   | -2 | 0 |   3.7 |
|-----+----+---+-------|
| 2 x | -4 | 0 |   7.4 |
| x^2 |  4 | 0 | 13.69 |
#+TBLFM: @<<\$<<..@>\$>=simplify(subst(\$<,@<\$<,@1))::@2\$1=deriv(@+1,@1\$1)

You are probably aware of the possibility for debugging org table formulas. That shows pretty good what happens.

• Great ! I spent a lot of time executing step-by-step org-table-eval-formula and calc-eval without finding. I did not think about this function because I expected to find the same behavior as in calc in interactive mode. Many thanks. – gigiair Jan 15 '18 at 22:18