In Calc Embedded Mode, you can define a variable with the :=
operator. You can then use it in an equation using the =>
operator and it will be automatically updated when you change the variable. See (calc) Assignments in Embedded Mode.
Example:
- Create a new buffer containing:
x := 3
x + 2 => 9999
- Invoke
calc-embedded-activate
(C-x * a
) Invoke
calc-embedded-update-formula
(C-x * u
) on the bottom equation. It changes tox + 2 => 5
Now enter embedded mode on the top equation and change it to
x := 30
. The bottom one will change tox + 2 => 32
.
But this doesn't work with functions. Create a buffer containing
f(x) := 2 x
f(2) => 9999
Invoke C-x * a
anywhere and invoke C-x * u
on the bottom equation. It changes to f(2) => f(2)
. Changing the top equation doesn't affect the bottom one.
Is there any way to define a function from within Calc or does it have another way of dealing with this? I know of defmath
but that doesn't help in e.g. a Latex document (unless you define the function twice, likely making mistakes).
Assignments to other kinds of objects can be represented by Calc, but the automatic linkage between assignments and references works only for plain variables ...
. So how to do the linkage for other objects? Maybe Omars answer shows this? – jue Feb 18 '20 at 14:08