The title of this notebook does not mean "fantastic, amazing things". The title does describe more or less literally the content. Many of the features and commands in Symata will be familiar from other programs. This notebook presents a few things that may be unfamiliar and not documented elsewhere. Also note that many of the "unique" features appear in other tutorial notebooks.
using Symata # enter Symata mode
Version information of main components.
VersionInfo()
symata version 0.3.0-dev.7 julia version 0.6.0-dev.435 python version 2.7.12 sympy version 1.0
OutputStyle
selects the appearance of printed (or rendered) Symata expressions. See the notebook "InteractingWithSymata" for more details.
? 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]
Use Time(True)
and Time(False)
to toggle timing and allocation information after evaluation of each input line. Use Timing(expr)
to time the evaluation of expr
only.
?
prints help on the Help
function.
Help(topic)
, Help("topic")
, or ? topic
prints documentation for topic
.
h"words"
does a case insensitive search of the contents of help documents.
Syamta uses the python package SymPy extensivley. Help
prints relevant SymPy documentation along with Symata documentation. Type ShowSymPyDocs(False)
to disable printing SymPy documentation.
By default, Symata converts input integers to the Julia type Int
. But, you may want bigger numbers:
2^100 # overflow
? BigIntInput
BigIntInput(True)
enable interpreting all integers as arbitrary precision BigInt
s.
BigIntInput(False)
(default) disable interpreting all integers as arbitrary precision BigInts
.
BigIntInput()
return the current state.
You can always specify that an integer should be a BigInt
by giving BI(n)
.
Help( BigIntInput) See also BF, BI, Big, BigFloatInput, N, and SetPrecision. Attributes(BigIntInput) = [Protected]
BigIntInput(True);
2^100
Note that this only applies to input integers (at the moment)
Head(Cos(Pi))
Head( BI(Cos(Pi))) # Convert explicitly to BigInt
Symata's host language is Julia. There are several ways to interact with Julia in a Symata session.
Julia and Symata keep separate lists of symbols. For instance, x
may be defined in Julia, but not Symata, and vice versa.
Use SetJ
to bind (i.e. set) a Julia symbol to a Symata expression.
expr = x + y
? SetJ
SetJ(x,val)
sets the Julia symbol x
to val
.
Variables and functions in Symata are separate from those in Julia, ie, their table of bindings to symbols are separate.
Help( SetJ) Attributes(SetJ) = [HoldFirst,Protected]
Bind the Julia variable z
to the result of evaluating expr
.
SetJ(z , expr)
Execute Julia code, by enclosing it in :( )
. We ask for the value of z
.
J( Main.z )
We can also leave Symata and return to Julia
Julia() # begin interpreting expressions as Julia code. ;
z # Now in Julia
:x + :y
The unexported Julia function symval returns the Symata binding of a symbol.
? Symata.symval
symval(s::SJSym)
return the bound value of the Symata
symbol with Julia-Symbol name s
.
symval(s::SSJSym)
Return the value bound to the Symata symbol s
.
Symata.symval(:expr)
:x + :y
We can do the reverse, set a Symata variable to the value of a Julia variable.
Set a variable in Jula.
a = 1 # Set a Julia symbol (bind an identifier to a value)
1
isymata() # Enter Symata mode again
(expr2 = J( Main.a ); expr2)
Symata symbol expr2
is now set to 1
.
Symata uses the python package SymPy extensively. Most of the interaction with SymPy is transparent to the user. But there are several commands for controlling this interaction.
Use Symata's help search feature to find commands related to SymPy.
h"sympy"
Rewrite SymPyError ExpandA ReturnSymPy ToSymata ShowSymPyDocs ToSymPy
? SymPyError
SymPyError()
returns the most recent SymPy error message. If you see a message warning that a SymPy error has occurred, you can find the detailed error message.
Help( SymPyError) Attributes(SymPyError) = [Protected]
For debugging, you can disable converting SymPy objects to Symata.
? ReturnSymPy
ReturnSymPy(True)
disable conversion of expressions computed by SymPy to Symata.
ReturnSympy(False)
(default) enable conversion to Symata.
ReturnSympy()
return the current state.
Help( ReturnSymPy) See also ShowSymPyDocs, ToSymPy, and ToSymata. Attributes(ReturnSymPy) = [Protected]
? ToSymata
ToSymata(expr)
convert the python PyObject expr
to a Symata expression. Normally, expressions computed by SymPy are automatically converted to Symata expressions.
Help( ToSymata) See also ReturnSymPy, ShowSymPyDocs, and ToSymPy. Attributes(ToSymata) = [HoldAll,Protected]
? ToSymPy
ToSymPy(expr)
convert expr
to a (python) PyObject.
Help( ToSymPy) See also ReturnSymPy, ShowSymPyDocs, and ToSymata. Attributes(ToSymPy) = [Protected]
Use ToSymPy
and ToSymata
to convert between the languages.
(OutputStyle(InputForm), pyobj = ToSymPy(Integrate(f(x),x)))
PyObject Integral(f(x), x)
( OutputStyle(JupyterForm), Head(pyobj))
Recover the Symata expression.
ToSymata(pyobj)
VersionInfo()
symata version 0.3.0-dev.7 julia version 0.6.0-dev.435 python version 2.7.12 sympy version 1.0
Now()