In [2]:
using Pkg

In [3]:
Pkg.add("SymPy")
Pkg.build("SymPy")


  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
[1mFetching: [========================================>]  100.0 %.0 % Resolving package versions...
 Installed RecipesBase ────── v0.6.0
 Installed URIParser ──────── v0.4.0
 Installed BinDeps ────────── v0.8.10
 Installed SpecialFunctions ─ v0.7.2
 Installed SymPy ──────────── v0.9.0
  Updating `~/.julia/environments/v1.1/Project.toml`
  [24249f21] + SymPy v0.9.0
  Updating `~/.julia/environments/v1.1/Manifest.toml`
  [9e28174c] + BinDeps v0.8.10
  [3cdcf5f2] + RecipesBase v0.6.0
  [276daf66] + SpecialFunctions v0.7.2
  [24249f21] + SymPy v0.9.0
  [30578b45] + URIParser v0.4.0
  Building SpecialFunctions → `~/.julia/packages/SpecialFunctions/fvheQ/deps/build.log`
  Building SpecialFunctions → `~/.julia/packages/SpecialFunctions/fvheQ/deps/build.log`
  Building Conda ───────────→ `~/.julia/packages/Conda/CpuvI/deps/build.log`
  Building PyCall ──────────→ `~/.julia/packages/PyCall/RQjD7/deps/build.log`

In [4]:
using SymPy


┌ Info: Precompiling SymPy [24249f21-da20-56a4-8eb1-6a02cf4ae2e6]
└ @ Base loading.jl:1186
┌ Info: Installing sympy via the Conda sympy package...
└ @ PyCall ~/.julia/packages/PyCall/RQjD7/src/PyCall.jl:698
┌ Info: Running `conda install -y sympy` in root environment
└ @ Conda ~/.julia/packages/Conda/CpuvI/src/Conda.jl:112
Collecting package metadata: ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: ~/.julia/conda/3

  added / updated specs:
    - sympy


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    fastcache-1.0.2            |   py37h1de35cc_2          28 KB
    gmp-6.1.2                  |       hb37e062_1         734 KB
    gmpy2-2.0.8                |   py37h6ef4df4_2         162 KB
    mpc-1.1.0                  |       h6ef4df4_1          90 KB
    mpfr-4.0.1                 |       h3018a27_3         526 KB
    mpmath-1.1.0               |           py37_0         957 KB
    sympy-1.3                  |           py37_0         9.5 MB
    ------------------------------------------------------------
                                           Total:        11.9 MB

The following NEW packages will be INSTALLED:

  fastcache          pkgs/main/osx-64::fastcache-1.0.2-py37h1de35cc_2
  gmp                pkgs/main/osx-64::gmp-6.1.2-hb37e062_1
  gmpy2              pkgs/main/osx-64::gmpy2-2.0.8-py37h6ef4df4_2
  mpc                pkgs/main/osx-64::mpc-1.1.0-h6ef4df4_1
  mpfr               pkgs/main/osx-64::mpfr-4.0.1-h3018a27_3
  mpmath             pkgs/main/osx-64::mpmath-1.1.0-py37_0
  sympy              pkgs/main/osx-64::sympy-1.3-py37_0



Downloading and Extracting Packages
mpc-1.1.0            | 90 KB     | ########## | 100% 
sympy-1.3            | 9.5 MB    | ########## | 100% 
fastcache-1.0.2      | 28 KB     | ########## | 100% 
mpfr-4.0.1           | 526 KB    | ########## | 100% 
gmpy2-2.0.8          | 162 KB    | ########## | 100% 
mpmath-1.1.0         | 957 KB    | ########## | 100% 
gmp-6.1.2            | 734 KB    | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done

In [1]:
using SymPy

In [2]:
@syms a b c
a,b,c = Sym("a,b,c")


Out[2]:
(a, b, c)

In [3]:
u = symbols("u")
x = symbols("x", real=true)
y1, y2 = symbols("y1, y2", positive=true)
alpha = symbols("alpha", integer=true, positive=true)


Out[3]:
\begin{equation*}\alpha\end{equation*}

In [4]:
x,y,z = symbols("x,y,z")
ex = x + y + z
subs(ex, (x,1), (y,pi))


Out[4]:
\begin{equation*}z + 1 + \pi\end{equation*}

In [5]:
ex |> subs(x, 1) |> subs(y, π)


Out[5]:
\begin{equation*}z + 1 + \pi\end{equation*}

In [6]:
N(PI, 100)


Out[6]:
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170678

In [7]:
N(π, 100)


MethodError: no method matching N(::Irrational{:π}, ::Int64)
Closest candidates are:
  N(!Matched::Sym, ::Int64) at ~/.julia/packages/SymPy/4aR3F/src/subs.jl:186
  N(::Number) at ~/.julia/packages/SymPy/4aR3F/src/subs.jl:176

Stacktrace:
 [1] top-level scope at In[7]:1

In [8]:
π == PI


Out[8]:
true

In [9]:
solve(cos(x) - sin(x))


Out[9]:
\[ \left[ \begin{array}{r}- \frac{3 \pi}{4}\\\frac{\pi}{4}\end{array} \right] \]

In [10]:
x, h = symbols("x,h")
f(x) = exp(x)*sin(x)
limit((f(x+h) - f(x)) / h, h, 0)


Out[10]:
\begin{equation*}e^{x} \sin{\left (x \right )} + e^{x} \cos{\left (x \right )}\end{equation*}

In [11]:
diff(f(x), x)


Out[11]:
\begin{equation*}e^{x} \sin{\left (x \right )} + e^{x} \cos{\left (x \right )}\end{equation*}

In [12]:
# using PyCall
# @pyimport sympy
# @pyimport mpmath
# @pyimport sys
# sys.modules["sympy.mpmath"] = mpmath

In [13]:
# locals = PyDict(Dict(
#     :x => sympy.symbols("x"),
#     :Integral => sympy.Integral,
# :cos => sympy.cos,
# :exp => sympy.exp
# ))
# PyCall.pyeval_("""
# Integral(cos(x)*exp(x), x)
# """, locals, PyCall.Py_eval_input)

In [ ]: