emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* inclusion of #+RESULTS in a source block
@ 2014-06-16 14:38 Federico Beffa
  2014-06-16 16:53 ` Charles Berry
  0 siblings, 1 reply; 2+ messages in thread
From: Federico Beffa @ 2014-06-16 14:38 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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 --]

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

end of thread, other threads:[~2014-06-16 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-16 14:38 inclusion of #+RESULTS in a source block Federico Beffa
2014-06-16 16:53 ` Charles Berry

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).