emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* What is the status of ob-maxima.el? Is this a bug?
@ 2023-12-05  1:41 Eduardo Ochs
  2023-12-05 10:36 ` Fraga, Eric
  0 siblings, 1 reply; 10+ messages in thread
From: Eduardo Ochs @ 2023-12-05  1:41 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 2661 bytes --]

Hi list,

what is the status of ob-maxima.el? Is it considered to be functional?
If yes, what am I doing wrong? If no, should I file a bug report about
the problem below?

If I eval these two sexps and then execute the code block below them
with `C-c C-c' - obs: I added some indentation for clarity,

  (setq org-confirm-babel-evaluate nil)
  (require 'ob-maxima)

  #+begin_src maxima
  2+3;
  #+end_src

then I get this "#+RESULTS:" block when the first "maxima" found in
the $PATH is /usr/local/bin/maxima, that is a script that runs a
Maxima compiled from the git sources a few days ago,

  #+RESULTS:
  | Adding  |                                 118 | subdirectories | of |
/usr/local/share/maxima/branch_5_47_base_312_gd5a35a21b/share | to | search
| path. |
  | Adding  |                                   0 | subdirectories | of |
/home/edrx/.maxima                                            | to | search
| path. |
  | Loading | /home/edrx/.maxima/maxima-init.lisp |                |    |
                                                            |    |        |
      |
  | Loading |  /home/edrx/.maxima/maxima-init.mac |                |    |
                                                            |    |        |
      |

and I get this empty "#+RESULTS:" block

  #+RESULTS:

when the first "maxima" found in the $PATH is /usr/bin/maxima, that is
a script that runs the Maxima that comes with Debian 11
("oldstable")...

If I simply run the tests above in a shell the log is:

  /home/edrx(edrx:sc)# /usr/local/bin/maxima
  Adding 118 subdirectories of
"/usr/local/share/maxima/branch_5_47_base_312_gd5a35a21b/share" to search
path.
  Adding 0 subdirectories of "/home/edrx/.maxima" to search path.
  Loading /home/edrx/.maxima/maxima-init.lisp
  Loading /home/edrx/.maxima/maxima-init.mac
  Maxima branch_5_47_base_312_gd5a35a21b https://maxima.sourceforge.io
  using Lisp SBCL 2.1.1.debian
  Distributed under the GNU Public License. See the file COPYING.
  Dedicated to the memory of William Schelter.
  The function bug_report() provides bug reporting information.
  (%i1) 2+3;
  (%o1)                                  5
  (%i2) quit()$
  /home/edrx(edrx:sc)#
  /home/edrx(edrx:sc)# /usr/bin/maxima

  Maxima 5.44.0 http://maxima.sourceforge.net
  using Lisp GNU Common Lisp (GCL) GCL 2.6.12
  Distributed under the GNU Public License. See the file COPYING.
  Dedicated to the memory of William Schelter.
  The function bug_report() provides bug reporting information.
  (%i1) 2+3;
  (%o1)                                  5
  (%i2) quit()$
  /home/edrx(edrx:sc)#


Thanks in advance,
  Eduardo Ochs
  http://anggtwu.net/eepitch.html

[-- Attachment #2: Type: text/html, Size: 3347 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05  1:41 What is the status of ob-maxima.el? Is this a bug? Eduardo Ochs
@ 2023-12-05 10:36 ` Fraga, Eric
  2023-12-05 11:34   ` Eduardo Ochs
  2023-12-05 16:42   ` Leo Butler
  0 siblings, 2 replies; 10+ messages in thread
From: Fraga, Eric @ 2023-12-05 10:36 UTC (permalink / raw)
  To: Eduardo Ochs; +Cc: Org Mode

I think ob-maxima will only output the actual explicit "output" of the
script, so something like

#+begin_src maxima
print(2+3);
#+end_src

should work.

-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05 10:36 ` Fraga, Eric
@ 2023-12-05 11:34   ` Eduardo Ochs
  2023-12-05 13:22     ` Fraga, Eric
  2023-12-05 16:42   ` Leo Butler
  1 sibling, 1 reply; 10+ messages in thread
From: Eduardo Ochs @ 2023-12-05 11:34 UTC (permalink / raw)
  To: Org Mode List

Ouch! I'm so used to using Maxima from its REPL that I forgot to test
that... thanks and sorry! =/
  Eduardo

On Tue, 5 Dec 2023 at 07:36, Fraga, Eric <e.fraga@ucl.ac.uk> wrote:
>
> I think ob-maxima will only output the actual explicit "output" of the
> script, so something like
>
> #+begin_src maxima
> print(2+3);
> #+end_src
>
> should work.
>
> --
> : Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05 11:34   ` Eduardo Ochs
@ 2023-12-05 13:22     ` Fraga, Eric
  0 siblings, 0 replies; 10+ messages in thread
From: Fraga, Eric @ 2023-12-05 13:22 UTC (permalink / raw)
  To: Eduardo Ochs; +Cc: Org Mode List

On Tuesday,  5 Dec 2023 at 08:34, Eduardo Ochs wrote:
> Ouch! I'm so used to using Maxima from its REPL that I forgot to test
> that... thanks and sorry! =/

No apology required.  It would be good if ob-maxima had implemented the
concept of returning the last value, as some other language
implementations do, but my elisp-fu (and maxima-fu) was not up to the
challenge when I wrote the initial version of ob-maximal.el (much
improved later by Eric Shulte).

And having it output everything that maxima actually outputs in the REPL
I considered to be too overwhelming.  Hence the "--very-quiet" option
passed to maxima on execution.

-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05 10:36 ` Fraga, Eric
  2023-12-05 11:34   ` Eduardo Ochs
@ 2023-12-05 16:42   ` Leo Butler
  2023-12-05 16:49     ` Fraga, Eric
  1 sibling, 1 reply; 10+ messages in thread
From: Leo Butler @ 2023-12-05 16:42 UTC (permalink / raw)
  To: Org Mode List

On Tue, Dec 05 2023, "Fraga, Eric" <e.fraga@ucl.ac.uk> wrote:

> I think ob-maxima will only output the actual explicit "output" of the
> script, so something like
>
> #+begin_src maxima
> print(2+3);
> #+end_src
>
> should work.

With recent versions of ob-maxima.el, you can set header arguments to
get the behaviour Eduardo expected:

#+NAME: batch-quiet-maxima
#+HEADER: :batch batch
#+HEADER: :results raw
#+HEADER: :wrap example
#+HEADER: :cmdline --quiet
#+BEGIN_SRC maxima
  rat(1/(x+1) + x/(x-1));
#+END_SRC

See "An example with line numbering" at
https://orgmode.org/worg//org-contrib/babel/languages/ob-doc-maxima.html

Leo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05 16:42   ` Leo Butler
@ 2023-12-05 16:49     ` Fraga, Eric
  2023-12-05 16:59       ` Leo Butler
  0 siblings, 1 reply; 10+ messages in thread
From: Fraga, Eric @ 2023-12-05 16:49 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode List

On Tuesday,  5 Dec 2023 at 16:42, Leo Butler wrote:
> With recent versions of ob-maxima.el, you can set header arguments to
> get the behaviour Eduardo expected:

Thank you.  This is great news.

I'm going to have to upgrade as the version I'm currently using (from
1-2 months ago, I think) doesn't seem to pay attention to :cmdline
--quiet and/or :results raw.

-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05 16:49     ` Fraga, Eric
@ 2023-12-05 16:59       ` Leo Butler
  2023-12-05 17:16         ` Fraga, Eric
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Butler @ 2023-12-05 16:59 UTC (permalink / raw)
  To: Org Mode List

On Tue, Dec 05 2023, "Fraga, Eric" <e.fraga@ucl.ac.uk> wrote:

> On Tuesday,  5 Dec 2023 at 16:42, Leo Butler wrote:
>> With recent versions of ob-maxima.el, you can set header arguments to
>> get the behaviour Eduardo expected:
>
> Thank you.  This is great news.
>
> I'm going to have to upgrade as the version I'm currently using (from
> 1-2 months ago, I think) doesn't seem to pay attention to :cmdline
> --quiet and/or :results raw.

Yes, it is relatively recent work (see below).

You mentioned returning a value from a maxima code block. I wonder if
you could elaborate? I could imagine either the lisp sexp of the last
expression or the printed representation (e.g. in linear/1d form). But
maybe you have something else in mind?

Leo


#+begin_src elisp :exports results
  (org-version)
#+end_src

#+RESULTS:
: 9.7-pre

#+NAME: batch-quiet-maxima
#+HEADER: :batch batch
#+HEADER: :exports results
#+HEADER: :results raw
#+HEADER: :wrap example
#+HEADER: :cmdline --quiet
#+BEGIN_SRC maxima
  rat(1/(x+1) + x/(x-1));
#+END_SRC

#+RESULTS: batch-quiet-maxima
#+begin_example
(%i1) rat(1/(x+1)+x/(x-1))
                                  2
                                 x  + 2 x - 1
(%o1)/R/                         ------------
                                     2
                                    x  - 1
#+end_example

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05 16:59       ` Leo Butler
@ 2023-12-05 17:16         ` Fraga, Eric
  2023-12-05 20:18           ` Leo Butler
  0 siblings, 1 reply; 10+ messages in thread
From: Fraga, Eric @ 2023-12-05 17:16 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode List

On Tuesday,  5 Dec 2023 at 16:59, Leo Butler wrote:
> You mentioned returning a value from a maxima code block. 

By this, I mean the value of the last sexp as some other src blocks do
(elisp? octave? Not sure which...).  It's what I would expect to see if
I were to specify ":results value".

And your improvements definitely look good!  Thanks.  I use maxima a lot
for teaching so will need to reconsider the material on some of my
slides (next year... :-)).

I also use embedded Calc as it's easier to incorporate directly in text,
especially in org, but Calc is not quite as capable as maxima as a
computer algebra system.

-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05 17:16         ` Fraga, Eric
@ 2023-12-05 20:18           ` Leo Butler
  2023-12-06 14:15             ` Fraga, Eric
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Butler @ 2023-12-05 20:18 UTC (permalink / raw)
  To: Org Mode List

On Tue, Dec 05 2023, "Fraga, Eric" <e.fraga@ucl.ac.uk> wrote:

> On Tuesday,  5 Dec 2023 at 16:59, Leo Butler wrote:
>> You mentioned returning a value from a maxima code block. 
>
> By this, I mean the value of the last sexp as some other src blocks do
> (elisp? octave? Not sure which...).  It's what I would expect to see if
> I were to specify ":results value".

I think it should be easy to provide this for a few data types (matrix,
string, maybe list), but I think the conversion from a Lisp sexp to an
ELisp sexp will need a lot of assumptions. E.g. how to convert the
Maxima list:

[[a,b],[c,d,[e,f]]]

Or maybe such cases are not important?

Also, what would we do with an arbitrary mathematical expression? Return
a printed representation?

>
> And your improvements definitely look good!  Thanks.  I use maxima a lot
> for teaching so will need to reconsider the material on some of my
> slides (next year... :-)).
>
> I also use embedded Calc as it's easier to incorporate directly in text,
> especially in org, but Calc is not quite as capable as maxima as a
> computer algebra system.

Thanks.

I have used Calc, but never really got the hang of it.

Developing a working session for maxima would make it more feasible to
use it directly in text, as you are using Calc.

Leo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What is the status of ob-maxima.el? Is this a bug?
  2023-12-05 20:18           ` Leo Butler
@ 2023-12-06 14:15             ` Fraga, Eric
  0 siblings, 0 replies; 10+ messages in thread
From: Fraga, Eric @ 2023-12-06 14:15 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode List

Hi Leo,

On Tuesday,  5 Dec 2023 at 20:18, Leo Butler wrote:
> I think it should be easy to provide this for a few data types (matrix,
> string, maybe list), but I think the conversion from a Lisp sexp to an
> ELisp sexp will need a lot of assumptions. E.g. how to convert the
> Maxima list:
>
> [[a,b],[c,d,[e,f]]]
>
> Or maybe such cases are not important?

Good question.  I am not sure what the best approach would be.  My own
use case often does involve results which are vectors of vectors of
values or expressions (solutions to system of equations).  I typically
simply output directly using either print or grind, as in

#+begin_src maxima :results output 
  for i: 1 thru length(solution[1])
  do grind(solution[1][i])$
#+end_src

where "solution" is the result of the computation in my (elided) example
and I only care about the first solution.  I haven't really thought
about how the final "value" should be output.  I'm happy to explore
alternatives.

> Also, what would we do with an arbitrary mathematical expression? Return
> a printed representation?

This might actually be the easiest, of course.

> Developing a working session for maxima would make it more feasible to
> use it directly in text, as you are using Calc.

It would indeed be more feasible but not necessarily a benefit (to me),
as such.

I use Calc for pedagogical aspects, showing step by step calculations,
and it has some benefits over Maxima for this, especially for
engineering topics because it "understands" units (e.g. kg, J, m^2).
Further, I have total control of the formatting by having defined my own
embedded Calc format, lines that start with #+calc: which I can
interpret during the export process in org.

I use maxima to solve more detailed problems so that students can see
the outcome of the algebra to compare with their own work.

And there's the psychological/philosophical benefit of doing everything
I can in Emacs itself! :-)

But, having said that, consistency in the tools used is beneficial so
doing step by step calculations with maxima instead of Calc could be a
good thing for the students.  It would be nice to have that option.

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-06 14:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-05  1:41 What is the status of ob-maxima.el? Is this a bug? Eduardo Ochs
2023-12-05 10:36 ` Fraga, Eric
2023-12-05 11:34   ` Eduardo Ochs
2023-12-05 13:22     ` Fraga, Eric
2023-12-05 16:42   ` Leo Butler
2023-12-05 16:49     ` Fraga, Eric
2023-12-05 16:59       ` Leo Butler
2023-12-05 17:16         ` Fraga, Eric
2023-12-05 20:18           ` Leo Butler
2023-12-06 14:15             ` Fraga, Eric

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).