Skip to content

Instantly share code, notes, and snippets.

@multidis
Last active August 29, 2015 14:08
Show Gist options
  • Save multidis/2929c1c6d62dad32970b to your computer and use it in GitHub Desktop.
Save multidis/2929c1c6d62dad32970b to your computer and use it in GitHub Desktop.
Symbolic evaluation in Julia language via SymPy.jl interface to the Python CAS library SumPy. Illustrative tutorials at http://mth229.github.io/symbolic.html
## first verify python-sympy Ubuntu package is installed,
## and Pkg.add("SymPy") in Julia
using Gadfly # before SymPy to have automatic plotting as below
using SymPy
# declare symbols: one of several ways
# see https://github.com/jverzani/SymPy.jl
x, a, b, c = @syms x a b c
typeof(x)
f(x) = a*exp(-(x - b)^2/c)
f(x) # prints formatted expression
# symbolic derivative
diff(f(x), x)
# gadfly plotting
f(x) = x^x; c = 1
m = diff(f(x)) |> replace(x, c);
fs = [f(x), f(c) + m*(x-c)] # Array with 2 Sym-elements
plot(fs, .5, 1.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment