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.
using Symata # load the package and enter Symata mode
Integrate(f(x + I), [x, 0, Infinity])
Here is the same thing in InputForm
style
OutputStyle(InputForm)
Out(2)
Integrate(f(I + x),[x,0,Infinity])
In UnicodeForm
style, some of the symbols are pretty printed.
OutputStyle(UnicodeForm)
Out(2)
Integrate(f(𝕚 + x),[x,0,∞])
Assume(a, Positive)
gammaint = Integrate(E^(-x) * x^(a-1), [x,0,Infinity])
Γ(a)
In InputForm
style
OutputStyle(InputForm)
gammaint
Gamma(a)
And back to JupyterForm
style
OutputStyle(JupyterForm)
gammaint
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)
OutputStyle(InputForm), Expand((x + y)^3)
x^3 + 3*x^2*y + 3x*y^2 + y^3
FullForm(Out(8)) # Internal form of the previous output
Plus(Power(x,3),Times(3,Power(x,2),y),Times(3,x,Power(y,2)),Power(y,3))
Plus(Power(x,3),Times(3,Power(x,2),y),Times(3,x,Power(y,2)),Power(y,3)) # This is also valid input
x^3 + 3*x^2*y + 3x*y^2 + y^3
Compare this to JupyterForm
output style which cannot in general be copied as input.
OutputStyle(JupyterForm);
Integrate(g(x), [x,0,Infinity])
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:
g(x_) := Exp(-x)
Out(11)
In InputForm
style, you can make the output more compact or less compact like this:
OutputStyle(InputForm), CompactOutput(False), Out(10)
x^3 + 3 * x^2 * y + 3x * y^2 + y^3
CompactOutput(True), Out(10)
x^3 + 3*x^2*y + 3x*y^2 + y^3
Here are some examples of formatting with JupyterForm
output style
OutputStyle(JupyterForm), (1/2 + a^b)/(x+y)
Sum(g(i,j), [i,0,Infinity], [j,0,Infinity]) + Sum(h(i,j), [i,0,Infinity], [j,1,n])
Integrate(g(x,y), [x,0,1], [y,0,1])
a < b < c/d
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
.
InputForm( a< b < c/d )
a < b && b < (c*d^(-1))
You can change the way numbers are printed like this.
N(Pi)
N(Pi) * 10^10
FloatFormat(Short);
N(Pi)
N(Pi) * 10^10
Print three digits
FloatFormat(3);
N(Pi)
N(Pi) * 10^10
Changing the number of digits printed does not change the precision of the number.
Precision(N(Pi))
The format of BigFloat numbers is not affected by FloatFormat
N(Pi,50)
Use BigFloatFormat
for this
BigFloatFormat(Short);
N(Pi,50)
Precision(N(Pi,50))
FloatFormat(Full);
N(Pi)
BigFloatFormat(Full);
N(Pi,50)
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.
OutputStyle(InputForm);
[π + 𝕖 + 𝕚 + a, Pi + E + I + a] # \pi + \Bbbe + \Bbbi
[I + a + E + Pi,I + a + E + Pi]
OutputStyle(UnicodeForm);
[π + 𝕖 + 𝕚 + a, Pi + E + I + a]
[𝕚 + a + 𝕖 + π,𝕚 + a + 𝕖 + π]
OutputStyle(JupyterForm);
[π + 𝕖 + 𝕚 + a, Pi + E + I + a]
Pi
and π, etc. refer to the same symbol.
[Pi == π, E == 𝕖, I == 𝕚, EulerGamma == γ, Gamma == Γ]
Cos([Pi, π])
In Symata
, in both the command line REPL and IJulia
, you can use TAB completion to complete built-in and user-defined 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. (This feature may be broken in both Julia and Symata)
You can get the same doc string (and the corresponding sympy
document) by typing ?
followed by the symbol.
? 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.
See also CompactOutput. Attributes(OutputStyle) = [Protected]
VersionInfo()
Symata version 0.4.1-dev.3 Julia version 0.7.0-beta2.1 Python version 2.7.14+ SymPy version 1.0
InputForm(Now())
2018-07-20T13:19:13.094