emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Federico Beffa <beffa@ieee.org>
To: emacs-orgmode@gnu.org
Subject: inclusion of #+RESULTS in a source block
Date: Mon, 16 Jun 2014 16:38:50 +0200	[thread overview]
Message-ID: <CAKrPhPMv7DGb2WcgrAEa=9PEK59x5ku4rsxx9kJcyFyfJbKGxA@mail.gmail.com> (raw)

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

  Suppose you want to use a program such as Sympy or Maxima to find
  the analytic solution of a complicated equation. After this you want
  to make use of that solution for numerical evaluation of various
  cases.

  Is it safe to use the analytic results (without using a session) in the
  following way, or is there a better way?

  #+NAME: analytic-sol
  #+BEGIN_SRC python :session none :results raw
    from sympy import symbols, sqrt, python, solve
    x, a = symbols("x, a")
    y = solve( x**2 + 2*a*x + 1, x)
    return python(y)
  #+END_SRC

  #+NAME: numeric-sol
  #+BEGIN_SRC python :session none
    from sympy import Symbol, sqrt, lambdify
    import numpy as np

    #+RESULTS: analytic-sol
    a = Symbol('a')
    e = [-a - sqrt(a**2 - 1), -a + sqrt(a**2 - 1)]

    f = lambdify(a, e[1], "numpy")
    t = np.r_[1:4]
    return f(t)
  #+END_SRC

  #+RESULTS:
  | -1 | -0.26794919 | -0.17157288 |

Regards,
Fede

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

             reply	other threads:[~2014-06-16 14:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 14:38 Federico Beffa [this message]
2014-06-16 16:53 ` inclusion of #+RESULTS in a source block Charles Berry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKrPhPMv7DGb2WcgrAEa=9PEK59x5ku4rsxx9kJcyFyfJbKGxA@mail.gmail.com' \
    --to=beffa@ieee.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).