# Tag Info

11

v x 10 RET should do it. Uses calc-index.

6

The same Emacs Rocks page links to an implementation of eval-and-replace used to replace a sexp with its value in this episode.

6

Yes, for example: (calc-eval "solve([x+y=3, x-y=1], [x,y])") evaluates to: "[x = 2, y = 1]" You might find it more comfortable to use a calc-mode buffer than running calc-eval in the scratch buffer, though.

6

You can use the built-in calc package to do so. Mark your expression, e.g. 3 * (1 + 1) Call calc-grab-region Call calc-dispatch (default C-x *), then hit g

5

You could use hook calc-end-hook to hook delete-frame. emacsclient -t --eval '(progn (add-hook (quote calc-end-hook) (lambda () (delete-frame))) (calc nil t))'

5

I'm having exactly the same issue, anything I try to fit gives me the same complaint. I stumbled across this though, which just says it's a bug in 24.3 and fixed in 24.4.

5

The idea is to evaluate some Elisp inline and replace it with the result. It looks like he did it with a custom function he defined and bound to C-x C-e. Note that C-x C-e is bound to eval-last-sexp by default, which does something very similar. It evaluates the s-expression just before your cursor. If you call it with a prefix argument, it will paste the ...

5

I'm not sure about the actual reason plus won't work the way you expect, but this is what Calc does when you add vectors interactively: #+BEGIN_SRC calc :var X=[1 2], Y=[3 4] map(add, X, Y) #+END_SRC The result where you get [[4, 6]] seems to indicate that Calc needs vectors to be 2D matrices with a single column, rather than 1D matrices.

5

You can do that interactively by query-replace-regexp with embedded Elisp in the replacement string. Go to the beginning of the file. Type M-x query-replace-regexp RET. Input {x: $$[0-9]+$$, y:$$[0-9]+$$} as search regexp. Input {x: \1, y:y_default + \,(- (read \2) 80)} as replacement string. Answer the queries of query-replace-regexp as appropriate. The ...

5

I don't think RREF is particularly useful other than for teaching linear algebra to college students, so your best hope is to find some math professor who uses Emacs and was sick of doing RREF by hand while grading homework... someone like me! Here's a little package I wrote the first time I taught linear algebra: https://github.com/oantolin/emacs-config/...

4

Update (Oct 12 2015) Below calc-yank implementation is now added to emacs trunk. It will be available in the next stable emacs release. I reviewed the original definition of calc-yank and the good thing is that it does not have any argument. So I added my own argument, radix, and slightly modified how the let-bound var thing is derived. By default, the ...

4

Using Org-mode Select the text of the table. C-c | Add at the bottom: #+TBLFM: $6=$6+5.487 and press C-c C-c while the point is either on the formula or on the table. This gives: | ATOM | 10 | H5 | LIG | 1 | 4.803 | 2.034 | 0.000 | 1.00 | 0.00 | | ATOM | 11 | C1 | LIG | 1 | 6.461 | 0.686 | 0.000 | 1.00 | 0.00 | | ATOM | 12 | H1 | LIG | 1 | 7.221 | 1.451 ...

4

To input a value in non-standardized HMS form you can press ' to start algebraic entry and then use the hms function. For example, to enter the equivalent of 0@8000'0" you would type ' hms(0, 8000, 0) RET. Another possibility is to input the number of days and then convert them to HMS form using the function calc-to-hms (bound to ch). So for your example ...

4

This question is almost a duplicate to the question about the usage of a calc table for converting units. The only difference is that you do not only want to convert values with units in a column but you want the result of an operation with standard units. You can write the operation into the first inner calc-eval of the linked answer. | test | ...

4

(calc) Basic Arithmetic: When combining multiplication and division in an algebraic formula, it is good style to use parentheses to distinguish between possible interpretations; the expression a/b*c should be written (a/b)*c or a/(b*c), as appropriate. Without the parentheses, Calc will interpret a/b*c as a/(b*c), since in algebraic entry Calc ...

4

Your guess inner is right. The first two operands of inner are the multiplication and the summation operator, respectively. The remaining two arguments are the vectors for the inner product. The summation operator is add and the multiplication operator is mul. Your table inclusive the table-formula should look like: | | | col1 | enable | |---+-----...

3

One way of going from an HMS form to the number of seconds is hinted by a line from the HMS forms page: Dividing two HMS forms produces a real-valued ratio of the two angles. So if an HMS form is on the stack 5@ 30' 0" entering one second to the stack 1" and dividing by it / gives the number of seconds: 19800. Not exactly a convert but it's only ...

3

How can I input this command? I believe you cannot. I am convinced that this is a bug in org-babel-execute:calc: see ob-calc.el, line 67. org-babel-execute:calc expects every Calc "stack operation" to be a function taking a prefix argument which specifies the number of times it is applied. calc-divide, for example, takes a prefix argument, so line 3 of ...

3

You can always use M-x query-replace-regexp, if you're comfortable with regexps and elisp. Replacing: ^$$\(?:[^ ]+ +$$\{5\}\)$$[ -][0-9.]+$$ With: \1\,(format "% .3f" (+ 5.487 \#2)) Will replace the second captured group (being the 6th column) with the formatted result of the calculation. This will break the alignment slightly if the numbers get too ...

3

You can use multiple cursors to get this done. Before you get started with the below steps, add this to your init.el, evaluate it and bind it to a key binding of your linking. ;; http://stackoverflow.com/questions/3035337/in-emacs-can-you-evaluate-an-emacs-lisp-expression-and-replace-it-with-the-resul (defun eval-and-replace-last-math-sexp () "Replace an ...

3

Original question: Is it possible that the evaluation of ((x-1)/(x+1))+((x+1)/(x-1))=> returns ((x-1)/(x+1))+((x+1)/(x-1))=>(2 x^2 + 2) / (x^2 - 1) The calc function nrat transforms its expression argument to a rational expression. You can try nrat(((x-1)/(x+1))+((x+1)/(x-1))) with M-: (calc-eval "nrat(((x-1)/(x+1))+((x+1)/(x-1)))") The result is: (2*...

3

The following works for me: | | Fund A | Fund B | Fund C | Combined | |-----------+--------+--------+--------+----------| | US | .1 | .8 | .5 | 0.53 | | Europe | .2 | .1 | .4 | 0.19 | | Pacific | .7 | .1 | .1 | 0.28 | | Weighting | .3 | .5 | .2 | | #+TBLFM: @2\$>..@&...

3

Summing the whole stack of calc can be achieved using a keyboard macro. Define the macro (which does just the + operation): C-x ( + C-x ). BTW this definition already sums two elements of the stack as a side effect. Then run the macro until an error occurs with C-0 X. That's it! The error is expected to occur when one element remains on the stack. If ...

3

Another solution, if you know from the beginning that you want a sum, is use a vector. Prefix your list of numbers with [, finish with ], and sum using calc-reduce with the + operator (v R +): [ 1 2 ... ] v R +

2

Found the solution as soon as I posted the question .. Solution In my init.el: (require 'calc) (setq calc-settings-file (concat user-emacs-directory "/setup-calc-defaults.el")) In my setup-calc-defaults.el: (setq calc-float-format '(eng 0)) The defaults don't become effective right-away. Without worrying about what all packages I might need to require ...

2

Have the region -2:5 in a buffer. C-0 C-x * e activates calc's embedded mode on that region. Activate calc-latex-language by typing d L if not already done. The marked text has been replaced by \frac{-2}{5}. Key sequence C-x * e deactivates embedded mode. So I think it's possible to write a command that checks for fractions like -2:5 in a column of an ...

2

Just after posting this, I found a solution I'm surprised I didn't think of sooner: Hit backtick (calc-edit) to edit the stack value. Kill the line in the edit buffer with C-w (editing it first if it suits your needs). C-c C-c to close the buffer (if you killed everything, the value gets restored on the stack, so it's equivalent to hitting C-c C-k). Yank ...

2

You can set mark and point, and save the region to the kill ring with kill-ring-save, which by default is bound to C-M-w in calc mode (instead of M-w as it is in most other modes).

2

You first have to evaluate the algebraic 7i - 2 by pressing =, such that it is rewritten as (-2, 7). Then you can use calc-abs just like you would on a normal number. See also the section on complex formats in the Calc manual.

2

You might also use calc's embedded mode if you intent to replace an expression with its result in the current buffer. C-u C-x * e when your formula / expression is on it's own on a separate line. Otherwise mark it and type C-0 C-x * e (Update: thanks to Dodgie, forgot to mention that) When you are finished with your mathematical manipulations type C-x * e ...

Only top voted, non community-wiki answers of a minimum length are eligible