Interacting with Symata

Output

Three output styles

Symata runs in either the ipython (Jupyter) notebook or the Julia REPL (or even in a dumb terminal). In the Julia REPL two output styles are available, InputForm and UnicodeForm. In the notebook, a third style, called JupyterForm, is available. The notebook starts with the JupyterForm style.


In [1]:
using Symata  # load the package and enter Symata mode

In [2]:
Integrate(f(x+I),[x,0,Infinity])  # input is interpreted as Symata code


Out[2]:
$$ \int_{0}^{\infty}f \! \left( \mathbb{i} + x \right) \, \mathbb{d}x $$

Here is the same thing in InputForm style


In [3]:
OutputStyle(InputForm)
Out(2)


Out[3]:
Integrate(f(I + x),[x,0,Infinity])

In UnicodeForm style, some of the symbols are pretty printed.


In [4]:
OutputStyle(UnicodeForm)
Out(2)


Out[4]:
Integrate(f(𝕚 + x),[x,0,∞])

In [5]:
Assume(a, Positive)
Integrate(E^(-x) * x^(a-1), [x,0,Infinity])


Out[5]:
Γ(a)

In InputForm style


In [6]:
OutputStyle(InputForm)
Out(5)


Out[6]:
Gamma(a)

And back to JupyterForm style


In [7]:
OutputStyle(JupyterForm)
Out(5)


Out[7]:
$$ \Gamma \! \left( a \right) $$

InputForm output style

InputForm style output is closest to the internal form of the expression. It can be copied and pasted as input. (This is also true of UnicodeForm style)


In [8]:
OutputStyle(InputForm), Expand((x+y)^3)


Out[8]:
x^3 + 3x^2*y + 3x*y^2 + y^3

In [9]:
FullForm(Out(8))  # Internal form of the previous output


Out[9]:
Plus(Power(x,3),Times(3,Power(x,2),y),Times(3,x,Power(y,2)),Power(y,3))

In [10]:
Plus(Power(x,3),Times(3,Power(x,2),y),Times(3,x,Power(y,2)),Power(y,3)) # This is also valid input


Out[10]:
x^3 + 3x^2*y + 3x*y^2 + y^3

Compare this to JupyterForm output style which cannot in general be copied as input.


In [11]:
OutputStyle(JupyterForm);

Integrate(g(x), [x,0,Infinity])


Out[11]:
$$ \int_{0}^{\infty}g \! \left( x \right) \, \mathbb{d}x $$

This is what we get by cutting and pasting from the typset integral in Out[12]: ∫∞0g(x)𝕕x. Not valid input. But, you can still refer to the output cell:


In [12]:
g(x_) := Exp(-x)

Out(11)


Out[12]:
$$ 1 $$

In InputForm style, you can make the output more compact or less compact like this:


In [13]:
OutputStyle(InputForm), CompactOutput(False), Out(10)


Out[13]:
x^3 + 3x^2 * y + 3x * y^2 + y^3

In [14]:
CompactOutput(True), Out(10)


Out[14]:
x^3 + 3x^2*y + 3x*y^2 + y^3

JupyterForm output style

Here are some examples of formatting with JupyterForm output style


In [15]:
OutputStyle(JupyterForm), (1/2 +  a^b)/(x+y)


Out[15]:
$$ \frac{\frac{1}{2} + a^{b}}{x + y} $$

In [16]:
Sum(g(i,j), [i,0,Infinity], [j,0,Infinity]) + Sum(h(i,j), [i,0,Infinity], [j,1,n])


Out[16]:
$$ \sum _{\substack{i=0 \\ j=1}}^{\infty,n}h \! \left( i,j \right) + \sum _{\substack{i=0 \\ j=0}}^{\infty}g \! \left( i,j \right) $$

In [17]:
Integrate(g(x,y), [x,0,1], [y,0,1])


Out[17]:
$$ \int_{0}^{1} \mathbb{d}x\int_{0}^{1} \mathbb{d}y \, g \! \left( x,y \right) $$

In [18]:
a < b < c/d


Out[18]:
$$ a\text{<}b \, \text{&&} \, b\text{<} \left( \frac{c}{d} \right) $$

To cut and past from Jupyter to another application, right click on the displayed output. Then choose from the menu which format you like, such as the $\LaTeX$ source. (You can also choose math display options here)

To get an expression that can be cut and pasted as Symata input, say to text editor, you can either switch formats using OutputStyle(InputForm), or wrap a single expression in InputForm.


In [19]:
InputForm( a< b < c/d )


Out[19]:
a < b && b < (c*d^(-1))

Input

Unicode input

Unicode input is inherited from Julia and the ipython/Jupyter notebook. In both the REPL and the notebook, you can enter a $\LaTeX$ macro and hit TAB to convert it to a symbol. For instance, \alpha[TAB] gives α. You can also copy/paste unicode symbols into the notebook.

A few symbols, such as π, are intepreted as builtin Symata symbols.


In [20]:
OutputStyle(InputForm);

In [21]:
[π + 𝕖 + 𝕚 + a, Pi + E + I + a]   # \pi + \Bbbe + \Bbbi


Out[21]:
[I + a + E + Pi,I + a + E + Pi]

In [22]:
OutputStyle(UnicodeForm);

In [23]:
[π + 𝕖 + 𝕚 + a, Pi + E + I + a]


Out[23]:
[𝕚 + a + 𝕖 + π,𝕚 + a + 𝕖 + π]

In [24]:
OutputStyle(JupyterForm);

In [25]:
[π + 𝕖 + 𝕚 + a, Pi + E + I + a]


Out[25]:
$$ \left[ \mathbb{i} + a + \mathbb{e} + \pi ,\mathbb{i} + a + \mathbb{e} + \pi \right] $$

Pi and π, etc. refer to the same symbol.


In [26]:
[Pi == π, E == 𝕖, I == 𝕚, EulerGamma == γ, Gamma == Γ]


Out[26]:
$$ \left[ \text{True},\text{True},\text{True},\text{True},\text{True} \right] $$

In [27]:
Cos([Pi, π])


Out[27]:
$$ \left[ -1,-1 \right] $$

TAB completion

In Symata, in both the command line REPL and IJulia, you can use TAB completion to complete built-in symbols, in the same way that you do in Julia. In IJulia, typing Shift-TAB when the cursor is at the end of a built-in symbol displays a pop-up with the doc string, if available.

You can get the same doc string (and the corresponding sympy document) by typing ? followed by the symbol.


In [28]:
? OutputStyle


OutputStyle(InputForm)

print plain 1d text output.

OutputStyle(UnicodeForm)

print 1d text output with pretty unicode characters.

OutputStyle(JupyterForm)

in a Jupyter notebook, print in typeset mathematics style using latex.

OutputStyle()

return the current output style.

InputForm and UnicodeForm give output that is valid Symata input for the same expression.

Help( OutputStyle)

See also CompactOutput.

 Attributes(OutputStyle) = [Protected]